summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/command/build_ext.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/packaging/command/build_ext.py')
0 files changed, 0 insertions, 0 deletions
hicssystems/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 82ddb3a39596b6c245d26c80c1e3935aba04a3a9 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 2 Mar 2010 11:12:34 +1000 Subject: Fixed compiler warnings when compiling multimedia module. Reviewed-by:Andrew den Exter --- src/multimedia/base/qmediaserviceprovider.cpp | 14 +++++++++----- src/multimedia/qml/qsoundeffect_qsound_p.cpp | 2 +- src/multimedia/qml/wavedecoder_p.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/multimedia/base/qmediaserviceprovider.cpp b/src/multimedia/base/qmediaserviceprovider.cpp index eb6505c..d51d682 100644 --- a/src/multimedia/base/qmediaserviceprovider.cpp +++ b/src/multimedia/base/qmediaserviceprovider.cpp @@ -268,7 +268,7 @@ class QPluginServiceProvider : public QMediaServiceProvider public: QMediaService* requestService(const QByteArray &type, const QMediaServiceProviderHint &hint) { - QString key(type); + QString key(QString::fromLatin1(type.constData(),type.length())); QListplugins; foreach (QObject *obj, loader()->instances(key)) { @@ -383,7 +383,8 @@ public: const QStringList& codecs, int flags) const { - QList instances = loader()->instances(serviceType); + QList instances = loader()->instances( + QString::fromLatin1(serviceType.constData(),serviceType.length())); if (instances.isEmpty()) return QtMultimedia::NotSupported; @@ -424,7 +425,8 @@ public: QStringList supportedMimeTypes(const QByteArray &serviceType, int flags) const { - QList instances = loader()->instances(serviceType); + QList instances = loader()->instances( + QString::fromLatin1(serviceType.constData(),serviceType.length())); QStringList supportedTypes; @@ -457,7 +459,8 @@ public: { QList res; - foreach(QObject *obj, loader()->instances(serviceType)) { + foreach(QObject *obj, loader()->instances( + QString::fromLatin1(serviceType.constData(),serviceType.length()))) { QMediaServiceSupportedDevicesInterface *iface = qobject_cast(obj); @@ -471,7 +474,8 @@ public: QString deviceDescription(const QByteArray &serviceType, const QByteArray &device) { - foreach(QObject *obj, loader()->instances(serviceType)) { + foreach(QObject *obj, loader()->instances( + QString::fromLatin1(serviceType.constData(),serviceType.length()))) { QMediaServiceSupportedDevicesInterface *iface = qobject_cast(obj); diff --git a/src/multimedia/qml/qsoundeffect_qsound_p.cpp b/src/multimedia/qml/qsoundeffect_qsound_p.cpp index 0292d26..df160a9 100644 --- a/src/multimedia/qml/qsoundeffect_qsound_p.cpp +++ b/src/multimedia/qml/qsoundeffect_qsound_p.cpp @@ -157,7 +157,7 @@ void QSoundEffectPrivate::setMedia(const QMediaContent &media) { m_queued = false; - if (media.isNull() || media.canonicalUrl().scheme() != "file") { + if (media.isNull() || media.canonicalUrl().scheme() != QLatin1String("file")) { m_media = QMediaContent(); return; } diff --git a/src/multimedia/qml/wavedecoder_p.cpp b/src/multimedia/qml/wavedecoder_p.cpp index b7d6101..f2277ae 100644 --- a/src/multimedia/qml/wavedecoder_p.cpp +++ b/src/multimedia/qml/wavedecoder_p.cpp @@ -122,7 +122,7 @@ void WaveDecoder::handleData() else { int bps = qFromLittleEndian(header.wave.bitsPerSample); - format.setCodec("audio/pcm"); + format.setCodec(QLatin1String("audio/pcm")); format.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt); format.setByteOrder(QAudioFormat::LittleEndian); format.setFrequency(qFromLittleEndian(header.wave.sampleRate)); -- cgit v0.12 From 655228dd7f28d6641cabfeb6a878d9aa1ca8db5e Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 4 Mar 2010 09:57:42 +1000 Subject: In the way of merges. Remove. --- imports/Qt/multimedia/qmldir | 1 - imports/Qt/widgets/qmldir | 1 - imports/org/webkit/qmldir | 1 - 3 files changed, 3 deletions(-) delete mode 100644 imports/Qt/multimedia/qmldir delete mode 100644 imports/Qt/widgets/qmldir delete mode 100644 imports/org/webkit/qmldir diff --git a/imports/Qt/multimedia/qmldir b/imports/Qt/multimedia/qmldir deleted file mode 100644 index 0e6f656..0000000 --- a/imports/Qt/multimedia/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin multimedia diff --git a/imports/Qt/widgets/qmldir b/imports/Qt/widgets/qmldir deleted file mode 100644 index 6f19878..0000000 --- a/imports/Qt/widgets/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin widgets diff --git a/imports/org/webkit/qmldir b/imports/org/webkit/qmldir deleted file mode 100644 index 258aa2c..0000000 --- a/imports/org/webkit/qmldir +++ /dev/null @@ -1 +0,0 @@ -plugin webkitqmlplugin -- cgit v0.12 From 752550cec220cf42c77ee932a581d88e104fc256 Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Mon, 8 Mar 2010 16:12:48 +1000 Subject: Add missing QT namespace. --- src/plugins/bearer/nativewifi/platformdefs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/bearer/nativewifi/platformdefs.h b/src/plugins/bearer/nativewifi/platformdefs.h index 57ae852..d67525a 100644 --- a/src/plugins/bearer/nativewifi/platformdefs.h +++ b/src/plugins/bearer/nativewifi/platformdefs.h @@ -52,6 +52,8 @@ #define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 2 #define DOT11_SSID_MAX_LENGTH 32 +QT_BEGIN_NAMESPACE + struct WLAN_NOTIFICATION_DATA { DWORD NotificationSource; DWORD NotificationCode; @@ -319,4 +321,6 @@ extern WlanScanProto local_WlanScan; extern WlanFreeMemoryProto local_WlanFreeMemory; extern WlanCloseHandleProto local_WlanCloseHandle; +QT_END_NAMESPACE + #endif // PLATFORMDEFS_H -- 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 a897301131c59233c872627907925efac8a27c7b Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 12 Mar 2010 13:05:42 +0100 Subject: --warn; --- src/declarative/qml/qdeclarativelist.h | 10 +++++----- src/declarative/util/qdeclarativetimeline_p_p.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index 8d59384..ed402a8 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QObject; -class QMetaObject; +struct QMetaObject; template struct QDeclarativeListProperty { typedef void (*AppendFunction)(QDeclarativeListProperty *, T*); @@ -61,12 +61,12 @@ struct QDeclarativeListProperty { typedef T *(*AtFunction)(QDeclarativeListProperty *, int); typedef void (*ClearFunction)(QDeclarativeListProperty *); - QDeclarativeListProperty() + QDeclarativeListProperty() : object(0), data(0), append(0), count(0), at(0), clear(0), dummy1(0), dummy2(0) {} QDeclarativeListProperty(QObject *o, QList &list) : object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), clear(qlist_clear), dummy1(0), dummy2(0) {} - QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, + QDeclarativeListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, ClearFunction r = 0) : object(o), data(d), append(a), count(c), at(t), clear(r), dummy1(0), dummy2(0) {} @@ -81,7 +81,7 @@ struct QDeclarativeListProperty { QObject *object; void *data; - + AppendFunction append; CountFunction count; @@ -94,7 +94,7 @@ struct QDeclarativeListProperty { private: static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList *)p->data)->append(v); + ((QList *)p->data)->append(v); } static int qlist_count(QDeclarativeListProperty *p) { return ((QList *)p->data)->count(); diff --git a/src/declarative/util/qdeclarativetimeline_p_p.h b/src/declarative/util/qdeclarativetimeline_p_p.h index c08c07c..598c897 100644 --- a/src/declarative/util/qdeclarativetimeline_p_p.h +++ b/src/declarative/util/qdeclarativetimeline_p_p.h @@ -160,7 +160,7 @@ public: QDeclarativeTimeLineObject *callbackObject() const; private: - friend class QDeclarativeTimeLinePrivate; + friend struct QDeclarativeTimeLinePrivate; Callback d0; void *d1; QDeclarativeTimeLineObject *d2; -- cgit v0.12 From 981515b84df18d3f4bde5a8de33ea6a3a9614073 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 15 Mar 2010 07:22:45 +0100 Subject: Get debug code compiling since function signature changes --- src/gui/painting/qtextureglyphcache.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index cf3957b..edbf580 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -73,7 +73,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const const QFixedPoint *) { #ifdef CACHE_DEBUG - printf("Populating with '%s'\n", QString::fromRawData(ti.chars, ti.num_chars).toLatin1().data()); + printf("Populating with %d glyphs\n", numGlyphs); qDebug() << " -> current transformation: " << m_transform; #endif @@ -93,17 +93,14 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const glyph_metrics_t metrics = fontEngine->boundingBox(glyph, m_transform); #ifdef CACHE_DEBUG - printf("'%c' (%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f, ti.ascent=%.2f, ti.descent=%.2f\n", - ti.chars[i].toLatin1(), + printf("(%4x): w=%.2f, h=%.2f, xoff=%.2f, yoff=%.2f, x=%.2f, y=%.2f\n", glyph, metrics.width.toReal(), metrics.height.toReal(), metrics.xoff.toReal(), metrics.yoff.toReal(), metrics.x.toReal(), - metrics.y.toReal(), - ti.ascent.toReal(), - ti.descent.toReal()); + metrics.y.toReal()); #endif int glyph_width = metrics.width.ceil().toInt(); int glyph_height = metrics.height.ceil().toInt(); @@ -333,10 +330,7 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g) QPoint base(c.x + glyphMargin(), c.y + glyphMargin() + c.baseLineY-1); if (m_image.rect().contains(base)) m_image.setPixel(base, 255); - m_image.save(QString::fromLatin1("cache-%1-%2-%3.png") - .arg(m_current_textitem->font().family()) - .arg(m_current_textitem->font().pointSize()) - .arg(m_transform.type())); + m_image.save(QString::fromLatin1("cache-%1.png").arg(int(this))); #endif } -- cgit v0.12 From ee3841ae90156f991717376f34921de97e47097c Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 15 Mar 2010 07:30:58 +0100 Subject: Fixed wasted space in the texture cache. We were using the height of the texture to position the next row, rather than just adding the rowHeight. This used to work when the texture cached grew by rowHeight, now it grows to next power of two... Reviewed-by: Eskil --- src/gui/painting/qtextureglyphcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index edbf580..4ca0c3a 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -136,7 +136,7 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const if (m_cx + c.w > m_w) { // no room on the current line, start new glyph strip m_cx = 0; - m_cy = m_h; + m_cy += rowHeight; } if (m_cy + c.h > m_h) { int new_height = m_h*2; -- 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 b0773d144e1cd31f49be5f70c357d6be030a2e8f Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 10 Mar 2010 16:49:03 +0100 Subject: Assistant: Move search widget into the dock area. Task-number: QTBUG-2048 Reviewed-by: kh1 --- tools/assistant/tools/assistant/centralwidget.cpp | 276 +++++---------------- tools/assistant/tools/assistant/centralwidget.h | 16 +- .../tools/assistant/helpenginewrapper.cpp | 12 - .../assistant/tools/assistant/helpenginewrapper.h | 3 - tools/assistant/tools/assistant/mainwindow.cpp | 80 +++--- tools/assistant/tools/assistant/mainwindow.h | 11 +- 6 files changed, 107 insertions(+), 291 deletions(-) diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index f56e9e3..e562198 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -92,7 +92,6 @@ CentralWidget::CentralWidget(MainWindow *parent) , findWidget(0) , printer(0) , usesDefaultCollection(parent->usesDefaultCollection()) - , m_searchWidget(0) { TRACE_OBJ globalActionList.clear(); @@ -168,10 +167,7 @@ CentralWidget::~CentralWidget() QStringList zoomFactors; QStringList currentPages; - bool searchAttached = m_searchWidget->isAttached(); - - int i = searchAttached ? 1 : 0; - for (; i < tabWidget->count(); ++i) { + for (int i = 0; i < tabWidget->count(); ++i) { HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); if (viewer && viewer->source().isValid()) { currentPages << viewer->source().toString(); @@ -182,7 +178,6 @@ CentralWidget::~CentralWidget() HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); helpEngine.setLastTabPage(tabWidget->currentIndex()); helpEngine.setLastShownPages(currentPages); - helpEngine.setSearchWasAttached(searchAttached); helpEngine.setLastZoomFactors(zoomFactors); } @@ -197,9 +192,7 @@ void CentralWidget::newTab() TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); #if !defined(QT_NO_WEBKIT) - if (viewer && viewer->hasLoadFinished()) -#else - if (viewer) + if (viewer->hasLoadFinished()) #endif setSourceInNewTab(viewer->source()); } @@ -207,23 +200,13 @@ void CentralWidget::newTab() void CentralWidget::zoomIn() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->scaleUp(); - - if (tabWidget->currentWidget() == m_searchWidget) - m_searchWidget->zoomIn(); + currentHelpViewer()->scaleUp(); } void CentralWidget::zoomOut() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->scaleDown(); - - if (tabWidget->currentWidget() == m_searchWidget) - m_searchWidget->zoomOut(); + currentHelpViewer()->scaleDown(); } void CentralWidget::nextPage() @@ -238,11 +221,7 @@ void CentralWidget::nextPage() void CentralWidget::resetZoom() { TRACE_OBJ - if (HelpViewer *viewer = currentHelpViewer()) - viewer->resetScale(); - - if (tabWidget->currentWidget() == m_searchWidget) - m_searchWidget->resetZoom(); + currentHelpViewer()->resetScale(); } void CentralWidget::previousPage() @@ -257,10 +236,10 @@ void CentralWidget::previousPage() void CentralWidget::closeTab() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (!viewer|| tabWidget->count() == 1) + if (tabWidget->count() == 1) return; + HelpViewer *viewer = currentHelpViewer(); tabWidget->removeTab(tabWidget->indexOf(viewer)); QTimer::singleShot(0, viewer, SLOT(deleteLater())); } @@ -323,20 +302,13 @@ void CentralWidget::setLastShownPages() while (zoomFactors.count() < pageCount) zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); - const bool searchIsAttached = m_searchWidget->isAttached(); - const bool searchWasAttached = helpEngine.searchWasAttached(); int tabToShow = helpEngine.lastTabPage(); - if (searchWasAttached && !searchIsAttached && tabToShow != 0) - --tabToShow; - else if (!searchWasAttached && searchIsAttached) - ++tabToShow; - for (int curTab = 0; curTab < pageCount; ++curTab) { const QString &curFile = lastShownPageList.at(curTab); if (helpEngine.findFile(curFile).isValid() || curFile == QLatin1String("about:blank")) { setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat()); - } else if (curTab + searchIsAttached <= tabToShow) + } else if (curTab <= tabToShow) --tabToShow; } @@ -346,36 +318,25 @@ void CentralWidget::setLastShownPages() bool CentralWidget::hasSelection() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - return viewer ? viewer->hasSelection() : false; + return currentHelpViewer()->hasSelection(); } QUrl CentralWidget::currentSource() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->source(); - - return QUrl(); + return currentHelpViewer()->source(); } QString CentralWidget::currentTitle() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->documentTitle(); - - return QString(); + return currentHelpViewer()->documentTitle(); } void CentralWidget::copySelection() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->copy(); + currentHelpViewer()->copy(); } void CentralWidget::showTextSearch() @@ -398,11 +359,7 @@ void CentralWidget::print() TRACE_OBJ #ifndef QT_NO_PRINTER HelpViewer *viewer = currentHelpViewer(); - if (!viewer) - return; - initPrinter(); - QPrintDialog dlg(printer, this); #if defined(QT_NO_WEBKIT) if (viewer->textCursor().hasSelection()) @@ -433,9 +390,7 @@ void CentralWidget::printPreview(QPrinter *p) { TRACE_OBJ #ifndef QT_NO_PRINTER - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->print(p); + currentHelpViewer()->print(p); #endif } @@ -449,54 +404,34 @@ void CentralWidget::pageSetup() #endif } -bool CentralWidget::isHomeAvailable() const -{ - TRACE_OBJ - return currentHelpViewer() ? true : false; -} - void CentralWidget::home() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->home(); + currentHelpViewer()->home(); } bool CentralWidget::isForwardAvailable() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->isForwardAvailable(); - - return false; + return currentHelpViewer()->isForwardAvailable(); } void CentralWidget::forward() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->forward(); + currentHelpViewer()->forward(); } bool CentralWidget::isBackwardAvailable() const { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - return viewer->isBackwardAvailable(); - - return false; + return currentHelpViewer()->isBackwardAvailable(); } void CentralWidget::backward() { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - if (viewer) - viewer->backward(); + currentHelpViewer()->backward(); } @@ -515,10 +450,9 @@ void CentralWidget::setGlobalActions(const QList &actions) void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) { TRACE_OBJ - if (HelpViewer *viewer = currentHelpViewer()) { - if (viewer->launchWithExternalApp(url)) - return; - } + + if (AbstractHelpViewer::launchWithExternalApp(url)) + return; HelpViewer *viewer = new HelpViewer(this, zoom); viewer->installEventFilter(this); @@ -548,20 +482,18 @@ void CentralWidget::connectSignals() { TRACE_OBJ const HelpViewer *viewer = currentHelpViewer(); - if (viewer) { - connect(viewer, SIGNAL(copyAvailable(bool)), this, + connect(viewer, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); - connect(viewer, SIGNAL(forwardAvailable(bool)), this, + connect(viewer, SIGNAL(forwardAvailable(bool)), this, SIGNAL(forwardAvailable(bool))); - connect(viewer, SIGNAL(backwardAvailable(bool)), this, + connect(viewer, SIGNAL(backwardAvailable(bool)), this, SIGNAL(backwardAvailable(bool))); - connect(viewer, SIGNAL(sourceChanged(QUrl)), this, + connect(viewer, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); - connect(viewer, SIGNAL(highlighted(QString)), this, + connect(viewer, SIGNAL(highlighted(QString)), this, SIGNAL(highlighted(QString))); - connect(viewer, SIGNAL(sourceChanged(QUrl)), this, + connect(viewer, SIGNAL(sourceChanged(QUrl)), this, SLOT(setTabTitle(QUrl))); - } } HelpViewer* CentralWidget::viewerAt(int index) const @@ -576,18 +508,10 @@ HelpViewer* CentralWidget::currentHelpViewer() const return qobject_cast(tabWidget->currentWidget()); } -void CentralWidget::activateTab(bool onlyHelpViewer) +void CentralWidget::activateTab() { TRACE_OBJ - if (currentHelpViewer()) { - currentHelpViewer()->setFocus(); - } else { - int idx = 0; - if (onlyHelpViewer) - idx = lastTabPage; - tabWidget->setCurrentIndex(idx); - tabWidget->currentWidget()->setFocus(); - } + currentHelpViewer()->setFocus(); } void CentralWidget::setTabTitle(const QUrl &url) @@ -605,25 +529,18 @@ void CentralWidget::setTabTitle(const QUrl &url) } #else HelpViewer *viewer = currentHelpViewer(); - if (viewer) { - tabWidget->setTabText(lastTabPage, - quoteTabTitle(viewer->documentTitle().trimmed())); - } + tabWidget->setTabText(lastTabPage, + quoteTabTitle(viewer->documentTitle().trimmed())); #endif } void CentralWidget::currentPageChanged(int index) { TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - if (viewer) - lastTabPage = index; + lastTabPage = index; - QWidget *widget = tabWidget->cornerWidget(Qt::TopRightCorner); - widget->setEnabled(viewer && enableTabCloseAction()); - - widget = tabWidget->cornerWidget(Qt::TopLeftCorner); - widget->setEnabled(viewer ? true : false); + QWidget *closeButton = tabWidget->cornerWidget(Qt::TopRightCorner); + closeButton->setEnabled(enableTabCloseAction()); emit currentViewerChanged(); } @@ -778,34 +695,33 @@ bool CentralWidget::findInWebPage(const QString &ttf, bool forward) { TRACE_OBJ #if !defined(QT_NO_WEBKIT) - if (HelpViewer *viewer = currentHelpViewer()) { - bool found = false; - QWebPage::FindFlags options; - if (!ttf.isEmpty()) { - if (!forward) - options |= QWebPage::FindBackward; + HelpViewer *viewer = currentHelpViewer(); + bool found = false; + QWebPage::FindFlags options; + if (!ttf.isEmpty()) { + if (!forward) + options |= QWebPage::FindBackward; - if (findWidget->caseSensitive()) - options |= QWebPage::FindCaseSensitively; + if (findWidget->caseSensitive()) + options |= QWebPage::FindCaseSensitively; - found = viewer->findText(ttf, options); - findWidget->setTextWrappedVisible(false); + found = viewer->findText(ttf, options); + findWidget->setTextWrappedVisible(false); - if (!found) { - options |= QWebPage::FindWrapsAroundDocument; - found = viewer->findText(ttf, options); - if (found) - findWidget->setTextWrappedVisible(true); - } + if (!found) { + options |= QWebPage::FindWrapsAroundDocument; + found = viewer->findText(ttf, options); + if (found) + findWidget->setTextWrappedVisible(true); } - // force highlighting of all other matches, also when empty (clear) - options = QWebPage::HighlightAllOccurrences; - if (findWidget->caseSensitive()) - options |= QWebPage::FindCaseSensitively; - viewer->findText(QLatin1String(""), options); - viewer->findText(ttf, options); - return found; } + // force highlighting of all other matches, also when empty (clear) + options = QWebPage::HighlightAllOccurrences; + if (findWidget->caseSensitive()) + options |= QWebPage::FindCaseSensitively; + viewer->findText(QLatin1String(""), options); + viewer->findText(ttf, options); + return found; // this needs to stay, case for active search results page return findInTextBrowser(ttf, forward); @@ -820,8 +736,6 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) { TRACE_OBJ QTextBrowser *browser = qobject_cast(currentHelpViewer()); - if (tabWidget->currentWidget() == m_searchWidget) - browser = qFindChild(m_searchWidget); if (!browser || ttf.isEmpty()) return false; @@ -868,88 +782,22 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) void CentralWidget::updateBrowserFont() { TRACE_OBJ - const bool searchAttached = searchWidgetAttached(); - if (searchAttached) { - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - m_searchWidget->setFont(helpEngine.usesBrowserFont() - ? helpEngine.browserFont() : qApp->font()); - } - const int count = tabWidget->count(); - if (HelpViewer* viewer = viewerAt(count - 1)) { - const QFont &font = viewer->viewerFont(); - for (int i = searchAttached ? 1 : 0; i < count; ++i) - viewerAt(i)->setViewerFont(font); - } -} - -bool CentralWidget::searchWidgetAttached() const -{ - TRACE_OBJ - return m_searchWidget && m_searchWidget->isAttached(); -} - -void CentralWidget::createSearchWidget(QHelpSearchEngine *searchEngine) -{ - TRACE_OBJ - if (m_searchWidget) - return; - - m_searchWidget = new SearchWidget(searchEngine, this); - connect(m_searchWidget, SIGNAL(requestShowLink(QUrl)), this, - SLOT(setSourceFromSearch(QUrl))); - connect(m_searchWidget, SIGNAL(requestShowLinkInNewTab(QUrl)), this, - SLOT(setSourceFromSearchInNewTab(QUrl))); - - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - m_searchWidget->setFont(!helpEngine.usesBrowserFont() ? qApp->font() - : helpEngine.browserFont()); -} - -void CentralWidget::activateSearchWidget(bool updateLastTabPage) -{ - TRACE_OBJ - if (!m_searchWidget) - createSearchWidget(HelpEngineWrapper::instance().searchEngine()); - - if (!m_searchWidget->isAttached()) { - tabWidget->insertTab(0, m_searchWidget, tr("Search")); - m_searchWidget->setAttached(true); - - if (updateLastTabPage) - lastTabPage++; - } - - tabWidget->setCurrentWidget(m_searchWidget); - m_searchWidget->setFocus(); -} - -void CentralWidget::removeSearchWidget() -{ - TRACE_OBJ - if (searchWidgetAttached()) { - tabWidget->removeTab(0); - m_searchWidget->setAttached(false); - } + const QFont &font = viewerAt(count - 1)->viewerFont(); + for (int i = 0; i < count; ++i) + viewerAt(i)->setViewerFont(font); } int CentralWidget::availableHelpViewer() const { TRACE_OBJ - int count = tabWidget->count(); - if (searchWidgetAttached()) - count--; - return count; + return tabWidget->count(); } bool CentralWidget::enableTabCloseAction() const { TRACE_OBJ - int minTabCount = 1; - if (searchWidgetAttached()) - minTabCount = 2; - - return (tabWidget->count() > minTabCount); + return tabWidget->count() > 1; } QString CentralWidget::quoteTabTitle(const QString &title) const @@ -990,8 +838,6 @@ CentralWidget::highlightSearchTerms() { TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); - if (!viewer) - return; QHelpSearchEngine *searchEngine = HelpEngineWrapper::instance().searchEngine(); diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index f286ff7..66d4142 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -51,7 +51,6 @@ class HelpViewer; class MainWindow; class QHelpSearchEngine; class QTabWidget; -class SearchWidget; class CentralWidget : public QWidget { @@ -65,7 +64,6 @@ public: bool hasSelection() const; QUrl currentSource() const; QString currentTitle() const; - bool isHomeAvailable() const; bool isForwardAvailable() const; bool isBackwardAvailable() const; QList globalActions() const; @@ -74,11 +72,6 @@ public: HelpViewer *viewerAt(int index) const; HelpViewer *currentHelpViewer() const; - bool searchWidgetAttached() const; - void createSearchWidget(QHelpSearchEngine *searchEngine); - void activateSearchWidget(bool updateLastTabPage = false); - void removeSearchWidget(); - int availableHelpViewer() const; bool enableTabCloseAction() const; @@ -107,12 +100,15 @@ public slots: void forward(); void backward(); - void activateTab(bool onlyHelpViewer = false); + void activateTab(); void findNext(); void findPrevious(); void find(const QString &text, bool forward); + void setSourceFromSearch(const QUrl &url); + void setSourceFromSearchInNewTab(const QUrl &url); + signals: void currentViewerChanged(); void copyAvailable(bool yes); @@ -132,8 +128,6 @@ private slots: void currentPageChanged(int index); void showTabBarContextMenu(const QPoint &point); void printPreview(QPrinter *printer); - void setSourceFromSearch(const QUrl &url); - void setSourceFromSearchInNewTab(const QUrl &url); void highlightSearchTerms(); private: @@ -153,8 +147,6 @@ private: FindWidget *findWidget; QPrinter *printer; bool usesDefaultCollection; - - SearchWidget *m_searchWidget; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index e21e95d..c7f4091 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -566,18 +566,6 @@ void HelpEngineWrapper::setLastTabPage(int lastPage) CollectionConfiguration::setLastTabPage(*d->m_helpEngine, lastPage); } -bool HelpEngineWrapper::searchWasAttached() const -{ - TRACE_OBJ - return d->m_helpEngine->customValue(SearchWasAttachedKey).toBool(); -} - -void HelpEngineWrapper::setSearchWasAttached(bool attached) -{ - TRACE_OBJ - d->m_helpEngine->setCustomValue(SearchWasAttachedKey, attached); -} - int HelpEngineWrapper::startOption() const { TRACE_OBJ diff --git a/tools/assistant/tools/assistant/helpenginewrapper.h b/tools/assistant/tools/assistant/helpenginewrapper.h index c1041b6..f1a381a 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.h +++ b/tools/assistant/tools/assistant/helpenginewrapper.h @@ -170,9 +170,6 @@ public: int startOption() const; void setStartOption(int option); - bool searchWasAttached() const; - void setSearchWasAttached(bool attached); - bool hasFontSettings() const; bool usesAppFont() const; void setUseAppFont(bool useAppFont); diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 8096218..2605050 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -131,30 +131,34 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) contentDock->setWidget(m_contentWindow); addDockWidget(Qt::LeftDockWidgetArea, contentDock); - QDockWidget *bookmarkDock = 0; - if (BookmarkManager *manager = BookmarkManager::instance()) { - bookmarkDock = new QDockWidget(tr("Bookmarks"), this); - bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); - bookmarkDock->setWidget(m_bookmarkWidget = manager->bookmarkDockWidget()); - addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); - - connect(manager, SIGNAL(escapePressed()), this, + m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine()); + m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font() + : helpEngineWrapper.browserFont()); + QDockWidget *searchDock = new QDockWidget(tr("Search"), this); + searchDock->setObjectName(QLatin1String("SearchWindow")); + searchDock->setWidget(m_searchWindow); + addDockWidget(Qt::LeftDockWidgetArea, searchDock); + + BookmarkManager *bookMarkManager = BookmarkManager::instance(); + QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this); + bookmarkDock->setObjectName(QLatin1String("BookmarkWindow")); + bookmarkDock->setWidget(m_bookmarkWidget + = bookMarkManager->bookmarkDockWidget()); + addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); + + connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); - connect(manager, SIGNAL(setSource(QUrl)), m_centralWidget, + connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); - connect(manager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget, + connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget, SLOT(setSourceInNewTab(QUrl))); - connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), manager, - SLOT(addBookmark(QString, QString))); - } + connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), + bookMarkManager, SLOT(addBookmark(QString, QString))); QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); - m_centralWidget->createSearchWidget(searchEngine); - m_centralWidget->activateSearchWidget(); - QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); @@ -190,10 +194,10 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) restoreGeometry(ba); } else { tabifyDockWidget(contentDock, indexDock); - if (bookmarkDock) - tabifyDockWidget(indexDock, bookmarkDock); + tabifyDockWidget(indexDock, bookmarkDock); + tabifyDockWidget(bookmarkDock, searchDock); contentDock->raise(); - resize(QSize(800, 600)); + resize(QSize(1024, 768)); } if (!helpEngineWrapper.hasFontSettings()) { @@ -490,7 +494,7 @@ void MainWindow::setupActions() QKeySequence(tr("ALT+I"))); m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarksDockWidget()), QKeySequence(tr("ALT+O"))); - m_viewMenu->addAction(tr("Search"), this, SLOT(showSearchWidget()), + m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()), QKeySequence(tr("ALT+S"))); menu = menuBar()->addMenu(tr("&Go")); @@ -524,8 +528,7 @@ void MainWindow::setupActions() tmp->setShortcuts(QList() << QKeySequence(tr("Ctrl+Alt+Left")) << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); - if (BookmarkManager *manager = BookmarkManager::instance()) - manager->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks"))); + BookmarkManager::instance()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks"))); menu = menuBar()->addMenu(tr("&Help")); m_aboutAction = menu->addAction(tr("About..."), this, SLOT(showAboutDialog())); @@ -601,6 +604,12 @@ void MainWindow::setupActions() connect(m_contentWindow, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); + // search window + connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), m_centralWidget, + SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWindow, SIGNAL(requestShowLinkInNewTab(QUrl)), + m_centralWidget, SLOT(setSourceFromSearchInNewTab(QUrl))); + #if defined(QT_NO_PRINTER) m_pageSetupAction->setVisible(false); m_printPreviewAction->setVisible(false); @@ -727,15 +736,9 @@ void MainWindow::gotoAddress() void MainWindow::updateNavigationItems() { TRACE_OBJ - bool hasCurrentViewer = m_centralWidget->isHomeAvailable(); m_copyAction->setEnabled(m_centralWidget->hasSelection()); - m_homeAction->setEnabled(hasCurrentViewer); - m_syncAction->setEnabled(hasCurrentViewer); - m_printPreviewAction->setEnabled(hasCurrentViewer); - m_printAction->setEnabled(hasCurrentViewer); m_nextAction->setEnabled(m_centralWidget->isForwardAvailable()); m_backAction->setEnabled(m_centralWidget->isBackwardAvailable()); - m_newTabAction->setEnabled(hasCurrentViewer); } void MainWindow::updateTabCloseAction() @@ -891,15 +894,13 @@ void MainWindow::setBookmarksVisible(bool visible) void MainWindow::showBookmarksDockWidget() { TRACE_OBJ - if (m_bookmarkWidget) - activateDockWidget(m_bookmarkWidget); + activateDockWidget(m_bookmarkWidget); } void MainWindow::hideBookmarksDockWidget() { TRACE_OBJ - if (m_bookmarkWidget) - m_bookmarkWidget->parentWidget()->hide(); + m_bookmarkWidget->parentWidget()->hide(); } void MainWindow::setSearchVisible(bool visible) @@ -914,13 +915,13 @@ void MainWindow::setSearchVisible(bool visible) void MainWindow::showSearch() { TRACE_OBJ - m_centralWidget->activateSearchWidget(); + activateDockWidget(m_searchWindow); } void MainWindow::hideSearch() { TRACE_OBJ - m_centralWidget->removeSearchWidget(); + m_searchWindow->parentWidget()->hide(); } void MainWindow::activateDockWidget(QWidget *w) @@ -940,10 +941,7 @@ void MainWindow::setIndexString(const QString &str) void MainWindow::activateCurrentBrowser() { TRACE_OBJ - CentralWidget *cw = CentralWidget::instance(); - if (cw) { - cw->activateTab(true); - } + CentralWidget::instance()->activateTab(); } void MainWindow::activateCurrentCentralWidgetTab() @@ -952,12 +950,6 @@ void MainWindow::activateCurrentCentralWidgetTab() m_centralWidget->activateTab(); } -void MainWindow::showSearchWidget() -{ - TRACE_OBJ - m_centralWidget->activateSearchWidget(true); -} - void MainWindow::updateApplicationFont() { TRACE_OBJ diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 40ca624..6ac148e 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -53,13 +53,14 @@ class QLineEdit; class QComboBox; class QMenu; -class IndexWindow; -class QHelpEngineCore; -class QHelpEngine; class CentralWidget; -class ContentWindow; class CmdLineParser; +class ContentWindow; +class IndexWindow; class QtDocInstaller; +class QHelpEngineCore; +class QHelpEngine; +class SearchWidget; class MainWindow : public QMainWindow { @@ -87,7 +88,6 @@ public slots: void setIndexVisible(bool visible); void setBookmarksVisible(bool visible); void setSearchVisible(bool visible); - void showSearchWidget(); void syncContents(); void activateCurrentCentralWidgetTab(); void currentFilterChanged(const QString &filter); @@ -144,6 +144,7 @@ private: CentralWidget *m_centralWidget; IndexWindow *m_indexWindow; ContentWindow *m_contentWindow; + SearchWidget *m_searchWindow; QLineEdit *m_addressLineEdit; QComboBox *m_filterCombo; -- cgit v0.12 From bd9adf630d8f95cfb2cb18731ee581de4efda167 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 6 Apr 2010 12:47:49 +0200 Subject: Assistant: Get rid of tabs. A QTabWidget is not the right widget if there are more than a handful of pages. Therefore, we now manage pages in a special widget. Reviewed-by: kh1 --- tools/assistant/tools/assistant/assistant.pro | 12 +- .../assistant/tools/assistant/assistant_images.qrc | 6 +- tools/assistant/tools/assistant/centralwidget.cpp | 456 +++------------------ tools/assistant/tools/assistant/centralwidget.h | 43 +- tools/assistant/tools/assistant/contentwindow.cpp | 5 +- tools/assistant/tools/assistant/globalactions.cpp | 163 ++++++++ tools/assistant/tools/assistant/globalactions.h | 91 ++++ tools/assistant/tools/assistant/helpviewer_qtb.cpp | 15 +- tools/assistant/tools/assistant/helpviewer_qtb.h | 7 +- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 35 +- tools/assistant/tools/assistant/helpviewer_qwv.h | 5 +- .../tools/assistant/images/closebutton.png | Bin 0 -> 288 bytes .../tools/assistant/images/darkclosebutton.png | Bin 0 -> 319 bytes tools/assistant/tools/assistant/indexwindow.cpp | 3 +- tools/assistant/tools/assistant/mainwindow.cpp | 234 ++++------- tools/assistant/tools/assistant/mainwindow.h | 16 +- .../assistant/tools/assistant/openpagesmanager.cpp | 308 ++++++++++++++ tools/assistant/tools/assistant/openpagesmanager.h | 104 +++++ tools/assistant/tools/assistant/openpagesmodel.cpp | 120 ++++++ tools/assistant/tools/assistant/openpagesmodel.h | 76 ++++ .../assistant/tools/assistant/openpageswidget.cpp | 181 ++++++++ tools/assistant/tools/assistant/openpageswidget.h | 76 ++++ .../tools/assistant/preferencesdialog.cpp | 15 +- .../assistant/tools/assistant/preferencesdialog.h | 1 - tools/assistant/tools/assistant/remotecontrol.cpp | 10 +- 25 files changed, 1336 insertions(+), 646 deletions(-) create mode 100644 tools/assistant/tools/assistant/globalactions.cpp create mode 100644 tools/assistant/tools/assistant/globalactions.h create mode 100644 tools/assistant/tools/assistant/images/closebutton.png create mode 100644 tools/assistant/tools/assistant/images/darkclosebutton.png create mode 100644 tools/assistant/tools/assistant/openpagesmanager.cpp create mode 100644 tools/assistant/tools/assistant/openpagesmanager.h create mode 100644 tools/assistant/tools/assistant/openpagesmodel.cpp create mode 100644 tools/assistant/tools/assistant/openpagesmodel.h create mode 100644 tools/assistant/tools/assistant/openpageswidget.cpp create mode 100644 tools/assistant/tools/assistant/openpageswidget.h diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index ff0ecc5..78f48c1 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -12,6 +12,8 @@ DESTDIR = ../../../../bin target.path = $$[QT_INSTALL_BINS] INSTALLS += target DEPENDPATH += ../shared +DEPENDPATH += . +INCLUDEPATH += . # ## Work around a qmake issue when statically linking to # ## not-yet-installed plugins @@ -42,7 +44,11 @@ HEADERS += aboutdialog.h \ topicchooser.h \ tracer.h \ xbelsupport.h \ - ../shared/collectionconfiguration.h + ../shared/collectionconfiguration.h \ + openpagesmodel.h \ + globalactions.h \ + openpageswidget.h \ + openpagesmanager.h win32:HEADERS += remotecontrol_win.h SOURCES += aboutdialog.cpp \ @@ -72,6 +78,10 @@ SOURCES += aboutdialog.cpp \ topicchooser.cpp \ xbelsupport.cpp \ ../shared/collectionconfiguration.cpp \ + openpagesmodel.cpp \ + globalactions.cpp \ + openpageswidget.cpp \ + openpagesmanager.cpp FORMS += bookmarkdialog.ui \ bookmarkmanagerwidget.ui \ diff --git a/tools/assistant/tools/assistant/assistant_images.qrc b/tools/assistant/tools/assistant/assistant_images.qrc index 34918c0..b4f2523 100644 --- a/tools/assistant/tools/assistant/assistant_images.qrc +++ b/tools/assistant/tools/assistant/assistant_images.qrc @@ -1,11 +1,10 @@ - + images/trolltech-logo.png images/assistant-128.png images/assistant.png images/wrap.png images/bookmark.png -#mac images/mac/addtab.png images/mac/book.png images/mac/closetab.png @@ -19,7 +18,6 @@ images/mac/zoomin.png images/mac/zoomout.png images/mac/resetzoom.png -#win images/win/addtab.png images/win/book.png images/win/closetab.png @@ -33,5 +31,7 @@ images/win/zoomin.png images/win/zoomout.png images/win/resetzoom.png + images/closebutton.png + images/darkclosebutton.png diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index e562198..c5a46af 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -38,97 +38,49 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "centralwidget.h" + #include "findwidget.h" #include "helpenginewrapper.h" #include "helpviewer_qtb.h" #include "helpviewer_qwv.h" -#include "searchwidget.h" -#include "mainwindow.h" +#include "tracer.h" #include "../shared/collectionconfiguration.h" #include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include #include QT_BEGIN_NAMESPACE namespace { - HelpViewer* helpViewerFromTabPosition(const QTabWidget *widget, - const QPoint &point) - { - TRACE_OBJ - QTabBar *tabBar = qFindChild(widget); - for (int i = 0; i < tabBar->count(); ++i) { - if (tabBar->tabRect(i).contains(point)) - return qobject_cast(widget->widget(i)); - } - return 0; - } CentralWidget *staticCentralWidget = 0; } // -- CentralWidget -CentralWidget::CentralWidget(MainWindow *parent) +CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) - , lastTabPage(0) - , tabWidget(0) , findWidget(0) , printer(0) - , usesDefaultCollection(parent->usesDefaultCollection()) { TRACE_OBJ - globalActionList.clear(); staticCentralWidget = this; QVBoxLayout *vboxLayout = new QVBoxLayout(this); - QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); vboxLayout->setMargin(0); - tabWidget = new QTabWidget(this); -#ifndef Q_OS_MAC - resourcePath.append(QLatin1String("win")); -#else - resourcePath.append(QLatin1String("mac")); - tabWidget->setDocumentMode(true); -#endif - - connect(tabWidget, SIGNAL(currentChanged(int)), this, - SLOT(currentPageChanged(int))); - - QToolButton *newTabButton = new QToolButton(this); - newTabButton->setAutoRaise(true); - newTabButton->setToolTip(tr("Add new page")); - newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png"))); - - tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner); - connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab())); - - QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setEnabled(false); - closeTabButton->setAutoRaise(true); - closeTabButton->setToolTip(tr("Close current page")); - closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png"))); - - tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); - connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab())); - - vboxLayout->addWidget(tabWidget); + m_stackedWidget = new QStackedWidget(this); + vboxLayout->addWidget(m_stackedWidget); findWidget = new FindWidget(this); vboxLayout->addWidget(findWidget); @@ -140,14 +92,6 @@ CentralWidget::CentralWidget(MainWindow *parent) SLOT(find(QString, bool))); connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab())); - QTabBar *tabBar = qFindChild(tabWidget); - if (tabBar) { - tabBar->installEventFilter(this); - tabBar->setContextMenuPolicy(Qt::CustomContextMenu); - connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(showTabBarContextMenu(QPoint))); - } - #if defined(QT_NO_WEBKIT) QPalette p = palette(); p.setColor(QPalette::Inactive, QPalette::Highlight, @@ -167,18 +111,19 @@ CentralWidget::~CentralWidget() QStringList zoomFactors; QStringList currentPages; - for (int i = 0; i < tabWidget->count(); ++i) { - HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); - if (viewer && viewer->source().isValid()) { - currentPages << viewer->source().toString(); + for (int i = 0; i < m_stackedWidget->count(); ++i) { + const HelpViewer * const viewer = viewerAt(i); + const QUrl &source = viewer->source(); + if (source.isValid()) { + currentPages << source.toString(); zoomFactors << QString::number(viewer->scale()); } } HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - helpEngine.setLastTabPage(tabWidget->currentIndex()); helpEngine.setLastShownPages(currentPages); helpEngine.setLastZoomFactors(zoomFactors); + helpEngine.setLastTabPage(m_stackedWidget->currentIndex()); } CentralWidget *CentralWidget::instance() @@ -187,16 +132,6 @@ CentralWidget *CentralWidget::instance() return staticCentralWidget; } -void CentralWidget::newTab() -{ - TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); -#if !defined(QT_NO_WEBKIT) - if (viewer->hasLoadFinished()) -#endif - setSourceInNewTab(viewer->source()); -} - void CentralWidget::zoomIn() { TRACE_OBJ @@ -209,110 +144,18 @@ void CentralWidget::zoomOut() currentHelpViewer()->scaleDown(); } -void CentralWidget::nextPage() -{ - TRACE_OBJ - int index = tabWidget->currentIndex() + 1; - if (index >= tabWidget->count()) - index = 0; - tabWidget->setCurrentIndex(index); -} - void CentralWidget::resetZoom() { TRACE_OBJ currentHelpViewer()->resetScale(); } -void CentralWidget::previousPage() -{ - TRACE_OBJ - int index = tabWidget->currentIndex() -1; - if (index < 0) - index = tabWidget->count() -1; - tabWidget->setCurrentIndex(index); -} - -void CentralWidget::closeTab() -{ - TRACE_OBJ - if (tabWidget->count() == 1) - return; - - HelpViewer *viewer = currentHelpViewer(); - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); -} - void CentralWidget::setSource(const QUrl &url) { TRACE_OBJ HelpViewer *viewer = currentHelpViewer(); - HelpViewer *lastViewer = - qobject_cast(tabWidget->widget(lastTabPage)); - - if (!viewer && !lastViewer) { - viewer = new HelpViewer(this); - viewer->installEventFilter(this); - lastTabPage = tabWidget->addTab(viewer, QString()); - tabWidget->setCurrentIndex(lastTabPage); - connectSignals(); - } else { - viewer = lastViewer; - } - viewer->setSource(url); - currentPageChanged(lastTabPage); viewer->setFocus(Qt::OtherFocusReason); - tabWidget->setCurrentIndex(lastTabPage); - tabWidget->setTabText(lastTabPage, quoteTabTitle(viewer->documentTitle())); -} - -void CentralWidget::setupWidget() -{ - TRACE_OBJ - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - int option = helpEngine.startOption(); - if (option != ShowLastPages) { - QString homePage; - if (option == ShowHomePage) - homePage = helpEngine.homePage(); - else if (option == ShowBlankPage) - homePage = QLatin1String("about:blank"); - setSource(homePage); - } else { - setLastShownPages(); - } -} - -void CentralWidget::setLastShownPages() -{ - TRACE_OBJ - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - const QStringList &lastShownPageList = helpEngine.lastShownPages(); - const int pageCount = lastShownPageList.count(); - if (pageCount == 0) { - if (usesDefaultCollection) - setSource(QUrl(QLatin1String("help"))); - else - setSource(QUrl(QLatin1String("about:blank"))); - return; - } - QStringList zoomFactors = helpEngine.lastZoomFactors(); - while (zoomFactors.count() < pageCount) - zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); - - int tabToShow = helpEngine.lastTabPage(); - for (int curTab = 0; curTab < pageCount; ++curTab) { - const QString &curFile = lastShownPageList.at(curTab); - if (helpEngine.findFile(curFile).isValid() - || curFile == QLatin1String("about:blank")) { - setSourceInNewTab(curFile, zoomFactors.at(curTab).toFloat()); - } else if (curTab <= tabToShow) - --tabToShow; - } - - tabWidget->setCurrentIndex(tabToShow); } bool CentralWidget::hasSelection() const @@ -434,78 +277,30 @@ void CentralWidget::backward() currentHelpViewer()->backward(); } - -QList CentralWidget::globalActions() const +void CentralWidget::connectSignals(HelpViewer *page) { TRACE_OBJ - return globalActionList; -} - -void CentralWidget::setGlobalActions(const QList &actions) -{ - TRACE_OBJ - globalActionList = actions; -} - -void CentralWidget::setSourceInNewTab(const QUrl &url, qreal zoom) -{ - TRACE_OBJ - - if (AbstractHelpViewer::launchWithExternalApp(url)) - return; - - HelpViewer *viewer = new HelpViewer(this, zoom); - viewer->installEventFilter(this); - viewer->setSource(url); - viewer->setFocus(Qt::OtherFocusReason); - tabWidget->setCurrentIndex(tabWidget->addTab(viewer, - quoteTabTitle(viewer->documentTitle()))); - connectSignals(); -} - -HelpViewer *CentralWidget::newEmptyTab() -{ - TRACE_OBJ - HelpViewer *viewer = new HelpViewer(this); - viewer->installEventFilter(this); - viewer->setFocus(Qt::OtherFocusReason); -#if defined(QT_NO_WEBKIT) - viewer->setDocumentTitle(tr("unknown")); -#endif - tabWidget->setCurrentIndex(tabWidget->addTab(viewer, tr("unknown"))); - - connectSignals(); - return viewer; -} - -void CentralWidget::connectSignals() -{ - TRACE_OBJ - const HelpViewer *viewer = currentHelpViewer(); - connect(viewer, SIGNAL(copyAvailable(bool)), this, - SIGNAL(copyAvailable(bool))); - connect(viewer, SIGNAL(forwardAvailable(bool)), this, - SIGNAL(forwardAvailable(bool))); - connect(viewer, SIGNAL(backwardAvailable(bool)), this, - SIGNAL(backwardAvailable(bool))); - connect(viewer, SIGNAL(sourceChanged(QUrl)), this, - SIGNAL(sourceChanged(QUrl))); - connect(viewer, SIGNAL(highlighted(QString)), this, + connect(page, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); + connect(page, SIGNAL(forwardAvailable(bool)), this, + SIGNAL(forwardAvailable(bool))); + connect(page, SIGNAL(backwardAvailable(bool)), this, + SIGNAL(backwardAvailable(bool))); + connect(page, SIGNAL(sourceChanged(QUrl)), this, + SLOT(handleSourceChanged(QUrl))); + connect(page, SIGNAL(highlighted(QString)), this, SIGNAL(highlighted(QString))); - connect(viewer, SIGNAL(sourceChanged(QUrl)), this, - SLOT(setTabTitle(QUrl))); } HelpViewer* CentralWidget::viewerAt(int index) const { TRACE_OBJ - return qobject_cast(tabWidget->widget(index)); + return static_cast(m_stackedWidget->widget(index)); } HelpViewer* CentralWidget::currentHelpViewer() const { TRACE_OBJ - return qobject_cast(tabWidget->currentWidget()); + return static_cast(m_stackedWidget->currentWidget()); } void CentralWidget::activateTab() @@ -514,90 +309,6 @@ void CentralWidget::activateTab() currentHelpViewer()->setFocus(); } -void CentralWidget::setTabTitle(const QUrl &url) -{ - TRACE_OBJ - Q_UNUSED(url) -#if !defined(QT_NO_WEBKIT) - QTabBar *tabBar = qFindChild(tabWidget); - for (int tab = 0; tab < tabBar->count(); ++tab) { - HelpViewer *viewer = qobject_cast(tabWidget->widget(tab)); - if (viewer) { - tabWidget->setTabText(tab, - quoteTabTitle(viewer->documentTitle().trimmed())); - } - } -#else - HelpViewer *viewer = currentHelpViewer(); - tabWidget->setTabText(lastTabPage, - quoteTabTitle(viewer->documentTitle().trimmed())); -#endif -} - -void CentralWidget::currentPageChanged(int index) -{ - TRACE_OBJ - lastTabPage = index; - - QWidget *closeButton = tabWidget->cornerWidget(Qt::TopRightCorner); - closeButton->setEnabled(enableTabCloseAction()); - - emit currentViewerChanged(); -} - -void CentralWidget::showTabBarContextMenu(const QPoint &point) -{ - TRACE_OBJ - HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, point); - if (!viewer) - return; - - QTabBar *tabBar = qFindChild(tabWidget); - - QMenu menu(QLatin1String(""), tabBar); - QAction *newPage = menu.addAction(tr("Add New Page")); - - bool enableAction = enableTabCloseAction(); - QAction *closePage = menu.addAction(tr("Close This Page")); - closePage->setEnabled(enableAction); - - QAction *closePages = menu.addAction(tr("Close Other Pages")); - closePages->setEnabled(enableAction); - - menu.addSeparator(); - - QAction *newBookmark = menu.addAction(tr("Add Bookmark for this Page...")); - const QString &url = viewer->source().toString(); - if (url.isEmpty() || url == QLatin1String("about:blank")) - newBookmark->setEnabled(false); - - QAction *pickedAction = menu.exec(tabBar->mapToGlobal(point)); - if (pickedAction == newPage) - setSourceInNewTab(viewer->source()); - - if (pickedAction == closePage) { - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - } - - if (pickedAction == closePages) { - int currentPage = tabWidget->indexOf(viewer); - for (int i = tabBar->count() -1; i >= 0; --i) { - viewer = qobject_cast(tabWidget->widget(i)); - if (i != currentPage && viewer) { - tabWidget->removeTab(i); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - - if (i < currentPage) - --currentPage; - } - } - } - - if (pickedAction == newBookmark) - emit addBookmark(viewer->documentTitle(), viewer->source().toString()); -} - bool CentralWidget::eventFilter(QObject *object, QEvent *e) { TRACE_OBJ @@ -624,25 +335,6 @@ bool CentralWidget::eventFilter(QObject *object, QEvent *e) } } - if (qobject_cast(object)) { - const bool dblClick = e->type() == QEvent::MouseButtonDblClick; - if ((e->type() == QEvent::MouseButtonRelease) || dblClick) { - QMouseEvent *mouseEvent = static_cast(e); - HelpViewer *viewer = helpViewerFromTabPosition(tabWidget, - mouseEvent->pos()); - if (viewer) { - if ((mouseEvent->button() == Qt::MidButton) || dblClick) { - if (availableHelpViewer() > 1) { - tabWidget->removeTab(tabWidget->indexOf(viewer)); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); - currentPageChanged(tabWidget->currentIndex()); - return true; - } - } - } - } - } - return QWidget::eventFilter(object, e); } @@ -782,31 +474,12 @@ bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) void CentralWidget::updateBrowserFont() { TRACE_OBJ - const int count = tabWidget->count(); + const int count = m_stackedWidget->count(); const QFont &font = viewerAt(count - 1)->viewerFont(); for (int i = 0; i < count; ++i) viewerAt(i)->setViewerFont(font); } -int CentralWidget::availableHelpViewer() const -{ - TRACE_OBJ - return tabWidget->count(); -} - -bool CentralWidget::enableTabCloseAction() const -{ - TRACE_OBJ - return tabWidget->count() > 1; -} - -QString CentralWidget::quoteTabTitle(const QString &title) const -{ - TRACE_OBJ - QString s = title; - return s.replace(QLatin1Char('&'), QLatin1String("&&")); -} - void CentralWidget::setSourceFromSearch(const QUrl &url) { @@ -821,19 +494,6 @@ CentralWidget::setSourceFromSearch(const QUrl &url) } void -CentralWidget::setSourceFromSearchInNewTab(const QUrl &url) -{ - TRACE_OBJ - setSourceInNewTab(url); -#if defined(QT_NO_WEBKIT) - highlightSearchTerms(); -#else - connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, - SLOT(highlightSearchTerms())); -#endif -} - -void CentralWidget::highlightSearchTerms() { TRACE_OBJ @@ -900,48 +560,48 @@ CentralWidget::highlightSearchTerms() #endif } - -void CentralWidget::closeOrReloadTabs(const QList &indices, bool tryReload) +void CentralWidget::addPage(HelpViewer *page, bool fromSearch) { TRACE_OBJ - QList sortedIndices = indices; - qSort(sortedIndices); - for (int i = sortedIndices.count(); --i >= 0;) { - const int tab = sortedIndices.at(i); - bool close = true; - if (tryReload) { - HelpViewer *viewer = - qobject_cast(tabWidget->widget(tab)); - if (HelpEngineWrapper::instance().findFile(viewer->source()).isValid()) { - viewer->reload(); - close = false; - } - } - if (close) - closeTabAt(tab); + page->installEventFilter(this); + page->setFocus(Qt::OtherFocusReason); + connectSignals(page); + m_stackedWidget->addWidget(page); + if (fromSearch) { +#if defined(QT_NO_WEBKIT) + highlightSearchTerms(); +#else + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); +#endif } - if (availableHelpViewer() == 0) - setSource(QUrl(QLatin1String("about:blank"))); } -void CentralWidget::closeTabAt(int index) +void CentralWidget::removePage(int index) { TRACE_OBJ - HelpViewer *viewer = qobject_cast(tabWidget->widget(index)); - tabWidget->removeTab(index); - QTimer::singleShot(0, viewer, SLOT(deleteLater())); + const bool currentChanged = index == currentIndex(); + m_stackedWidget->removeWidget(m_stackedWidget->widget(index)); + if (currentChanged) + emit currentViewerChanged(); } -QMap CentralWidget::currentSourceFileList() const +void CentralWidget::setCurrentPage(HelpViewer *page) { TRACE_OBJ - QMap sourceList; - for (int i = 0; i < tabWidget->count(); ++i) { - HelpViewer *viewer = qobject_cast(tabWidget->widget(i)); - if (viewer && viewer->source().isValid()) - sourceList.insert(i, viewer->source().host()); - } - return sourceList; + m_stackedWidget->setCurrentWidget(page); + emit currentViewerChanged(); +} + +int CentralWidget::currentIndex() const +{ + return m_stackedWidget->currentIndex(); +} + +void CentralWidget::handleSourceChanged(const QUrl &url) +{ + if (sender() == currentHelpViewer()) + emit sourceChanged(url); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 66d4142..9b8db30 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -48,45 +48,36 @@ QT_BEGIN_NAMESPACE class FindWidget; class HelpViewer; -class MainWindow; -class QHelpSearchEngine; -class QTabWidget; +class QStackedWidget; class CentralWidget : public QWidget { Q_OBJECT public: - CentralWidget(MainWindow *parent); + CentralWidget(QWidget *parent); ~CentralWidget(); - void setupWidget(); bool hasSelection() const; QUrl currentSource() const; QString currentTitle() const; bool isForwardAvailable() const; bool isBackwardAvailable() const; - QList globalActions() const; - void setGlobalActions(const QList &actions); HelpViewer *viewerAt(int index) const; HelpViewer *currentHelpViewer() const; - int availableHelpViewer() const; - bool enableTabCloseAction() const; - - void closeOrReloadTabs(const QList &indices, bool tryReload); - void closeTabAt(int index); - QMap currentSourceFileList() const; + void addPage(HelpViewer *page, bool fromSearch = false); + void removePage(int index); + void setCurrentPage(HelpViewer *page); + int currentIndex() const; static CentralWidget *instance(); public slots: void zoomIn(); void zoomOut(); - void nextPage(); void resetZoom(); - void previousPage(); void copySelection(); void showTextSearch(); void print(); @@ -94,8 +85,7 @@ public slots: void printPreview(); void updateBrowserFont(); void setSource(const QUrl &url); - void setSourceInNewTab(const QUrl &url, qreal zoom = 0.0); - HelpViewer *newEmptyTab(); + void setSourceFromSearch(const QUrl &url); void home(); void forward(); void backward(); @@ -106,9 +96,6 @@ public slots: void findPrevious(); void find(const QString &text, bool forward); - void setSourceFromSearch(const QUrl &url); - void setSourceFromSearchInNewTab(const QUrl &url); - signals: void currentViewerChanged(); void copyAvailable(bool yes); @@ -122,31 +109,21 @@ protected: void keyPressEvent(QKeyEvent *); private slots: - void newTab(); - void closeTab(); - void setTabTitle(const QUrl& url); - void currentPageChanged(int index); - void showTabBarContextMenu(const QPoint &point); void printPreview(QPrinter *printer); void highlightSearchTerms(); + void handleSourceChanged(const QUrl &url); private: - void connectSignals(); + void connectSignals(HelpViewer *page); bool eventFilter(QObject *object, QEvent *e); bool findInWebPage(const QString &ttf, bool forward); bool findInTextBrowser(const QString &ttf, bool forward); void initPrinter(); - QString quoteTabTitle(const QString &title) const; - void setLastShownPages(); private: - int lastTabPage; - QList globalActionList; - - QTabWidget *tabWidget; + QStackedWidget *m_stackedWidget; FindWidget *findWidget; QPrinter *printer; - bool usesDefaultCollection; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index e0347c8..3af4d34 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "openpagesmanager.h" #include #include @@ -145,7 +146,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); if (itm && AbstractHelpViewer::canOpenPage(itm->url().path())) - CentralWidget::instance()->setSourceInNewTab(itm->url()); + OpenPagesManager::instance()->createPage(itm->url()); } } else if (button == Qt::LeftButton) { itemClicked(index); @@ -179,7 +180,7 @@ void ContentWindow::showContextMenu(const QPoint &pos) if (curTab == action) emit linkActivated(itm->url()); else if (newTab == action) - CentralWidget::instance()->setSourceInNewTab(itm->url()); + OpenPagesManager::instance()->createPage(itm->url()); } void ContentWindow::itemClicked(const QModelIndex &index) diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp new file mode 100644 index 0000000..75c57b6 --- /dev/null +++ b/tools/assistant/tools/assistant/globalactions.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "globalactions.h" + +#include "centralwidget.h" +#include "tracer.h" + +#include + +GlobalActions *GlobalActions::instance(QObject *parent) +{ + Q_ASSERT(!m_instance != !parent); + if (!m_instance) + m_instance = new GlobalActions(parent); + return m_instance; +} + +GlobalActions::GlobalActions(QObject *parent) : QObject(parent) +{ + TRACE_OBJ + + // TODO: Put resource path in misc class + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); +#ifdef Q_OS_MAC + resourcePath.append(QLatin1String("mac")); +#else + resourcePath.append(QLatin1String("win")); +#endif + CentralWidget *centralWidget = CentralWidget::instance(); + + m_backAction = new QAction(tr("&Back"), parent); + m_backAction->setEnabled(false); + m_backAction->setShortcuts(QKeySequence::Back); + m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png"))); + connect(m_backAction, SIGNAL(triggered()), centralWidget, SLOT(backward())); + m_actionList << m_backAction; + + m_nextAction = new QAction(tr("&Forward"), parent); + m_nextAction->setPriority(QAction::LowPriority); + m_nextAction->setEnabled(false); + m_nextAction->setShortcuts(QKeySequence::Forward); + m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png"))); + connect(m_nextAction, SIGNAL(triggered()), centralWidget, SLOT(forward())); + m_actionList << m_nextAction; + + m_homeAction = new QAction(tr("&Home"), parent); + m_homeAction->setShortcut(tr("ALT+Home")); + m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png"))); + connect(m_homeAction, SIGNAL(triggered()), centralWidget, SLOT(home())); + m_actionList << m_homeAction; + + QAction *separator = new QAction(parent); + separator->setSeparator(true); + m_actionList << separator; + + m_zoomInAction = new QAction(tr("Zoom &in"), parent); + m_zoomInAction->setPriority(QAction::LowPriority); + m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png"))); + m_zoomInAction->setShortcut(QKeySequence::ZoomIn); + connect(m_zoomInAction, SIGNAL(triggered()), centralWidget, SLOT(zoomIn())); + m_actionList << m_zoomInAction; + + m_zoomOutAction = new QAction(tr("Zoom &out"), parent); + m_zoomOutAction->setPriority(QAction::LowPriority); + m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png"))); + m_zoomOutAction->setShortcut(QKeySequence::ZoomOut); + connect(m_zoomOutAction, SIGNAL(triggered()), centralWidget, SLOT(zoomOut())); + m_actionList << m_zoomOutAction; + + separator = new QAction(parent); + separator->setSeparator(true); + m_actionList << separator; + + m_copyAction = new QAction(tr("&Copy selected Text"), parent); + m_copyAction->setPriority(QAction::LowPriority); + m_copyAction->setIconText("&Copy"); + m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png"))); + m_copyAction->setShortcuts(QKeySequence::Copy); + m_copyAction->setEnabled(false); + connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copySelection())); + m_actionList << m_copyAction; + + m_printAction = new QAction(tr("&Print..."), parent); + m_printAction->setPriority(QAction::LowPriority); + m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png"))); + m_printAction->setShortcut(QKeySequence::Print); + connect(m_printAction, SIGNAL(triggered()), centralWidget, SLOT(print())); + m_actionList << m_printAction; + + m_findAction = new QAction(tr("&Find in Text..."), parent); + m_findAction->setIconText(tr("&Find")); + m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png"))); + m_findAction->setShortcuts(QKeySequence::Find); + connect(m_findAction, SIGNAL(triggered()), centralWidget, SLOT(showTextSearch())); + m_actionList << m_findAction; + + #ifdef Q_WS_X11 + m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon())); + m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon())); + m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon())); + m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon())); + m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon())); + m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon())); + m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon())); + m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon())); +#endif +} + +void GlobalActions::updateActions() +{ + TRACE_OBJ + CentralWidget *centralWidget = CentralWidget::instance(); + m_copyAction->setEnabled(centralWidget->hasSelection()); + m_nextAction->setEnabled(centralWidget->isForwardAvailable()); + m_backAction->setEnabled(centralWidget->isBackwardAvailable()); +} + +void GlobalActions::setCopyAvailable(bool available) +{ + TRACE_OBJ + m_copyAction->setEnabled(available); +} + +GlobalActions *GlobalActions::m_instance = 0; diff --git a/tools/assistant/tools/assistant/globalactions.h b/tools/assistant/tools/assistant/globalactions.h new file mode 100644 index 0000000..e53e08f --- /dev/null +++ b/tools/assistant/tools/assistant/globalactions.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 GLOBALACTION_H +#define GLOBALACTION_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class QAction; + +class GlobalActions : public QObject +{ + Q_OBJECT + Q_DISABLE_COPY(GlobalActions) +public: + static GlobalActions *instance(QObject *parent = 0); + + QList actionList() const { return m_actionList; } + QAction *backAction() const { return m_backAction; } + QAction *nextAction() const { return m_nextAction; } + QAction *homeAction() const { return m_homeAction; } + QAction *zoomInAction() const { return m_zoomInAction; } + QAction *zoomOutAction() const { return m_zoomOutAction; } + QAction *copyAction() const { return m_copyAction; } + QAction *printAction() const { return m_printAction; } + QAction *findAction() const { return m_findAction; } + + Q_SLOT void updateActions(); + Q_SLOT void setCopyAvailable(bool available); + +private: + GlobalActions(QObject *parent); + + static GlobalActions *m_instance; + + QAction *m_backAction; + QAction *m_nextAction; + QAction *m_homeAction; + QAction *m_zoomInAction; + QAction *m_zoomOutAction; + QAction *m_copyAction; + QAction *m_printAction; + QAction *m_findAction; + + QList m_actionList; +}; + +QT_END_NAMESPACE + +#endif // GLOBALACTION_H diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index bba2850..f6df611 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -42,8 +42,9 @@ #if defined(QT_NO_WEBKIT) -#include "centralwidget.h" +#include "globalactions.h" #include "helpenginewrapper.h" +#include "openpagesmanager.h" #include "tracer.h" #include @@ -55,12 +56,10 @@ QT_BEGIN_NAMESPACE -HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) - : QTextBrowser(parent) - , zoomCount(zoom) +HelpViewer::HelpViewer(qreal zoom) + : zoomCount(zoom) , controlPressed(false) , lastAnchor(QString()) - , parentWidget(parent) , helpEngine(HelpEngineWrapper::instance()) , forceFont(false) { @@ -71,6 +70,7 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) QFont font = viewerFont(); font.setPointSize(int(font.pointSize() + zoom)); setViewerFont(font); + connect(this, SIGNAL(sourceChanged(QUrl), this, SIGNAL(titleChanged())); } HelpViewer::~HelpViewer() @@ -176,7 +176,7 @@ void HelpViewer::openLinkInNewTab() if(lastAnchor.isEmpty()) return; - parentWidget->setSourceInNewTab(QUrl(lastAnchor)); + OpenPagesManager::instance()->createNewTab(QUrl(lastAnchor)); lastAnchor.clear(); } @@ -222,7 +222,8 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *e) SLOT(openLinkInNewTab())); menu.addSeparator(); } - menu.addActions(parentWidget->globalActions()); + + menu.addActions(GlobalActions::instance()->actionList()); QAction *action = menu.exec(e->globalPos()); if (action == copyAnchorAction) QApplication::clipboard()->setText(link.toString()); diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h index 5b38870..b6ab903 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ b/tools/assistant/tools/assistant/helpviewer_qtb.h @@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE -class CentralWidget; class HelpEngineWrapper; class QContextMenuEvent; class QKeyEvent; @@ -65,7 +64,7 @@ class HelpViewer : public QTextBrowser, public AbstractHelpViewer Q_OBJECT public: - HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + HelpViewer(qreal zoom = 0.0); ~HelpViewer(); QFont viewerFont() const; @@ -81,6 +80,9 @@ public: inline bool hasSelection() const { return textCursor().hasSelection(); } +signals: + void titleChanged(); + public Q_SLOTS: void home(); @@ -103,7 +105,6 @@ private: int zoomCount; bool controlPressed; QString lastAnchor; - CentralWidget* parentWidget; HelpEngineWrapper &helpEngine; bool forceFont; diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 9bb66e1..934fb03 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -45,6 +45,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" +#include "openpagesmanager.h" #include "tracer.h" #include @@ -156,7 +157,7 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, class HelpPage : public QWebPage { public: - HelpPage(CentralWidget *central, QObject *parent); + HelpPage(QObject *parent); protected: virtual QWebPage *createWindow(QWebPage::WebWindowType); @@ -166,7 +167,6 @@ protected: const QNetworkRequest &request, NavigationType type); private: - CentralWidget *centralWidget; bool closeNewTabIfNeeded; friend class HelpViewer; @@ -174,9 +174,8 @@ private: Qt::KeyboardModifiers m_keyboardModifiers; }; -HelpPage::HelpPage(CentralWidget *central, QObject *parent) +HelpPage::HelpPage(QObject *parent) : QWebPage(parent) - , centralWidget(central) , closeNewTabIfNeeded(false) , m_pressedButtons(Qt::NoButton) , m_keyboardModifiers(Qt::NoModifier) @@ -187,9 +186,8 @@ HelpPage::HelpPage(CentralWidget *central, QObject *parent) QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) { TRACE_OBJ - HelpPage* newPage = static_cast(centralWidget->newEmptyTab()->page()); - if (newPage) - newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; + HelpPage* newPage = static_cast(OpenPagesManager::instance()->createPage()->page()); + newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; closeNewTabIfNeeded = false; return newPage; } @@ -216,18 +214,17 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, const QUrl &url = request.url(); if (AbstractHelpViewer::launchWithExternalApp(url)) { if (closeNewTab) - QMetaObject::invokeMethod(centralWidget, "closeTab"); + QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentTab"); return false; } if (type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) { - if (HelpViewer* viewer = centralWidget->newEmptyTab()) - centralWidget->setSource(url); - m_pressedButtons = Qt::NoButton; - m_keyboardModifiers = Qt::NoModifier; - return false; + OpenPagesManager::instance()->createPage(url); + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; + return false; } return true; @@ -235,23 +232,18 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, // -- HelpViewer -HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) - : QWebView(parent) - , parentWidget(parent) - , loadFinished(false) +HelpViewer::HelpViewer(qreal zoom) + : loadFinished(false) , helpEngine(HelpEngineWrapper::instance()) { TRACE_OBJ setAcceptDrops(false); - setPage(new HelpPage(parent, this)); - + setPage(new HelpPage(this)); page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); action->setText(tr("Open Link in New Tab")); - if (!parent) - action->setVisible(false); pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); @@ -267,6 +259,7 @@ HelpViewer::HelpViewer(CentralWidget *parent, qreal zoom) SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); + connect(this, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged())); setFont(viewerFont()); setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h index fbfbaac..ea5ec78 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ b/tools/assistant/tools/assistant/helpviewer_qwv.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE -class CentralWidget; class HelpEngineWrapper; class QMouseEvent; @@ -62,7 +61,7 @@ class HelpViewer : public QWebView, public AbstractHelpViewer Q_OBJECT public: - HelpViewer(CentralWidget *parent, qreal zoom = 0.0); + HelpViewer(qreal zoom = 0.0); ~HelpViewer(); QFont viewerFont() const; @@ -102,6 +101,7 @@ Q_SIGNALS: void backwardAvailable(bool enabled); void highlighted(const QString &); void sourceChanged(const QUrl &); + void titleChanged(); protected: virtual void wheelEvent(QWheelEvent *); @@ -113,7 +113,6 @@ private Q_SLOTS: void setLoadFinished(bool ok); private: - CentralWidget* parentWidget; bool loadFinished; HelpEngineWrapper &helpEngine; }; diff --git a/tools/assistant/tools/assistant/images/closebutton.png b/tools/assistant/tools/assistant/images/closebutton.png new file mode 100644 index 0000000..c978cf5 Binary files /dev/null and b/tools/assistant/tools/assistant/images/closebutton.png differ diff --git a/tools/assistant/tools/assistant/images/darkclosebutton.png b/tools/assistant/tools/assistant/images/darkclosebutton.png new file mode 100644 index 0000000..1077663 Binary files /dev/null and b/tools/assistant/tools/assistant/images/darkclosebutton.png differ diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 63ddbe4..7a47e85 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -44,6 +44,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" +#include "openpagesmanager.h" #include "topicchooser.h" #include @@ -222,7 +223,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) if (!AbstractHelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else - CentralWidget::instance()->setSourceInNewTab(url); + OpenPagesManager::instance()->createPage(url); } } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 2605050..4c8a2dc 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -38,57 +38,55 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "mainwindow.h" +#include "aboutdialog.h" #include "bookmarkmanager.h" #include "centralwidget.h" -#include "indexwindow.h" -#include "topicchooser.h" +#include "cmdlineparser.h" #include "contentwindow.h" -#include "preferencesdialog.h" +#include "globalactions.h" #include "helpenginewrapper.h" +#include "indexwindow.h" +#include "openpagesmanager.h" +#include "preferencesdialog.h" +#include "qtdocinstaller.h" #include "remotecontrol.h" -#include "cmdlineparser.h" -#include "aboutdialog.h" #include "searchwidget.h" -#include "qtdocinstaller.h" - -// #define TRACING_REQUESTED +#include "topicchooser.h" +#include "tracer.h" -#include -#include +#include #include #include -#include +#include #include #include -#include #include -#include +#include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include #include -#include -#include +#include +#include #include -#include -#include #include -#include +#include +#include #include -#include -#include -#include #include +#include #include +#include QT_BEGIN_NAMESPACE @@ -105,6 +103,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) TRACE_OBJ setToolButtonStyle(Qt::ToolButtonFollowStyle); + setDockOptions(ForceTabbedDocks); // Has no effect; Qt bug? QString collectionFile; if (usesDefaultCollection()) { @@ -146,12 +145,19 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) = bookMarkManager->bookmarkDockWidget()); addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock); + QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this); + openPagesDock->setObjectName(QLatin1String("Open Pages")); + OpenPagesManager *openPagesManager + = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url()); + openPagesDock->setWidget(openPagesManager->openPagesWidget()); + addDockWidget(Qt::LeftDockWidgetArea, openPagesDock); + connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, SLOT(setSource(QUrl))); - connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), m_centralWidget, - SLOT(setSourceInNewTab(QUrl))); + connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)), + openPagesManager, SLOT(createPage(QUrl))); connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)), bookMarkManager, SLOT(addBookmark(QString, QString))); @@ -195,9 +201,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) } else { tabifyDockWidget(contentDock, indexDock); tabifyDockWidget(indexDock, bookmarkDock); - tabifyDockWidget(bookmarkDock, searchDock); + tabifyDockWidget(bookmarkDock, openPagesDock); + tabifyDockWidget(openPagesDock, searchDock); contentDock->raise(); - resize(QSize(1024, 768)); + const QRect screen = QApplication::desktop()->screenGeometry(); + resize(4*screen.width()/5, 4*screen.height()/5); } if (!helpEngineWrapper.hasFontSettings()) { @@ -261,6 +269,8 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) this, SLOT(documentationUpdated(QString))); } setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); + GlobalActions::instance()->updateActions(); + showNewAddress(); } MainWindow::~MainWindow() @@ -391,11 +401,6 @@ void MainWindow::checkInitState() void MainWindow::insertLastPages() { TRACE_OBJ - if (m_cmdLine->url().isValid()) - m_centralWidget->setSource(m_cmdLine->url()); - else - m_centralWidget->setupWidget(); - if (m_cmdLine->search() == CmdLineParser::Activate) showSearch(); } @@ -418,18 +423,16 @@ void MainWindow::setupActions() m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget, SLOT(printPreview())); - m_printAction = menu->addAction(tr("&Print..."), m_centralWidget, SLOT(print())); - m_printAction->setPriority(QAction::LowPriority); - m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png"))); - m_printAction->setShortcut(QKeySequence::Print); - + GlobalActions *globalActions = GlobalActions::instance(this); + menu->addAction(globalActions->printAction()); menu->addSeparator(); - m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab())); + OpenPagesManager * const openPages = OpenPagesManager::instance(); + m_newTabAction + = menu->addAction(tr("New &Tab"), openPages, SLOT(createPage())); m_newTabAction->setShortcut(QKeySequence::AddTab); - - m_closeTabAction = menu->addAction(tr("&Close Tab"), m_centralWidget, - SLOT(closeTab())); + m_closeTabAction = menu->addAction(tr("&Close Tab"), + openPages, SLOT(closeCurrentPage())); m_closeTabAction->setShortcuts(QKeySequence::Close); QAction *tmp = menu->addAction(tr("&Quit"), this, SLOT(close())); @@ -441,19 +444,8 @@ void MainWindow::setupActions() #endif menu = menuBar()->addMenu(tr("&Edit")); - m_copyAction = menu->addAction(tr("&Copy selected Text"), m_centralWidget, - SLOT(copySelection())); - m_copyAction->setPriority(QAction::LowPriority); - m_copyAction->setIconText("&Copy"); - m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png"))); - m_copyAction->setShortcuts(QKeySequence::Copy); - m_copyAction->setEnabled(false); - - m_findAction = menu->addAction(tr("&Find in Text..."), m_centralWidget, - SLOT(showTextSearch())); - m_findAction->setIconText(tr("&Find")); - m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png"))); - m_findAction->setShortcuts(QKeySequence::Find); + menu->addAction(globalActions->copyAction()); + menu->addAction(globalActions->findAction()); QAction *findNextAction = menu->addAction(tr("Find &Next"), m_centralWidget, SLOT(findNext())); @@ -468,17 +460,8 @@ void MainWindow::setupActions() tmp->setMenuRole(QAction::PreferencesRole); m_viewMenu = menuBar()->addMenu(tr("&View")); - m_zoomInAction = m_viewMenu->addAction(tr("Zoom &in"), m_centralWidget, - SLOT(zoomIn())); - m_zoomInAction->setPriority(QAction::LowPriority); - m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png"))); - m_zoomInAction->setShortcut(QKeySequence::ZoomIn); - - m_zoomOutAction = m_viewMenu->addAction(tr("Zoom &out"), m_centralWidget, - SLOT(zoomOut())); - m_zoomOutAction->setPriority(QAction::LowPriority); - m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png"))); - m_zoomOutAction->setShortcut(QKeySequence::ZoomOut); + m_viewMenu->addAction(globalActions->zoomInAction()); + m_viewMenu->addAction(globalActions->zoomOutAction()); m_resetZoomAction = m_viewMenu->addAction(tr("Normal &Size"), m_centralWidget, SLOT(resetZoom())); @@ -496,22 +479,13 @@ void MainWindow::setupActions() QKeySequence(tr("ALT+O"))); m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()), QKeySequence(tr("ALT+S"))); + m_viewMenu->addAction(tr("Open Pages"), this, SLOT(showOpenPages()), + QKeySequence(tr("ALT+P"))); menu = menuBar()->addMenu(tr("&Go")); - m_homeAction = menu->addAction(tr("&Home"), m_centralWidget, SLOT(home())); - m_homeAction->setShortcut(tr("ALT+Home")); - m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png"))); - - m_backAction = menu->addAction(tr("&Back"), m_centralWidget, SLOT(backward())); - m_backAction->setEnabled(false); - m_backAction->setShortcuts(QKeySequence::Back); - m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png"))); - - m_nextAction = menu->addAction(tr("&Forward"), m_centralWidget, SLOT(forward())); - m_nextAction->setPriority(QAction::LowPriority); - m_nextAction->setEnabled(false); - m_nextAction->setShortcuts(QKeySequence::Forward); - m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png"))); + menu->addAction(globalActions->homeAction()); + menu->addAction(globalActions->backAction()); + menu->addAction(globalActions->nextAction()); m_syncAction = menu->addAction(tr("Sync with Table of Contents"), this, SLOT(syncContents())); @@ -520,11 +494,11 @@ void MainWindow::setupActions() menu->addSeparator(); - tmp = menu->addAction(tr("Next Page"), m_centralWidget, SLOT(nextPage())); + tmp = menu->addAction(tr("Next Page"), openPages, SLOT(nextPage())); tmp->setShortcuts(QList() << QKeySequence(tr("Ctrl+Alt+Right")) << QKeySequence(Qt::CTRL + Qt::Key_PageDown)); - tmp = menu->addAction(tr("Previous Page"), m_centralWidget, SLOT(previousPage())); + tmp = menu->addAction(tr("Previous Page"), openPages, SLOT(previousPage())); tmp->setShortcuts(QList() << QKeySequence(tr("Ctrl+Alt+Left")) << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); @@ -535,39 +509,25 @@ void MainWindow::setupActions() m_aboutAction->setMenuRole(QAction::AboutRole); #ifdef Q_WS_X11 - m_backAction->setIcon(QIcon::fromTheme("go-previous" , m_backAction->icon())); - m_nextAction->setIcon(QIcon::fromTheme("go-next" , m_nextAction->icon())); - m_zoomInAction->setIcon(QIcon::fromTheme("zoom-in" , m_zoomInAction->icon())); - m_zoomOutAction->setIcon(QIcon::fromTheme("zoom-out" , m_zoomOutAction->icon())); m_resetZoomAction->setIcon(QIcon::fromTheme("zoom-original" , m_resetZoomAction->icon())); m_syncAction->setIcon(QIcon::fromTheme("view-refresh" , m_syncAction->icon())); - m_copyAction->setIcon(QIcon::fromTheme("edit-copy" , m_copyAction->icon())); - m_findAction->setIcon(QIcon::fromTheme("edit-find" , m_findAction->icon())); - m_homeAction->setIcon(QIcon::fromTheme("go-home" , m_homeAction->icon())); - m_printAction->setIcon(QIcon::fromTheme("document-print" , m_printAction->icon())); #endif QToolBar *navigationBar = addToolBar(tr("Navigation Toolbar")); navigationBar->setObjectName(QLatin1String("NavigationToolBar")); - navigationBar->addAction(m_backAction); - navigationBar->addAction(m_nextAction); - navigationBar->addAction(m_homeAction); + navigationBar->addAction(globalActions->backAction()); + navigationBar->addAction(globalActions->nextAction()); + navigationBar->addAction(globalActions->homeAction()); navigationBar->addAction(m_syncAction); - QAction *sep = navigationBar->addSeparator(); - navigationBar->addAction(m_copyAction); - navigationBar->addAction(m_printAction); - navigationBar->addAction(m_findAction); - QAction *sep2 = navigationBar->addSeparator(); - navigationBar->addAction(m_zoomInAction); - navigationBar->addAction(m_zoomOutAction); + navigationBar->addSeparator(); + navigationBar->addAction(globalActions->copyAction()); + navigationBar->addAction(globalActions->printAction()); + navigationBar->addAction(globalActions->findAction()); + navigationBar->addSeparator(); + navigationBar->addAction(globalActions->zoomInAction()); + navigationBar->addAction(globalActions->zoomOutAction()); navigationBar->addAction(m_resetZoomAction); - QList actionList; - actionList << m_backAction << m_nextAction << m_homeAction << sep - << m_zoomInAction << m_zoomOutAction << sep2 << m_copyAction - << m_printAction << m_findAction; - m_centralWidget->setGlobalActions(actionList); - #if defined(Q_WS_MAC) QMenu *windowMenu = new QMenu(tr("&Window"), this); menuBar()->insertMenu(menu->menuAction(), windowMenu); @@ -577,16 +537,14 @@ void MainWindow::setupActions() #endif // content viewer connections - connect(m_centralWidget, SIGNAL(copyAvailable(bool)), this, - SLOT(copyAvailable(bool))); - connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, - SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, - SLOT(updateTabCloseAction())); - connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), this, - SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), this, - SLOT(updateNavigationItems())); + connect(m_centralWidget, SIGNAL(copyAvailable(bool)), globalActions, + SLOT(setCopyAvailable(bool))); + connect(m_centralWidget, SIGNAL(currentViewerChanged()), globalActions, + SLOT(updateActions())); + connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), globalActions, + SLOT(updateActions())); + connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), globalActions, + SLOT(updateActions())); connect(m_centralWidget, SIGNAL(highlighted(QString)), statusBar(), SLOT(showMessage(QString))); @@ -605,10 +563,10 @@ void MainWindow::setupActions() SLOT(activateCurrentCentralWidgetTab())); // search window - connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), m_centralWidget, - SLOT(setSourceFromSearch(QUrl))); + connect(m_searchWindow, SIGNAL(requestShowLink(QUrl)), + CentralWidget::instance(), SLOT(setSourceFromSearch(QUrl))); connect(m_searchWindow, SIGNAL(requestShowLinkInNewTab(QUrl)), - m_centralWidget, SLOT(setSourceFromSearchInNewTab(QUrl))); + OpenPagesManager::instance(), SLOT(createNewPageFromSearch(QUrl))); #if defined(QT_NO_PRINTER) m_pageSetupAction->setVisible(false); @@ -733,20 +691,6 @@ void MainWindow::gotoAddress() m_centralWidget->setSource(m_addressLineEdit->text()); } -void MainWindow::updateNavigationItems() -{ - TRACE_OBJ - m_copyAction->setEnabled(m_centralWidget->hasSelection()); - m_nextAction->setEnabled(m_centralWidget->isForwardAvailable()); - m_backAction->setEnabled(m_centralWidget->isBackwardAvailable()); -} - -void MainWindow::updateTabCloseAction() -{ - TRACE_OBJ - m_closeTabAction->setEnabled(m_centralWidget->enableTabCloseAction()); -} - void MainWindow::showTopicChooser(const QMap &links, const QString &keyword) { @@ -780,12 +724,6 @@ void MainWindow::syncContents() qApp->restoreOverrideCursor(); } -void MainWindow::copyAvailable(bool yes) -{ - TRACE_OBJ - m_copyAction->setEnabled(yes); -} - void MainWindow::showAboutDialog() { TRACE_OBJ @@ -918,6 +856,12 @@ void MainWindow::showSearch() activateDockWidget(m_searchWindow); } +void MainWindow::showOpenPages() +{ + TRACE_OBJ + activateDockWidget(OpenPagesManager::instance()->openPagesWidget()); +} + void MainWindow::hideSearch() { TRACE_OBJ @@ -1071,17 +1015,13 @@ void MainWindow::currentFilterChanged(const QString &filter) void MainWindow::documentationRemoved(const QString &namespaceName) { TRACE_OBJ - CentralWidget* widget = CentralWidget::instance(); - widget->closeOrReloadTabs(widget->currentSourceFileList(). - keys(namespaceName), false); + OpenPagesManager::instance()->closePages(namespaceName); } void MainWindow::documentationUpdated(const QString &namespaceName) { TRACE_OBJ - CentralWidget* widget = CentralWidget::instance(); - widget->closeOrReloadTabs(widget->currentSourceFileList(). - keys(namespaceName), true); + OpenPagesManager::instance()->reloadPages(namespaceName); } void MainWindow::resetQtDocInfo(const QString &component) diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 6ac148e..93cc1ac 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -42,21 +42,23 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include #include #include QT_BEGIN_NAMESPACE class QAction; +class QComboBox; class QFileSystemWatcher; class QLineEdit; -class QComboBox; class QMenu; class CentralWidget; class CmdLineParser; class ContentWindow; class IndexWindow; +class OpenPagesWindow; class QtDocInstaller; class QHelpEngineCore; class QHelpEngine; @@ -96,14 +98,12 @@ private slots: void showContents(); void showIndex(); void showSearch(); + void showOpenPages(); void insertLastPages(); void gotoAddress(); void showPreferences(); void showNewAddress(); void showAboutDialog(); - void copyAvailable(bool yes); - void updateNavigationItems(); - void updateTabCloseAction(); void showNewAddress(const QUrl &url); void showTopicChooser(const QMap &links, const QString &keyword); void updateApplicationFont(); @@ -148,17 +148,9 @@ private: QLineEdit *m_addressLineEdit; QComboBox *m_filterCombo; - QAction *m_backAction; - QAction *m_nextAction; - QAction *m_homeAction; QAction *m_syncAction; - QAction *m_copyAction; - QAction *m_findAction; - QAction *m_printAction; QAction *m_printPreviewAction; QAction *m_pageSetupAction; - QAction *m_zoomInAction; - QAction *m_zoomOutAction; QAction *m_resetZoomAction; QAction *m_aboutAction; QAction *m_closeTabAction; diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp new file mode 100644 index 0000000..cd4460a --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -0,0 +1,308 @@ +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "openpagesmanager.h" + +#include "centralwidget.h" +#include "helpenginewrapper.h" +#include "helpviewer.h" +#include "helpviewer_qtb.h" +#include "helpviewer_qwv.h" +#include "openpagesmodel.h" +#include "openpageswidget.h" +#include "tracer.h" +#include "../shared/collectionconfiguration.h" + +#include + +QT_BEGIN_NAMESPACE + +OpenPagesManager *OpenPagesManager::createInstance(QObject *parent, + bool defaultCollection, const QUrl &cmdLineUrl) +{ + TRACE_OBJ + Q_ASSERT(!m_instance); + m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl); + return m_instance; +} + +OpenPagesManager *OpenPagesManager::instance() +{ + TRACE_OBJ + Q_ASSERT(m_instance); + return m_instance; +} + +OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection, + const QUrl &cmdLineUrl) + : QObject(parent), m_model(new OpenPagesModel(this)), + m_openPagesWidget(new OpenPagesWidget(m_model)) +{ + TRACE_OBJ + connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, + SLOT(setCurrentPage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, + SLOT(closePage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this, + SLOT(closePagesExcept(QModelIndex))); + setupInitialPages(defaultCollection, cmdLineUrl); +} + +int OpenPagesManager::pageCount() const +{ + TRACE_OBJ + return m_model->rowCount(); +} + +void OpenPagesManager::setupInitialPages(bool defaultCollection, + const QUrl &cmdLineUrl) +{ + TRACE_OBJ + if (cmdLineUrl.isValid()) { + createPage(cmdLineUrl); + return; + } + + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + int initialPage = 0; + switch (helpEngine.startOption()) { + case ShowHomePage: + m_model->addPage(helpEngine.homePage()); + break; + case ShowBlankPage: + m_model->addPage(QUrl(QLatin1String("about:blank"))); + break; + case ShowLastPages: { + const QStringList &lastShownPageList = helpEngine.lastShownPages(); + const int pageCount = lastShownPageList.count(); + if (pageCount == 0) { + if (defaultCollection) + m_model->addPage(QUrl(QLatin1String("help"))); + else + m_model->addPage(QUrl(QLatin1String("about:blank"))); + } else { + QStringList zoomFactors = helpEngine.lastZoomFactors(); + while (zoomFactors.count() < pageCount) + zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); + initialPage = helpEngine.lastTabPage(); + if (initialPage >= pageCount) { + qWarning("Initial page set to %d, maximum possible value is %d", + initialPage, pageCount - 1); + initialPage = 0; + } + for (int curPage = 0; curPage < pageCount; ++curPage) { + const QString &curFile = lastShownPageList.at(curPage); + if (helpEngine.findFile(curFile).isValid() + || curFile == QLatin1String("about:blank")) { + m_model->addPage(curFile, zoomFactors.at(curPage).toFloat()); + } else if (curPage <= initialPage && initialPage > 0) + --initialPage; + } + } + break; + } + default: + Q_ASSERT(!"Unhandled option"); + } + + if (m_model->rowCount() == 0) + m_model->addPage(helpEngine.homePage()); + for (int i = 0; i < m_model->rowCount(); ++i) + CentralWidget::instance()->addPage(m_model->pageAt(i)); + setCurrentPage(initialPage); +} + +HelpViewer *OpenPagesManager::createPage() +{ + TRACE_OBJ + return createPage(QUrl(QLatin1String("about:blank"))); +} + +void OpenPagesManager::closeCurrentPage() +{ + TRACE_OBJ + Q_ASSERT(m_model->rowCount() > 1); + const QModelIndexList selectedIndexes + = m_openPagesWidget->selectionModel()->selectedRows(); + if (selectedIndexes.isEmpty()) + return; + Q_ASSERT(selectedIndexes.count() == 1); + removePage(selectedIndexes.first().row()); +} + +HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch) +{ + TRACE_OBJ + if (AbstractHelpViewer::launchWithExternalApp(url)) + return 0; + + m_model->addPage(url); + const int index = m_model->rowCount() - 1; + HelpViewer * const page = m_model->pageAt(index); + CentralWidget::instance()->addPage(page, fromSearch); + setCurrentPage(index); + return page; +} + +HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url) +{ + return createPage(url, true); +} + +void OpenPagesManager::closePage(const QModelIndex &index) +{ + if (index.isValid()) + removePage(index.row()); +} + +void OpenPagesManager::closePages(const QString &nameSpace) +{ + TRACE_OBJ + closeOrReloadPages(nameSpace, false); +} + +void OpenPagesManager::reloadPages(const QString &nameSpace) +{ + TRACE_OBJ + closeOrReloadPages(nameSpace, true); + selectCurrentPage(); +} + +void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload) +{ + TRACE_OBJ + + for (int i = m_model->rowCount() - 1; i >= 0; --i) { + HelpViewer *page = m_model->pageAt(i); + if (page->source().host() != nameSpace) + continue; + if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid()) + page->reload(); + else if (m_model->rowCount() == 1) + page->setSource(QUrl(QLatin1String("about:blank"))); + else + removePage(i); + } +} + +bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const +{ + TRACE_OBJ + for (int i = 0; i < m_model->rowCount(); ++i) + if (m_model->pageAt(i)->source().host() == nameSpace) + return true; + return false; +} + +void OpenPagesManager::setCurrentPage(const QModelIndex &index) +{ + TRACE_OBJ + if (!index.isValid()) + return; + HelpViewer * const page = m_model->pageAt(index.row()); + CentralWidget::instance()->setCurrentPage(page); +} + +void OpenPagesManager::setCurrentPage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->setCurrentPage(m_model->pageAt(index)); + selectCurrentPage(); +} + +void OpenPagesManager::selectCurrentPage() +{ + TRACE_OBJ + QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel(); + selModel->clearSelection(); + selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0), + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex()); +} + +void OpenPagesManager::removePage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->removePage(index); + m_model->removePage(index); + selectCurrentPage(); +} + + +void OpenPagesManager::closePagesExcept(const QModelIndex &index) +{ + TRACE_OBJ + if (!index.isValid()) + return; + + int i = 0; + HelpViewer *viewer = m_model->pageAt(index.row()); + while (m_model->rowCount() > 1) { + if (m_model->pageAt(i) != viewer) + removePage(i); + else + ++i; + } +} + +QWidget *OpenPagesManager::openPagesWidget() const +{ + return m_openPagesWidget; +} + +void OpenPagesManager::nextPage() +{ + nextOrPreviousPage(1); +} + +void OpenPagesManager::previousPage() +{ + nextOrPreviousPage(-1); +} + +void OpenPagesManager::nextOrPreviousPage(int offset) +{ + setCurrentPage((CentralWidget::instance()->currentIndex() + offset + + m_model->rowCount()) % m_model->rowCount()); +} + +OpenPagesManager *OpenPagesManager::m_instance = 0; + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h new file mode 100644 index 0000000..95bf247 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESMANAGER_H +#define OPENPAGESMANAGER_H + +#include + +QT_BEGIN_NAMESPACE + +class QModelIndex; +class QUrl; +class QWidget; + +class HelpViewer; +class OpenPagesModel; +class OpenPagesWidget; + +class OpenPagesManager : public QObject + { + Q_OBJECT + public: + static OpenPagesManager *createInstance(QObject *parent, + bool defaultCollection, const QUrl &cmdLineUrl); + static OpenPagesManager *instance(); + + bool pagesOpenForNamespace(const QString &nameSpace) const; + void closePages(const QString &nameSpace); + void reloadPages(const QString &nameSpace); + + QWidget* openPagesWidget() const; + + int pageCount() const; + + public slots: + HelpViewer *createPage(const QUrl &url, bool fromSearch = false); + HelpViewer *createNewPageFromSearch(const QUrl &url); + HelpViewer *createPage(); + void closeCurrentPage(); + void nextPage(); + void previousPage(); + +private slots: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); + +private: + OpenPagesManager(QObject *parent, bool defaultCollection, + const QUrl &cmdLineUrl); + void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); + void closeOrReloadPages(const QString &nameSpace, bool tryReload); + void setCurrentPage(int index); + void selectCurrentPage(); + void removePage(int index); + void nextOrPreviousPage(int offset); + + OpenPagesModel *m_model; + OpenPagesWidget *m_openPagesWidget; + + static OpenPagesManager *m_instance; + }; + +QT_END_NAMESPACE + +#endif // OPENPAGESMANAGER_H diff --git a/tools/assistant/tools/assistant/openpagesmodel.cpp b/tools/assistant/tools/assistant/openpagesmodel.cpp new file mode 100644 index 0000000..9e31b84 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmodel.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "openpagesmodel.h" + +#include "helpenginewrapper.h" +#include "helpviewer_qtb.h" +#include "helpviewer_qwv.h" +#include "tracer.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +OpenPagesModel::OpenPagesModel(QObject *parent) : QAbstractTableModel(parent) +{ + TRACE_OBJ +} + +int OpenPagesModel::rowCount(const QModelIndex &parent) const +{ + TRACE_OBJ + return parent.isValid() ? 0 : m_pages.count(); +} + +int OpenPagesModel::columnCount(const QModelIndex &/*parent*/) const +{ + TRACE_OBJ + return 2; +} + +QVariant OpenPagesModel::data(const QModelIndex &index, int role) const +{ + TRACE_OBJ + if (!index.isValid() || index.row() >= rowCount() || index.column() > 0 + || role != Qt::DisplayRole) + return QVariant(); + QString title = m_pages.at(index.row())->documentTitle(); + title.replace(QLatin1Char('&'), QLatin1String("&&")); + return title.isEmpty() ? QLatin1String("(Untitled)") : title; +} + +void OpenPagesModel::addPage(const QUrl &url, qreal zoom) +{ + TRACE_OBJ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + HelpViewer *page = new HelpViewer(zoom); + connect(page, SIGNAL(titleChanged()), this, SLOT(handleTitleChanged())); + m_pages << page; + endInsertRows(); + page->setSource(url); +} + +void OpenPagesModel::removePage(int index) +{ + TRACE_OBJ + Q_ASSERT(index >= 0 && index < rowCount()); + beginRemoveRows(QModelIndex(), index, index); + HelpViewer *page = m_pages.at(index); + m_pages.removeAt(index); + endRemoveRows(); + page->deleteLater(); +} + +HelpViewer *OpenPagesModel::pageAt(int index) const +{ + TRACE_OBJ + Q_ASSERT(index >= 0 && index < rowCount()); + return m_pages.at(index); +} + +void OpenPagesModel::handleTitleChanged() +{ + TRACE_OBJ + HelpViewer *page = static_cast(sender()); + const int row = m_pages.indexOf(page); + Q_ASSERT(row != -1 ); + const QModelIndex &item = index(row, 0); + emit dataChanged(item, item); +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesmodel.h b/tools/assistant/tools/assistant/openpagesmodel.h new file mode 100644 index 0000000..64013a6 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesmodel.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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESMODEL_H +#define OPENPAGESMODEL_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class HelpViewer; +class QUrl; + +class OpenPagesModel : public QAbstractTableModel +{ + Q_OBJECT +public: + OpenPagesModel(QObject *parent); + + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + void addPage(const QUrl &url, qreal zoom = 0); + void removePage(int index); + HelpViewer *pageAt(int index) const; + +private slots: + void handleTitleChanged(); + +private: + QList m_pages; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESMODEL_H diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp new file mode 100644 index 0000000..648ead8 --- /dev/null +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -0,0 +1,181 @@ +/************************************************************************** +** +** This file is part of the Assistant module of the Qt toolkit. +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "openpageswidget.h" + +#include "openpagesmodel.h" + +#include +#include +#include +#include +#include +#include + +#ifdef Q_WS_MAC +#include +#endif + +QT_BEGIN_NAMESPACE + +OpenPagesDelegate::OpenPagesDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ +} + +void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + if (option.state & QStyle::State_MouseOver) { + if ((QApplication::mouseButtons() & Qt::LeftButton) == 0) + pressedIndex = QModelIndex(); + QBrush brush = option.palette.alternateBase(); + if (index == pressedIndex) + brush = option.palette.dark(); + painter->fillRect(option.rect, brush); + } + + QStyledItemDelegate::paint(painter, option, index); + + if (index.column() == 1 && option.state & QStyle::State_MouseOver) { + QIcon icon((option.state & QStyle::State_Selected) + ? ":/trolltech/assistant/images/closebutton.png" + : ":/trolltech/assistant/images/darkclosebutton.png"); + + const QRect iconRect(option.rect.right() - option.rect.height(), + option.rect.top(), option.rect.height(), option.rect.height()); + icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter); + } +} + + +OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) +{ + setModel(model); + setIndentation(0); + setItemDelegate((m_delegate = new OpenPagesDelegate(this))); + + setFrameStyle(QFrame::NoFrame); + setTextElideMode(Qt::ElideMiddle); + setAttribute(Qt::WA_MacShowFocusRect, false); + + viewport()->setAttribute(Qt::WA_Hover); + setSelectionBehavior(QAbstractItemView::SelectRows); + setSelectionMode(QAbstractItemView::SingleSelection); + + header()->hide(); + header()->setStretchLastSection(false); + header()->setResizeMode(0, QHeaderView::Stretch); + header()->setResizeMode(1, QHeaderView::Fixed); + header()->resizeSection(1, 18); + + installEventFilter(this); + setUniformRowHeights(true); + setContextMenuPolicy(Qt::CustomContextMenu); + + connect(this, SIGNAL(clicked(QModelIndex)), this, + SLOT(handleClicked(QModelIndex))); + connect(this, SIGNAL(pressed(QModelIndex)), this, + SLOT(handlePressed(QModelIndex))); + connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(contextMenuRequested(QPoint))); +} + +OpenPagesWidget::~OpenPagesWidget() +{ +} + +void OpenPagesWidget::contextMenuRequested(QPoint pos) +{ + const QModelIndex &index = indexAt(pos); + if (!index.isValid()) + return; + + QMenu contextMenu; + QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data() + .toString())); + QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1") + .arg(index.data().toString())); + + if (model()->rowCount() == 1) { + closeEditor->setEnabled(false); + closeOtherEditors->setEnabled(false); + } + + QAction *action = contextMenu.exec(mapToGlobal(pos)); + if (action == closeEditor) + emit closePage(index); + else if (action == closeOtherEditors) + emit closePagesExcept(index); +} + +void OpenPagesWidget::handlePressed(const QModelIndex &index) +{ + if (index.column() == 0) + emit setCurrentPage(index); + + if (index.column() == 1) + m_delegate->pressedIndex = index; +} + +void OpenPagesWidget::handleClicked(const QModelIndex &index) +{ + // implemented here to handle the funky close button and to work around a + // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver + if (index.column() == 1) { + if (model()->rowCount() > 1) + emit closePage(index); + + QWidget *vp = viewport(); + const QPoint &cursorPos = QCursor::pos(); + QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, + Qt::NoButton, 0, 0); + QCoreApplication::sendEvent(vp, &e); + } +} + +bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == this && event->type() == QEvent::KeyPress) { + if (currentIndex().isValid()) { + QKeyEvent *ke = static_cast(event); + const int key = ke->key(); + if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) + && ke->modifiers() == 0) { + emit setCurrentPage(currentIndex()); + } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace) + && ke->modifiers() == 0 && model()->rowCount() > 1) { + emit closePage(currentIndex()); + } + } + } + return QWidget::eventFilter(obj, event); +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h new file mode 100644 index 0000000..5b35321 --- /dev/null +++ b/tools/assistant/tools/assistant/openpageswidget.h @@ -0,0 +1,76 @@ +/************************************************************************** +** +** This file is part of the Assistant module of the Qt toolkit. +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef OPENPAGESWIDGET_H +#define OPENPAGESWIDGET_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class OpenPagesModel; + +class OpenPagesDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + explicit OpenPagesDelegate(QObject *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + mutable QModelIndex pressedIndex; +}; + +class OpenPagesWidget : public QTreeView +{ + Q_OBJECT +public: + OpenPagesWidget(OpenPagesModel *model); + ~OpenPagesWidget(); + +signals: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); + +private slots: + void contextMenuRequested(QPoint pos); + void handlePressed(const QModelIndex &index); + void handleClicked(const QModelIndex &index); + +private: + bool eventFilter(QObject *obj, QEvent *event); + + OpenPagesDelegate *m_delegate; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESWIDGET_H diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 0e1d719..3535e5a 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -45,6 +45,7 @@ #include "fontpanel.h" #include "helpenginewrapper.h" #include "installdialog.h" +#include "openpagesmanager.h" #include "tracer.h" #include @@ -302,15 +303,12 @@ void PreferencesDialog::addDocumentationLocal() void PreferencesDialog::removeDocumentation() { TRACE_OBJ - bool foundBefore = false; - CentralWidget* widget = CentralWidget::instance(); - QMap openedDocList = widget->currentSourceFileList(); - QStringList values(openedDocList.values()); + bool foundBefore = false; QList l = m_ui.registeredDocsListWidget->selectedItems(); foreach (QListWidgetItem* item, l) { const QString& ns = item->text(); - if (!foundBefore && values.contains(ns)) { + if (!foundBefore && OpenPagesManager::instance()->pagesOpenForNamespace(ns)) { if (0 == QMessageBox::information(this, tr("Remove Documentation"), tr("Some documents currently opened in Assistant reference the " "documentation you are attempting to remove. Removing the " @@ -320,7 +318,6 @@ void PreferencesDialog::removeDocumentation() } m_unregDocs.append(ns); - m_TabsToClose += openedDocList.keys(ns); delete m_ui.registeredDocsListWidget->takeItem( m_ui.registeredDocsListWidget->row(item)); } @@ -374,10 +371,10 @@ void PreferencesDialog::applyChanges() } } - CentralWidget::instance()->closeOrReloadTabs(m_TabsToClose, false); - - foreach (const QString &doc, m_unregDocs) + foreach (const QString &doc, m_unregDocs) { + OpenPagesManager::instance()->closePages(doc); helpEngine.unregisterDocumentation(doc); + } if (filtersWereChanged || !m_regDocs.isEmpty() || !m_unregDocs.isEmpty()) helpEngine.setupData(); diff --git a/tools/assistant/tools/assistant/preferencesdialog.h b/tools/assistant/tools/assistant/preferencesdialog.h index 2894494..7a17275 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.h +++ b/tools/assistant/tools/assistant/preferencesdialog.h @@ -96,7 +96,6 @@ private: QStringList m_docsBackup; QStringList m_regDocs; QStringList m_unregDocs; - QList m_TabsToClose; FontPanel *m_appFontPanel; FontPanel *m_browserFontPanel; bool m_appFontChanged; diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index 5ecdd69..06e5602 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -38,12 +38,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" - #include "remotecontrol.h" -#include "mainwindow.h" + #include "centralwidget.h" #include "helpenginewrapper.h" +#include "mainwindow.h" +#include "openpagesmanager.h" +#include "tracer.h" #include #include @@ -323,8 +324,7 @@ void RemoteControl::handleUnregisterCommand(const QString &arg) const QString &absFileName = QFileInfo(arg).absoluteFilePath(); const QString &ns = QHelpEngineCore::namespaceName(absFileName); if (helpEngine.registeredDocumentations().contains(ns)) { - CentralWidget* widget = CentralWidget::instance(); - widget->closeOrReloadTabs(widget->currentSourceFileList().keys(ns), false); + OpenPagesManager::instance()->closePages(ns); if (helpEngine.unregisterDocumentation(ns)) helpEngine.setupData(); } -- 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 dd5d297d2969795a47ef7a5234b64a791e080c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 20 Apr 2010 14:01:06 +0200 Subject: Made sure that QTabWidget reported a big enough size hint. This avoids some minor clipping issues observed (see autotest). Reviewed-by: MortenS --- src/gui/styles/qmacstyle_mac.mm | 51 ++++++++++++++++++++++++++++++++ src/gui/widgets/qtabwidget.cpp | 8 ++--- tests/auto/qtabwidget/tst_qtabwidget.cpp | 24 +++++++++++++++ 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 116b03e..fe87b80 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -5614,6 +5614,57 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, // hack to work around horrible sizeHint() code in QAbstractSpinBox sz.setHeight(sz.height() - 3); break; + case QStyle::CT_TabWidget: + // the size between the pane and the "contentsRect" (+4,+4) + // (the "contentsRect" is on the inside of the pane) + sz = QWindowsStyle::sizeFromContents(ct, opt, csz, widget); + /** + This is supposed to show the relationship between the tabBar and + the stack widget of a QTabWidget. + Unfortunately ascii is not a good way of representing graphics..... + PS: The '=' line is the painted frame. + + top ---+ + | + | + | + | vvv just outside the painted frame is the "pane" + - -|- - - - - - - - - - <-+ + TAB BAR +=====^============ | +2 pixels + - - -|- - -|- - - - - - - <-+ + | | ^ ^^^ just inside the painted frame is the "contentsRect" + | | | + | overlap | + | | | + bottom ------+ <-+ +14 pixels + | + v + ------------------------------ <- top of stack widget + + + To summarize: + * 2 is the distance between the pane and the contentsRect + * The 14 and the 1's are the distance from the contentsRect to the stack widget. + (same value as used in SE_TabWidgetTabContents) + * overlap is how much the pane should overlap the tab bar + */ + // then add the size between the stackwidget and the "contentsRect" + + if (const QStyleOptionTabWidgetFrame *twf + = qstyleoption_cast(opt)) { + QSize extra(0,0); + const int overlap = pixelMetric(PM_TabBarBaseOverlap, opt, widget); + const int gapBetweenTabbarAndStackWidget = 2 + 14 - overlap; + + if (getTabDirection(twf->shape) == kThemeTabNorth || getTabDirection(twf->shape) == kThemeTabSouth) { + extra = QSize(2, gapBetweenTabbarAndStackWidget + 1); + } else { + extra = QSize(gapBetweenTabbarAndStackWidget + 1, 2); + } + sz+= extra; + } + + break; case QStyle::CT_TabBarTab: if (const QStyleOptionTabV3 *tab = qstyleoption_cast(opt)) { const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget); diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 047a905..583c112 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -814,8 +814,8 @@ QSize QTabWidget::sizeHint() const { Q_D(const QTabWidget); QSize lc(0, 0), rc(0, 0); - QStyleOption opt(0); - opt.init(this); + QStyleOptionTabWidgetFrameV2 opt; + initStyleOption(&opt); opt.state = QStyle::State_None; if (d->leftCornerWidget) @@ -863,8 +863,8 @@ QSize QTabWidget::minimumSizeHint() const QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t); - QStyleOption opt(0); - opt.rect = rect(); + QStyleOptionTabWidgetFrameV2 opt; + initStyleOption(&opt); opt.palette = palette(); opt.state = QStyle::State_None; return style()->sizeFromContents(QStyle::CT_TabWidget, &opt, sz, this) diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp index 4491fb3..6d5a873 100644 --- a/tests/auto/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include //TESTED_CLASS= //TESTED_FILES= @@ -120,6 +121,7 @@ class tst_QTabWidget:public QObject { void clear(); void keyboardNavigation(); void paintEventCount(); + void minimumSizeHint(); private: int addPage(); @@ -621,6 +623,28 @@ void tst_QTabWidget::paintEventCount() QCOMPARE(tab2->count, 1); } +void tst_QTabWidget::minimumSizeHint() +{ + QTabWidget tw; + QWidget *page = new QWidget; + QVBoxLayout *lay = new QVBoxLayout; + + QLabel *label = new QLabel(QLatin1String("XXgypq lorem ipsum must be long, must be long. lorem ipsumMMMW")); + lay->addWidget(label); + + page->setLayout(lay); + + tw.addTab(page, QLatin1String("page1")); + + tw.show(); + QTest::qWaitForWindowShown(&tw); + tw.resize(tw.minimumSizeHint()); + + QSize minSize = label->minimumSizeHint(); + QSize actSize = label->geometry().size(); + QVERIFY(minSize.width() <= actSize.width()); + QVERIFY(minSize.height() <= actSize.height()); +} QTEST_MAIN(tst_QTabWidget) #include "tst_qtabwidget.moc" -- cgit v0.12 From eb7fad0afd164bb9b56ed47990eaa66cad0c2641 Mon Sep 17 00:00:00 2001 From: Markus Hossner Date: Wed, 21 Apr 2010 10:56:22 +0200 Subject: QAbstractGraphicsShapeItem: ignore already set pen or brush MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If setPen() or setBrush() of a QAbstractGraphicsShapeItem is called with a pen or brush equal to its current pen or brush prepareGeometryChange() and update() shouldn't be called. Testing for identical pen and brush is cheap in comparison with a QGraphicsView update() without seeing a change Merge-request: 562 Reviewed-by: Bjørn Erik Nilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 5735cd6..c19c052 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7694,6 +7694,8 @@ QPen QAbstractGraphicsShapeItem::pen() const void QAbstractGraphicsShapeItem::setPen(const QPen &pen) { Q_D(QAbstractGraphicsShapeItem); + if (d->pen == pen) + return; prepareGeometryChange(); d->pen = pen; d->boundingRect = QRectF(); @@ -7724,6 +7726,8 @@ QBrush QAbstractGraphicsShapeItem::brush() const void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush) { Q_D(QAbstractGraphicsShapeItem); + if (d->brush == brush) + return; d->brush = brush; update(); } @@ -8854,6 +8858,8 @@ QPen QGraphicsLineItem::pen() const void QGraphicsLineItem::setPen(const QPen &pen) { Q_D(QGraphicsLineItem); + if (d->pen == pen) + return; prepareGeometryChange(); d->pen = pen; update(); -- cgit v0.12 From 3d402524355bbcc7a5fc9114834436879b7b19ac Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 21 Apr 2010 13:29:21 +0200 Subject: QSettings: Fix isWritable incorrectly returning true on linux. When the target directory exists and is readable, QConfFile::isWritable used to returned true, even though the actual config file was not necessarily writable. Reviewed-by: joerg --- src/corelib/io/qsettings.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 64015ce..9562f58 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -252,9 +252,7 @@ bool QConfFile::isWritable() const } else { // Create the directories to the file. QDir dir(fileInfo.absolutePath()); - if (dir.exists() && dir.isReadable()) { - return true; - } else { + if (!dir.exists()) { if (!dir.mkpath(dir.absolutePath())) return false; } -- 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 64284216cf9bbda4b8bbac9f19852d4c12a2bb97 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 22 Apr 2010 16:24:42 +1000 Subject: Long live Qt 4.8! --- dist/changes-4.8.0 | 130 +++++++++++++++++++++ src/corelib/global/qglobal.h | 4 +- src/plugins/qpluginbase.pri | 2 +- src/qbase.pri | 2 +- tests/auto/selftests/expected_cmptest.txt | 2 +- tests/auto/selftests/expected_crashes_3.txt | 2 +- tests/auto/selftests/expected_longstring.txt | 2 +- tests/auto/selftests/expected_maxwarnings.txt | 2 +- tests/auto/selftests/expected_skip.txt | 2 +- .../tools/assistant/doc/assistant.qdocconf | 2 +- tools/qdoc3/doc/qdoc-manual.qdocconf | 2 +- tools/qdoc3/test/assistant.qdocconf | 6 +- tools/qdoc3/test/designer.qdocconf | 4 +- tools/qdoc3/test/linguist.qdocconf | 6 +- tools/qdoc3/test/qmake.qdocconf | 6 +- tools/qdoc3/test/qt-build-docs.qdocconf | 10 +- tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf | 10 +- tools/qdoc3/test/qt-html-templates.qdocconf | 2 +- tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf | 8 +- tools/qdoc3/test/qt.qdocconf | 10 +- tools/qdoc3/test/qt_zh_CN.qdocconf | 10 +- 21 files changed, 177 insertions(+), 47 deletions(-) create mode 100644 dist/changes-4.8.0 diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 new file mode 100644 index 0000000..39ea604 --- /dev/null +++ b/dist/changes-4.8.0 @@ -0,0 +1,130 @@ +Qt 4.8 introduces many new features and improvements as well as bugfixes +over the 4.7.x series. For more details, refer to the online documentation +included in this distribution. The documentation is also available online: + + http://qt.nokia.com/doc/4.8 + +The Qt version 4.8 series is binary compatible with the 4.7.x series. +Applications compiled for 4.7 will continue to run with 4.8. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + + http://bugreports.qt.nokia.com/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + +- + +Third party components +---------------------- + + - Updated libpng to version x.y.z + + +**************************************************************************** +* Library * +**************************************************************************** + +QtCore +------ + +QtGui +----- + + +**************************************************************************** +* Database Drivers * +**************************************************************************** + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Qt for Linux/X11 +---------------- + + +Qt for Windows +-------------- + + +Qt for Mac OS X +--------------- + + +Qt for Embedded Linux +--------------------- + + +Qt for Windows CE +----------------- + + +**************************************************************************** +* Compiler Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Tools * +**************************************************************************** + +- Build System + +- Assistant + + +- Designer + + +- Linguist + - Linguist GUI + + - lupdate + + - lrelease + + +- rcc + + +- moc + + +- uic + + +- uic3 + + +- qmake + + +- configure + + +- qtconfig + + +- qt3to4 + + +**************************************************************************** +* Plugins * +**************************************************************************** + + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 3118f8f..7359b6d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -44,11 +44,11 @@ #include -#define QT_VERSION_STR "4.7.0" +#define QT_VERSION_STR "4.8.0" /* QT_VERSION is (major << 16) + (minor << 8) + patch. */ -#define QT_VERSION 0x040700 +#define QT_VERSION 0x040800 /* can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) */ diff --git a/src/plugins/qpluginbase.pri b/src/plugins/qpluginbase.pri index 8b119b5..45e3976 100644 --- a/src/plugins/qpluginbase.pri +++ b/src/plugins/qpluginbase.pri @@ -1,6 +1,6 @@ TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.7.0 + VERSION=4.8.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/src/qbase.pri b/src/qbase.pri index 4a75565..9c4732e 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -4,7 +4,7 @@ INCLUDEPATH *= $$QMAKE_INCDIR_QT/$$TARGET #just for today to have some compat isEmpty(QT_ARCH):!isEmpty(ARCH):QT_ARCH=$$ARCH #another compat that will rot for change #215700 TEMPLATE = lib isEmpty(QT_MAJOR_VERSION) { - VERSION=4.7.0 + VERSION=4.8.0 } else { VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} } diff --git a/tests/auto/selftests/expected_cmptest.txt b/tests/auto/selftests/expected_cmptest.txt index e9f94c9..f4baf67 100644 --- a/tests/auto/selftests/expected_cmptest.txt +++ b/tests/auto/selftests/expected_cmptest.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_Cmptest ********* -Config: Using QTest library 4.7.0, Qt 4.7.0 +Config: Using QTest library 4.8.0, Qt 4.8.0 PASS : tst_Cmptest::initTestCase() PASS : tst_Cmptest::compare_boolfuncs() PASS : tst_Cmptest::compare_pointerfuncs() diff --git a/tests/auto/selftests/expected_crashes_3.txt b/tests/auto/selftests/expected_crashes_3.txt index 3aced25..b7f462a 100644 --- a/tests/auto/selftests/expected_crashes_3.txt +++ b/tests/auto/selftests/expected_crashes_3.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_Crashes ********* -Config: Using QTest library 4.7.0, Qt 4.7.0 +Config: Using QTest library 4.8.0, Qt 4.8.0 PASS : tst_Crashes::initTestCase() QFATAL : tst_Crashes::crash() Received signal 11 FAIL! : tst_Crashes::crash() Received a fatal error. diff --git a/tests/auto/selftests/expected_longstring.txt b/tests/auto/selftests/expected_longstring.txt index a6ad5d0..6cb6267 100644 --- a/tests/auto/selftests/expected_longstring.txt +++ b/tests/auto/selftests/expected_longstring.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_LongString ********* -Config: Using QTest library 4.7.0, Qt 4.7.0 +Config: Using QTest library 4.8.0, Qt 4.8.0 PASS : tst_LongString::initTestCase() FAIL! : tst_LongString::failWithLongString() Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. diff --git a/tests/auto/selftests/expected_maxwarnings.txt b/tests/auto/selftests/expected_maxwarnings.txt index 908bd5d..165bdda 100644 --- a/tests/auto/selftests/expected_maxwarnings.txt +++ b/tests/auto/selftests/expected_maxwarnings.txt @@ -1,5 +1,5 @@ ********* Start testing of MaxWarnings ********* -Config: Using QTest library 4.7.0, Qt 4.7.0 +Config: Using QTest library 4.8.0, Qt 4.8.0 PASS : MaxWarnings::initTestCase() QWARN : MaxWarnings::warn() 0 QWARN : MaxWarnings::warn() 1 diff --git a/tests/auto/selftests/expected_skip.txt b/tests/auto/selftests/expected_skip.txt index 4345a6c..9908c88 100644 --- a/tests/auto/selftests/expected_skip.txt +++ b/tests/auto/selftests/expected_skip.txt @@ -1,5 +1,5 @@ ********* Start testing of tst_Skip ********* -Config: Using QTest library 4.7.0, Qt 4.7.0 +Config: Using QTest library 4.8.0, Qt 4.8.0 PASS : tst_Skip::initTestCase() SKIP : tst_Skip::test() skipping all Loc: [/home/rmcgover/depot/qt-git/mainline/tests/auto/selftests/skip/tst_skip.cpp(68)] diff --git a/tools/assistant/tools/assistant/doc/assistant.qdocconf b/tools/assistant/tools/assistant/doc/assistant.qdocconf index 3b4b5f8..491f159 100644 --- a/tools/assistant/tools/assistant/doc/assistant.qdocconf +++ b/tools/assistant/tools/assistant/doc/assistant.qdocconf @@ -12,5 +12,5 @@ HTML.footer = "


\n" \ "\n" \ "\n" \ "\n" \ - "\n" \ + "\n" \ "
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)Trademarks
Qt 4.7.0
Qt 4.8.0
" diff --git a/tools/qdoc3/doc/qdoc-manual.qdocconf b/tools/qdoc3/doc/qdoc-manual.qdocconf index 26fd09c..5a725b9 100644 --- a/tools/qdoc3/doc/qdoc-manual.qdocconf +++ b/tools/qdoc3/doc/qdoc-manual.qdocconf @@ -32,7 +32,7 @@ HTML.postheader = "" \ "" \ "Home: QDoc Manual ·" \ - "" \ + "" \ " Qt Reference Documentation" \ "\n" \ "
" diff --git a/tools/qdoc3/test/assistant.qdocconf b/tools/qdoc3/test/assistant.qdocconf index 5308afd..42d2193 100644 --- a/tools/qdoc3/test/assistant.qdocconf +++ b/tools/qdoc3/test/assistant.qdocconf @@ -6,18 +6,18 @@ include(qt-defines.qdocconf) project = Qt Assistant description = Qt Assistant Manual -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Assistant qhp.Assistant.file = assistant.qhp -qhp.Assistant.namespace = com.trolltech.assistant.470 +qhp.Assistant.namespace = com.trolltech.assistant.480 qhp.Assistant.virtualFolder = qdoc qhp.Assistant.indexTitle = Qt Assistant Manual qhp.Assistant.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png -qhp.Assistant.filterAttributes = qt 4.7.0 tools assistant +qhp.Assistant.filterAttributes = qt 4.8.0 tools assistant qhp.Assistant.customFilters.Assistant.name = Qt Assistant Manual qhp.Assistant.customFilters.Assistant.filterAttributes = qt tools assistant qhp.Assistant.subprojects = manual examples diff --git a/tools/qdoc3/test/designer.qdocconf b/tools/qdoc3/test/designer.qdocconf index 2eb3d96..cf85e58 100644 --- a/tools/qdoc3/test/designer.qdocconf +++ b/tools/qdoc3/test/designer.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt Designer description = Qt Designer Manual -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index @@ -17,7 +17,7 @@ qhp.Designer.namespace = com.trolltech.designer.470 qhp.Designer.virtualFolder = qdoc qhp.Designer.indexTitle = Qt Designer Manual qhp.Designer.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png -qhp.Designer.filterAttributes = qt 4.7.0 tools designer +qhp.Designer.filterAttributes = qt 4.8.0 tools designer qhp.Designer.customFilters.Designer.name = Qt Designer Manual qhp.Designer.customFilters.Designer.filterAttributes = qt tools designer qhp.Designer.subprojects = manual examples diff --git a/tools/qdoc3/test/linguist.qdocconf b/tools/qdoc3/test/linguist.qdocconf index ac536be..697ae6f 100644 --- a/tools/qdoc3/test/linguist.qdocconf +++ b/tools/qdoc3/test/linguist.qdocconf @@ -6,18 +6,18 @@ include(qt-defines.qdocconf) project = Qt Linguist description = Qt Linguist Manual -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Linguist qhp.Linguist.file = linguist.qhp -qhp.Linguist.namespace = com.trolltech.linguist.470 +qhp.Linguist.namespace = com.trolltech.linguist.480 qhp.Linguist.virtualFolder = qdoc qhp.Linguist.indexTitle = Qt Linguist Manual qhp.Linguist.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png -qhp.Linguist.filterAttributes = qt 4.7.0 tools linguist +qhp.Linguist.filterAttributes = qt 4.8.0 tools linguist qhp.Linguist.customFilters.Linguist.name = Qt Linguist Manual qhp.Linguist.customFilters.Linguist.filterAttributes = qt tools linguist qhp.Linguist.subprojects = manual examples diff --git a/tools/qdoc3/test/qmake.qdocconf b/tools/qdoc3/test/qmake.qdocconf index bd47028..af1b13d 100644 --- a/tools/qdoc3/test/qmake.qdocconf +++ b/tools/qdoc3/test/qmake.qdocconf @@ -6,18 +6,18 @@ include(qt-defines.qdocconf) project = QMake description = QMake Manual -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = qmake qhp.qmake.file = qmake.qhp -qhp.qmake.namespace = com.trolltech.qmake.470 +qhp.qmake.namespace = com.trolltech.qmake.480 qhp.qmake.virtualFolder = qdoc qhp.qmake.indexTitle = QMake Manual qhp.qmake.extraFiles = classic.css images/qt-logo.png images/trolltech-logo.png -qhp.qmake.filterAttributes = qt 4.7.0 tools qmake +qhp.qmake.filterAttributes = qt 4.8.0 tools qmake qhp.qmake.customFilters.qmake.name = qmake Manual qhp.qmake.customFilters.qmake.filterAttributes = qt tools qmake qhp.qmake.subprojects = manual diff --git a/tools/qdoc3/test/qt-build-docs.qdocconf b/tools/qdoc3/test/qt-build-docs.qdocconf index dbff4e2..24db29f 100644 --- a/tools/qdoc3/test/qt-build-docs.qdocconf +++ b/tools/qdoc3/test/qt-build-docs.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt description = Qt Reference Documentation -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 sourceencoding = UTF-8 outputencoding = UTF-8 @@ -15,7 +15,7 @@ naturallanguage = en_US qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.470 +qhp.Qt.namespace = com.trolltech.qt.480 qhp.Qt.virtualFolder = qdoc qhp.Qt.indexTitle = Qt Reference Documentation @@ -57,9 +57,9 @@ qhp.Qt.extraFiles = index.html \ images/stylesheet-coffee-plastique.png -qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc -qhp.Qt.customFilters.Qt.name = Qt 4.7.0 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 +qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc +qhp.Qt.customFilters.Qt.name = Qt 4.8.0 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0 qhp.Qt.subprojects = classes overviews examples qhp.Qt.subprojects.classes.title = Classes qhp.Qt.subprojects.classes.indexTitle = Qt's Classes diff --git a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf index 461c069..73ca4ac 100644 --- a/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf @@ -6,7 +6,7 @@ include(qt-defines.qdocconf) project = Qt description = Qt Reference Documentation -url = http://qt.nokia.com/doc/zh_CN/4.7 +url = http://qt.nokia.com/doc/zh_CN/4.8 sourceencoding = UTF-8 outputencoding = UTF-8 @@ -17,15 +17,15 @@ indexes = $QT_BUILD_TREE/doc-build/html-qt/qt.index qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.470 +qhp.Qt.namespace = com.trolltech.qt.480 qhp.Qt.virtualFolder = qdoc qhp.Qt.title = 教程 qhp.Qt.indexTitle = 教程 qhp.Qt.selectors = fake:example -qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc zh_CN -qhp.Qt.customFilters.Qt.name = Qt 4.7.0 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 +qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc zh_CN +qhp.Qt.customFilters.Qt.name = Qt 4.8.0 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 67a25f3..215fdf8 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -16,7 +16,7 @@ HTML.postheader = "
\n" \ "
\n" \ "
\n" \ " \n" \ diff --git a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf index 5fb68cf..94ac431 100644 --- a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf @@ -6,13 +6,13 @@ HTML.postheader = "\n" \ "" \ "" \ "
  " \ - "" \ + "" \ "主页 ·" \ - " " \ + " " \ "所有类 ·" \ - " " \ + " " \ "所有函数 ·" \ - " " \ + " " \ "简介" \ "
" diff --git a/tools/qdoc3/test/qt.qdocconf b/tools/qdoc3/test/qt.qdocconf index cc3e436..3bb03b9 100644 --- a/tools/qdoc3/test/qt.qdocconf +++ b/tools/qdoc3/test/qt.qdocconf @@ -8,7 +8,7 @@ project = Qt versionsym = version = %VERSION% description = Qt Reference Documentation -url = http://qt.nokia.com/doc/4.7 +url = http://qt.nokia.com/doc/4.8 sourceencoding = UTF-8 outputencoding = UTF-8 @@ -17,7 +17,7 @@ naturallanguage = en_US qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.470 +qhp.Qt.namespace = com.trolltech.qt.480 qhp.Qt.virtualFolder = qdoc qhp.Qt.indexTitle = Qt Reference Documentation qhp.Qt.indexRoot = @@ -59,9 +59,9 @@ qhp.Qt.extraFiles = index.html \ images/dynamiclayouts-example.png \ images/stylesheet-coffee-plastique.png -qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc -qhp.Qt.customFilters.Qt.name = Qt 4.7.0 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 +qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc +qhp.Qt.customFilters.Qt.name = Qt 4.8.0 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0 qhp.Qt.subprojects = classes overviews examples qhp.Qt.subprojects.classes.title = Classes qhp.Qt.subprojects.classes.indexTitle = Qt's Classes diff --git a/tools/qdoc3/test/qt_zh_CN.qdocconf b/tools/qdoc3/test/qt_zh_CN.qdocconf index c5d2c88..45a945e 100644 --- a/tools/qdoc3/test/qt_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt_zh_CN.qdocconf @@ -8,7 +8,7 @@ project = Qt versionsym = version = %VERSION% description = Qt Reference Documentation -url = http://qt.nokia.com/doc/zh_CN/4.7 +url = http://qt.nokia.com/doc/zh_CN/4.8 sourceencoding = UTF-8 outputencoding = UTF-8 @@ -19,15 +19,15 @@ indexes = $QTDIR/doc/html/qt.index qhp.projects = Qt qhp.Qt.file = qt.qhp -qhp.Qt.namespace = com.trolltech.qt.470 +qhp.Qt.namespace = com.trolltech.qt.480 qhp.Qt.virtualFolder = qdoc qhp.Qt.title = 教程 qhp.Qt.indexTitle = 教程 qhp.Qt.selectors = fake:example -qhp.Qt.filterAttributes = qt 4.7.0 qtrefdoc zh_CN -qhp.Qt.customFilters.Qt.name = Qt 4.7.0 -qhp.Qt.customFilters.Qt.filterAttributes = qt 4.7.0 +qhp.Qt.filterAttributes = qt 4.8.0 qtrefdoc zh_CN +qhp.Qt.customFilters.Qt.name = Qt 4.8.0 +qhp.Qt.customFilters.Qt.filterAttributes = qt 4.8.0 # Files not referenced in any qdoc file (last four are needed by qtdemo) # See also extraimages.HTML -- cgit v0.12 From 17c48bde799d2ac382a6a95cd2d9d05e8d5828ad Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Thu, 22 Apr 2010 17:01:56 +1000 Subject: Add new QDataStream version for Qt 4.8. --- src/corelib/io/qdatastream.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h index 222ba8f..774c4bc 100644 --- a/src/corelib/io/qdatastream.h +++ b/src/corelib/io/qdatastream.h @@ -85,10 +85,11 @@ public: Qt_4_4 = 10, Qt_4_5 = 11, Qt_4_6 = 12, - Qt_4_7 = Qt_4_6 -#if QT_VERSION >= 0x040800 -#error Add the datastream version for this Qt version + Qt_4_7 = Qt_4_6, Qt_4_8 = Qt_4_7 +#if QT_VERSION >= 0x040900 +#error Add the datastream version for this Qt version + Qt_4_9 = Qt_4_8 #endif }; -- cgit v0.12 From 26eb22954b8fe766d5ad63c8d21124a8393bed17 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 19:06:14 +0200 Subject: [networkselftest] Add the FTP proxy and SMB ports to the test. --- tests/auto/networkselftest/tst_networkselftest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 752e368..041765c 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -408,6 +408,8 @@ void tst_NetworkSelfTest::remotePortsOpen_data() QTest::newRow("http-proxy-auth-ntlm") << 3130; QTest::newRow("socks5-proxy") << 1080; QTest::newRow("socks5-proxy-auth") << 1081; + QTest::newRow("ftp-proxy") << 2121; + QTest::newRow("smb") << 139; } void tst_NetworkSelfTest::remotePortsOpen() @@ -725,7 +727,7 @@ void tst_NetworkSelfTest::supportsSsl() #ifdef QT_NO_OPENSSL QFAIL("SSL not compiled in"); #else - QVERIFY(QSslSocket::supportsSsl()); + QVERIFY2(QSslSocket::supportsSsl(), "Could not load SSL libraries"); #endif } -- cgit v0.12 From 1692e4824a6c7b255b2f7d492ca69c4092d173ad Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 19:53:14 +0200 Subject: [networkselftest] Add a test to try the SMB server. --- tests/auto/networkselftest/tst_networkselftest.cpp | 57 ++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 041765c..d40a3fa 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -80,6 +80,7 @@ private slots: void httpProxyNtlmAuth(); void socks5Proxy(); void socks5ProxyAuth(); + void smbServer(); // ssl supported test void supportsSsl(); @@ -731,5 +732,61 @@ void tst_NetworkSelfTest::supportsSsl() #endif } +void tst_NetworkSelfTest::smbServer() +{ + static const char contents[] = "This is 34 bytes. Do not change..."; +#ifdef Q_OS_WIN + // use Windows's native UNC support to try and open a file on the server + QString filepath = QString("\\\\%1\\testshare\\test.pri").arg(QtNetworkSettings::winServerName()); + FILE *f = fopen(filepath.toLatin1(), "rb"); + QVERIFY2(f, qt_error_string().toLocal8Bit()); + + char buf[128]; + ssize_t ret = fread(buf, sizeof buf, 1, f); + fclose(f); + + QCOMPARE(ret, strlen(contents)); + QVERIFY(memcmp(ret, contents, strlen(contents)) == 0); +#else + // try to use Samba + QString progname = "smbclient"; + QProcess smbclient; + smbclient.start(progname, QIODevice::ReadOnly); + if (!smbclient.waitForStarted(2000)) + QSKIP("Could not find smbclient (from Samba), cannot continue testing", SkipAll); + if (!smbclient.waitForFinished(2000) || smbclient.exitStatus() != QProcess::NormalExit) + QSKIP("smbclient isn't working, cannot continue testing", SkipAll); + smbclient.close(); + + // try listing the server + smbclient.start(progname, QStringList() << "-g" << "-N" << "-L" << QtNetworkSettings::winServerName(), QIODevice::ReadOnly); + QVERIFY(smbclient.waitForFinished(5000)); + if (smbclient.exitStatus() != QProcess::NormalExit) + QSKIP("smbclient crashed", SkipAll); + QVERIFY2(smbclient.exitCode() == 0, "Test server not found"); + + QByteArray output = smbclient.readAll(); + QVERIFY(output.contains("Disk|testshare|")); + QVERIFY(output.contains("Disk|testsharewritable|")); + QVERIFY(output.contains("Disk|testsharelargefile|")); + qDebug() << "Test server found and shares are correct"; + + // try getting a file + QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); + env.insert("PAGER", "/bin/cat"); // just in case + smbclient.setProcessEnvironment(env); + smbclient.start(progname, QStringList() << "-N" << "-c" << "more test.pri" + << QString("\\\\%1\\testshare").arg(QtNetworkSettings::winServerName()), QIODevice::ReadOnly); + QVERIFY(smbclient.waitForFinished(5000)); + if (smbclient.exitStatus() != QProcess::NormalExit) + QSKIP("smbclient crashed", SkipAll); + QVERIFY2(smbclient.exitCode() == 0, "File //qt-test-server/testshare/test.pri not found"); + + output = smbclient.readAll(); + QCOMPARE(output.constData(), contents); + qDebug() << "Test file is correct"; +#endif +} + QTEST_MAIN(tst_NetworkSelfTest) #include "tst_networkselftest.moc" -- cgit v0.12 From d60a1d03453ab08ac12f85b4cf3beb0d4902b406 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 19:55:58 +0200 Subject: [networkselftest] Add a test for the FTP proxy server --- tests/auto/networkselftest/tst_networkselftest.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index d40a3fa..2cfe1cb 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -72,6 +72,7 @@ private slots: // specific protocol tests void ftpServer(); + void ftpProxyServer(); void imapServer(); void httpServer(); void httpsServer(); @@ -458,11 +459,11 @@ void tst_NetworkSelfTest::fileLineEndingTest() QVERIFY2(!lineEndingType.compare("LF"), QString("Reference file %1 has %2 as line ending - Git checkout issue !?!").arg(referenceName, lineEndingType).toLocal8Bit()); } -static QList ftpChat() +static QList ftpChat(const QByteArray &userSuffix = QByteArray()) { return QList() << Chat::expect("220") << Chat::discardUntil("\r\n") - << Chat::send("USER anonymous\r\n") + << Chat::send("USER anonymous" + userSuffix + "\r\n") << Chat::expect("331") << Chat::discardUntil("\r\n") << Chat::send("PASS user@hostname\r\n") @@ -479,6 +480,11 @@ void tst_NetworkSelfTest::ftpServer() netChat(21, ftpChat()); } +void tst_NetworkSelfTest::ftpProxyServer() +{ + netChat(2121, ftpChat("@" + QtNetworkSettings::serverName().toLatin1())); +} + void tst_NetworkSelfTest::imapServer() { netChat(143, QList() -- cgit v0.12 From 6e4ea4a55ccaf6e5f205c119062d6c2b527442ec Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 20:11:53 +0200 Subject: [networkselftest] Enchance test to verify the layout of the FTP server. --- tests/auto/networkselftest/tst_networkselftest.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 2cfe1cb..297f289 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -469,6 +469,33 @@ static QList ftpChat(const QByteArray &userSuffix = QByteArray()) << Chat::send("PASS user@hostname\r\n") << Chat::expect("230") << Chat::discardUntil("\r\n") + + << Chat::send("CWD pub\r\n") + << Chat::expect("250") + << Chat::discardUntil("\r\n") + << Chat::send("CWD dir-not-readable\r\n") + << Chat::expect("550") + << Chat::discardUntil("\r\n") + << Chat::send("PWD\r\n") + << Chat::expect("257 \"/pub\"\r\n") + << Chat::send("SIZE file-not-readable.txt\r\n") + << Chat::expect("213 41\r\n") + << Chat::send("CWD qxmlquery\r\n") + << Chat::expect("250") + << Chat::discardUntil("\r\n") + + << Chat::send("CWD /qtest\r\n") + << Chat::expect("250") + << Chat::discardUntil("\r\n") + << Chat::send("SIZE bigfile\r\n") + << Chat::expect("213 519240\r\n") + << Chat::send("SIZE rfc3252\r\n") + << Chat::expect("213 25962\r\n") + << Chat::send("SIZE rfc3252.txt\r\n") + << Chat::expect("213 25962\r\n") +// << Chat::send("SIZE nonASCII/german_\344\366\374\304\326\334\337\r\n") +// << Chat::expect("213 40\r\n") + << Chat::send("QUIT\r\n") << Chat::expect("221") << Chat::discardUntil("\r\n") -- cgit v0.12 From 5c9581b896f99eda8bd98fa265f9d010e6961dea Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 20:48:32 +0200 Subject: [networkselftest] Verify PUT and DELETE commands and the protected area in HTTP --- tests/auto/networkselftest/tst_networkselftest.cpp | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 297f289..6e07d4a 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -42,6 +42,8 @@ #include #include +#include + #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir // Current path (C:\private\) contains only ascii chars @@ -529,6 +531,14 @@ void tst_NetworkSelfTest::imapServer() void tst_NetworkSelfTest::httpServer() { + QString uniqueExtension; + qsrand(time(0)); +#ifndef Q_OS_WINCE + uniqueExtension = QString("%1%2%3").arg((qulonglong)this).arg(qrand()).arg((qulonglong)time(0)); +#else + uniqueExtension = QString("%1%2").arg((qulonglong)this).arg(qrand()); +#endif + netChat(80, QList() // HTTP/0.9 chat: << Chat::send("GET /\r\n") @@ -557,6 +567,75 @@ void tst_NetworkSelfTest::httpServer() << Chat::discardUntil(" ") << Chat::expect("200 ") << Chat::DiscardUntilDisconnect + + // HTTP protected area + << Chat::Reconnect + << Chat::send("GET /qtest/protected/rfc3252.txt HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("401 ") + << Chat::DiscardUntilDisconnect + + << Chat::Reconnect + << Chat::send("HEAD /qtest/protected/rfc3252.txt HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::DiscardUntilDisconnect + + // DAV area + << Chat::Reconnect + << Chat::send("HEAD /dav/ HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::DiscardUntilDisconnect + + // HTTP/1.0 PUT + << Chat::Reconnect + << Chat::send("PUT /dav/networkselftest-" + uniqueExtension.toLatin1() + ".txt HTTP/1.0\r\n" + "Content-Length: 5\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "\r\n" + "Hello") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("201 ") + << Chat::DiscardUntilDisconnect + + // check that the file did get uploaded + << Chat::Reconnect + << Chat::send("HEAD /dav/networkselftest-" + uniqueExtension.toLatin1() + ".txt HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("200 ") + << Chat::discardUntil("\r\nContent-Length: 5\r\n") + << Chat::DiscardUntilDisconnect + + // HTTP/1.0 DELETE + << Chat::Reconnect + << Chat::send("DELETE /dav/networkselftest-" + uniqueExtension.toLatin1() + ".txt HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::discardUntil(" ") + << Chat::expect("204 ") + << Chat::DiscardUntilDisconnect ); } -- cgit v0.12 From fbc94a70f2f539d640c3a7785d11e4d6ebe70b16 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 20:48:48 +0200 Subject: [networkselftest] Verify the presence and size of some files on HTTP --- tests/auto/networkselftest/tst_networkselftest.cpp | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index 6e07d4a..a4a130a 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -77,6 +77,8 @@ private slots: void ftpProxyServer(); void imapServer(); void httpServer(); + void httpServerFiles_data(); + void httpServerFiles(); void httpsServer(); void httpProxy(); void httpProxyBasicAuth(); @@ -162,7 +164,7 @@ static QString prettyByteArray(const QByteArray &array) static bool doSocketRead(QTcpSocket *socket, int minBytesAvailable, int timeout = 4000) { - QTime timer; + QElapsedTimer timer; timer.start(); forever { if (socket->bytesAvailable() >= minBytesAvailable) @@ -639,6 +641,43 @@ void tst_NetworkSelfTest::httpServer() ); } +void tst_NetworkSelfTest::httpServerFiles_data() +{ + QTest::addColumn("uri"); + QTest::addColumn("size"); + + QTest::newRow("fluke.gif") << "/qtest/fluke.gif" << -1; + QTest::newRow("bigfile") << "/qtest/bigfile" << 519240; + QTest::newRow("rfc3252.txt") << "/qtest/rfc3252.txt" << 25962; + QTest::newRow("protected/rfc3252.txt") << "/qtest/protected/rfc3252.txt" << 25962; + QTest::newRow("completelyEmptyQuery.xq") << "/qtest/qxmlquery/completelyEmptyQuery.xq" << -1; + QTest::newRow("notWellformedViaHttps.xml") << "/qtest/qxmlquery/notWellformedViaHttps.xml" << -1; + QTest::newRow("notWellformed.xml") << "/qtest/qxmlquery/notWellformed.xml" << -1; + QTest::newRow("viaHttp.xq") << "/qtest/qxmlquery/viaHttp.xq" << -1; + QTest::newRow("wellFormedViaHttps.xml") << "/qtest/qxmlquery/wellFormedViaHttps.xml" << -1; + QTest::newRow("wellFormed.xml") << "/qtest/qxmlquery/wellFormed.xml" << -1; +} + +void tst_NetworkSelfTest::httpServerFiles() +{ + QFETCH(QString, uri); + QFETCH(int, size); + + QList chat; + chat << Chat::send("HEAD " + QUrl::toPercentEncoding(uri, "/") + " HTTP/1.0\r\n" + "Host: " + QtNetworkSettings::serverName().toLatin1() + "\r\n" + "Connection: close\r\n" + "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" + "\r\n") + << Chat::expect("HTTP/1.") + << Chat::skipBytes(1) // HTTP/1.0 or 1.1 reply + << Chat::expect(" 200 "); + if (size != -1) + chat << Chat::discardUntil("\r\nContent-Length: " + QByteArray::number(size) + "\r\n"); + chat << Chat::DiscardUntilDisconnect; + netChat(80, chat); +} + void tst_NetworkSelfTest::httpsServer() { #ifndef QT_NO_OPENSSL -- cgit v0.12 From 9da275a24ae0b40ae29292a050c48915ac61099b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 20 Apr 2010 21:21:38 +0200 Subject: [networkselftest] Verify some CGIs on the test server --- tests/auto/networkselftest/tst_networkselftest.cpp | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index a4a130a..d25fcb6 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -79,6 +79,8 @@ private slots: void httpServer(); void httpServerFiles_data(); void httpServerFiles(); + void httpServerCGI_data(); + void httpServerCGI(); void httpsServer(); void httpProxy(); void httpProxyBasicAuth(); @@ -678,6 +680,76 @@ void tst_NetworkSelfTest::httpServerFiles() netChat(80, chat); } +void tst_NetworkSelfTest::httpServerCGI_data() +{ + QTest::addColumn("request"); + QTest::addColumn("result"); + QTest::addColumn("additionalHeader"); + + QTest::newRow("echo.cgi") + << QByteArray("GET /qtest/cgi-bin/echo.cgi?Hello+World HTTP/1.0\r\n" + "Connection: close\r\n" + "\r\n") + << QByteArray("Hello+World") + << QByteArray(); + + QTest::newRow("echo.cgi(POST)") + << QByteArray("POST /qtest/cgi-bin/echo.cgi?Hello+World HTTP/1.0\r\n" + "Connection: close\r\n" + "Content-Length: 15\r\n" + "\r\n" + "Hello, World!\r\n") + << QByteArray("Hello, World!\r\n") + << QByteArray(); + + QTest::newRow("md5sum.cgi") + << QByteArray("POST /qtest/cgi-bin/md5sum.cgi HTTP/1.0\r\n" + "Connection: close\r\n" + "Content-Length: 15\r\n" + "\r\n" + "Hello, World!\r\n") + << QByteArray("29b933a8d9a0fcef0af75f1713f4940e\n") + << QByteArray(); + + QTest::newRow("protected/md5sum.cgi") + << QByteArray("POST /qtest/protected/cgi-bin/md5sum.cgi HTTP/1.0\r\n" + "Connection: close\r\n" + "Authorization: Basic cXNvY2tzdGVzdDpwYXNzd29yZA==\r\n" + "Content-Length: 15\r\n" + "\r\n" + "Hello, World!\r\n") + << QByteArray("29b933a8d9a0fcef0af75f1713f4940e\n") + << QByteArray(); + + QTest::newRow("set-cookie.cgi") + << QByteArray("POST /qtest/cgi-bin/set-cookie.cgi HTTP/1.0\r\n" + "Connection: close\r\n" + "Content-Length: 8\r\n" + "\r\n" + "foo=bar\n") + << QByteArray("Success\n") + << QByteArray("\r\nSet-Cookie: foo=bar\r\n"); +} + +void tst_NetworkSelfTest::httpServerCGI() +{ + QFETCH(QByteArray, request); + QFETCH(QByteArray, result); + QFETCH(QByteArray, additionalHeader); + QList chat; + chat << Chat::send(request) + << Chat::expect("HTTP/1.") << Chat::skipBytes(1) + << Chat::expect(" 200 "); + + if (!additionalHeader.isEmpty()) + chat << Chat::discardUntil(additionalHeader); + + chat << Chat::discardUntil("\r\n\r\n") + << Chat::expect(result) + << Chat::RemoteDisconnect; + netChat(80, chat); +} + void tst_NetworkSelfTest::httpsServer() { #ifndef QT_NO_OPENSSL -- cgit v0.12 From 56891588a23adfe4ac6a8fbe01083464dc67e79b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 19 Apr 2010 14:26:23 +0200 Subject: Fix strerror_r in case it returns a pointer that is not our buffer Task-number: QTBUG-10014 Reviewed-by: Trust Me --- src/corelib/global/qglobal.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index dfa2c17..e29ad79 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2126,8 +2126,7 @@ QString qt_error_string(int errorCode) #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) QByteArray buf(1024, '\0'); - strerror_r(errorCode, buf.data(), buf.size()); - ret = QString::fromLocal8Bit(buf.constData()); + ret = QString::fromLocal8Bit(strerror_r(errorCode, buf.data(), buf.size())); #else ret = QString::fromLocal8Bit(strerror(errorCode)); #endif -- cgit v0.12 From 7e627a0b71eda8028bc40fd38e3d5a27496872ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 22 Apr 2010 09:40:05 +0200 Subject: Mac: Remove Ctrl+Y as redo shortcut. --- src/gui/kernel/qkeysequence.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 9efcc4e..ec3df98 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -240,7 +240,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni \row \i Paste \i Ctrl+V, Shift+Ins \i Ctrl+V \i Ctrl+V, F18, Shift+Ins \i Ctrl+V, F18, Shift+Ins \i Ctrl+V \row \i Preferences \i \i Ctrl+, \i \i \i (none) \row \i Undo \i Ctrl+Z, Alt+Backspace \i Ctrl+Z \i Ctrl+Z, F14 \i Ctrl+Z, F14 \i Ctrl+Z - \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z, Ctrl+Y \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none) + \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none) \row \i Back \i Alt+Left, Backspace \i Ctrl+[ \i Alt+Left \i Alt+Left \i (none) \row \i Forward \i Alt+Right, Shift+Backspace \i Ctrl+] \i Alt+Right \i Alt+Right \i (none) \row \i Refresh \i F5 \i F5 \i F5 \i Ctrl+R, F5 \i (none) @@ -699,7 +699,6 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = { {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QApplicationPrivate::KB_Mac}, {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QApplicationPrivate::KB_All}, {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_S60}, - {QKeySequence::Redo, 0, Qt::CTRL | Qt::Key_Y, QApplicationPrivate::KB_Mac},//different priority from above {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QApplicationPrivate::KB_All}, {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QApplicationPrivate::KB_Mac}, {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QApplicationPrivate::KB_Mac}, @@ -728,7 +727,7 @@ const QKeyBinding QKeySequencePrivate::keyBindings[] = { {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QApplicationPrivate::KB_KDE}, {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac}, {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60}, - {QKeySequence::Redo, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac}, //different priority from above + {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac}, {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11}, {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_X11}, -- cgit v0.12 From 5692527f418163d21e5e2f4a4dc76c65c30150ee Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Apr 2010 10:19:23 +0200 Subject: [qtconfig app] Add an app icon. Thanks to Mario Carrion for the patch. Task-number: QTBUG-10099 Reviewed-by: Thiago Macieira --- tools/qtconfig/mainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 0de4b43..1c490e2 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include @@ -202,6 +203,7 @@ MainWindow::MainWindow() { modified = true; desktopThemeName = tr("Desktop Settings (Default)"); + setIcon(QPixmap(":/trolltech/qtconfig/images/appicon.png")); QStringList gstyles = QStyleFactory::keys(); gstyles.sort(); gstylecombo->addItem(desktopThemeName); -- cgit v0.12 From 12eac6fa53680b5c7a6c898749a4ac0d3c427c18 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Thu, 22 Apr 2010 11:30:38 +0200 Subject: Added 'parallel_test' for some QGraphics* auto-tests. --- tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro | 2 +- tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro | 2 +- tests/auto/qgraphicseffect/qgraphicseffect.pro | 2 +- tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro | 2 +- tests/auto/qgraphicsgridlayout/qgraphicsgridlayout.pro | 2 +- tests/auto/qgraphicsitemanimation/qgraphicsitemanimation.pro | 2 +- tests/auto/qgraphicslayout/qgraphicslayout.pro | 2 +- tests/auto/qgraphicslayoutitem/qgraphicslayoutitem.pro | 2 +- tests/auto/qgraphicslinearlayout/qgraphicslinearlayout.pro | 2 +- tests/auto/qgraphicsobject/qgraphicsobject.pro | 1 + tests/auto/qgraphicspixmapitem/qgraphicspixmapitem.pro | 2 +- tests/auto/qgraphicspolygonitem/qgraphicspolygonitem.pro | 2 +- tests/auto/qgraphicssceneindex/qgraphicssceneindex.pro | 2 +- tests/auto/qgraphicstransform/qgraphicstransform.pro | 1 + 14 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro b/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro index 4c065f4..8768425 100644 --- a/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro +++ b/tests/auto/qgraphicsanchorlayout/qgraphicsanchorlayout.pro @@ -1,3 +1,3 @@ load(qttest_p4) SOURCES += tst_qgraphicsanchorlayout.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro b/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro index 27f48e0..90b7878 100644 --- a/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro +++ b/tests/auto/qgraphicsanchorlayout1/qgraphicsanchorlayout1.pro @@ -1,3 +1,3 @@ load(qttest_p4) SOURCES += tst_qgraphicsanchorlayout1.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicseffect/qgraphicseffect.pro b/tests/auto/qgraphicseffect/qgraphicseffect.pro index 7effaca..94b3ce6 100644 --- a/tests/auto/qgraphicseffect/qgraphicseffect.pro +++ b/tests/auto/qgraphicseffect/qgraphicseffect.pro @@ -1,3 +1,3 @@ load(qttest_p4) SOURCES += tst_qgraphicseffect.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro b/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro index d506c6d..5658ad7 100644 --- a/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro +++ b/tests/auto/qgraphicseffectsource/qgraphicseffectsource.pro @@ -1,3 +1,3 @@ load(qttest_p4) SOURCES += tst_qgraphicseffectsource.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicsgridlayout/qgraphicsgridlayout.pro b/tests/auto/qgraphicsgridlayout/qgraphicsgridlayout.pro index 97e68bc..d66d639 100644 --- a/tests/auto/qgraphicsgridlayout/qgraphicsgridlayout.pro +++ b/tests/auto/qgraphicsgridlayout/qgraphicsgridlayout.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qgraphicsgridlayout.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicsitemanimation/qgraphicsitemanimation.pro b/tests/auto/qgraphicsitemanimation/qgraphicsitemanimation.pro index 6be3bfe..01875c7 100644 --- a/tests/auto/qgraphicsitemanimation/qgraphicsitemanimation.pro +++ b/tests/auto/qgraphicsitemanimation/qgraphicsitemanimation.pro @@ -1,5 +1,5 @@ load(qttest_p4) SOURCES += tst_qgraphicsitemanimation.cpp DEFINES += QT_NO_CAST_TO_ASCII - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicslayout/qgraphicslayout.pro b/tests/auto/qgraphicslayout/qgraphicslayout.pro index 1dc916a..eafd213 100644 --- a/tests/auto/qgraphicslayout/qgraphicslayout.pro +++ b/tests/auto/qgraphicslayout/qgraphicslayout.pro @@ -5,4 +5,4 @@ load(qttest_p4) SOURCES += tst_qgraphicslayout.cpp DEFINES += QT_USE_USING_NAMESPACE - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicslayoutitem/qgraphicslayoutitem.pro b/tests/auto/qgraphicslayoutitem/qgraphicslayoutitem.pro index 6c8bf0c..816224b 100644 --- a/tests/auto/qgraphicslayoutitem/qgraphicslayoutitem.pro +++ b/tests/auto/qgraphicslayoutitem/qgraphicslayoutitem.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qgraphicslayoutitem.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicslinearlayout/qgraphicslinearlayout.pro b/tests/auto/qgraphicslinearlayout/qgraphicslinearlayout.pro index 114e5e9..df5a827 100644 --- a/tests/auto/qgraphicslinearlayout/qgraphicslinearlayout.pro +++ b/tests/auto/qgraphicslinearlayout/qgraphicslinearlayout.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qgraphicslinearlayout.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicsobject/qgraphicsobject.pro b/tests/auto/qgraphicsobject/qgraphicsobject.pro index 965b319..2418845 100644 --- a/tests/auto/qgraphicsobject/qgraphicsobject.pro +++ b/tests/auto/qgraphicsobject/qgraphicsobject.pro @@ -1,2 +1,3 @@ load(qttest_p4) SOURCES += tst_qgraphicsobject.cpp +CONFIG += parallel_test \ No newline at end of file diff --git a/tests/auto/qgraphicspixmapitem/qgraphicspixmapitem.pro b/tests/auto/qgraphicspixmapitem/qgraphicspixmapitem.pro index f6d6c8f..6b4db95 100644 --- a/tests/auto/qgraphicspixmapitem/qgraphicspixmapitem.pro +++ b/tests/auto/qgraphicspixmapitem/qgraphicspixmapitem.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qgraphicspixmapitem.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicspolygonitem/qgraphicspolygonitem.pro b/tests/auto/qgraphicspolygonitem/qgraphicspolygonitem.pro index d54b78b..4da949b 100644 --- a/tests/auto/qgraphicspolygonitem/qgraphicspolygonitem.pro +++ b/tests/auto/qgraphicspolygonitem/qgraphicspolygonitem.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qgraphicspolygonitem.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicssceneindex/qgraphicssceneindex.pro b/tests/auto/qgraphicssceneindex/qgraphicssceneindex.pro index d1bf3cc..1fdd176 100644 --- a/tests/auto/qgraphicssceneindex/qgraphicssceneindex.pro +++ b/tests/auto/qgraphicssceneindex/qgraphicssceneindex.pro @@ -1,4 +1,4 @@ load(qttest_p4) requires(contains(QT_CONFIG,private_tests)) SOURCES += tst_qgraphicssceneindex.cpp - +CONFIG += parallel_test diff --git a/tests/auto/qgraphicstransform/qgraphicstransform.pro b/tests/auto/qgraphicstransform/qgraphicstransform.pro index 709cff6..67c939e 100644 --- a/tests/auto/qgraphicstransform/qgraphicstransform.pro +++ b/tests/auto/qgraphicstransform/qgraphicstransform.pro @@ -1,2 +1,3 @@ load(qttest_p4) SOURCES += tst_qgraphicstransform.cpp +CONFIG += parallel_test -- 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 193601b5d19881d8c031c5868e808dd75233e535 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Apr 2010 15:21:29 +0200 Subject: Designer: Fix cardinality error in stringlist properties in ui4 schema. Task-number: QT-1621 --- tools/designer/data/ui4.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/designer/data/ui4.xsd b/tools/designer/data/ui4.xsd index de4253c..f44fa71 100644 --- a/tools/designer/data/ui4.xsd +++ b/tools/designer/data/ui4.xsd @@ -414,7 +414,7 @@ - + -- 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 e102acd25673f0fd6e281f3244093200c8802c90 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Apr 2010 15:38:28 +0200 Subject: Fix merge of qtextureglyphcache.cpp The merge in 1ffc19d083a82c3f717e4f091a3af7b0241b6a6d introdcued two different versions of the m_cy calculation simultaneously. Remove the older version and keep the new. Reviewed-by: TrustMe --- src/gui/painting/qtextureglyphcache.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index bf57460..631a9cf 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -140,7 +140,6 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const // no room on the current line, start new glyph strip m_cx = 0; m_cy += m_currentRowHeight + paddingDoubled; - m_cy += rowHeight; m_currentRowHeight = 0; // New row } if (m_cy + c.h > m_h) { -- cgit v0.12 From 4780f94e391b5e881497c5228661dead42c821fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Thu, 22 Apr 2010 15:40:44 +0200 Subject: Implement heightForWidth support for QTabWidget and QStackedWidget. The problem was simply that QTabWidget does not have a layout (it does manual layouting, and since that the heightForWidth implementation it inherits from QWidget require that the widget has a layout it will not work and it always returned -1 for QTabWidget). The solution is then to reimplement heightForWidth(). Unfortunately the patch has several workarounds for BIC: 1. QWidget::hasHeightForWidth() should really have been virtual. Instead we add the virtual QWidgetPrivate::hasHeightForWidth(). Since this is a workaround/bugfix for QTabWidget we decided to keep QWidget::hasHeightForWidth() internal for now. 2. We cannot reimplement a virtual function in QStackedLayout. We therefore fix QStackedWidget by subclassing QStackedLayout and reimplement the virtual functions in the subclass. This is not an ideal fix, but improves QTabWidget and QStackedWidget wrt height for width. Task-number: QTBUG-7792 Reviewed-by: Paul Reviewed-by: Olivier --- src/gui/kernel/qlayoutitem.cpp | 4 +-- src/gui/kernel/qwidget.cpp | 17 ++++++++++ src/gui/kernel/qwidget_p.h | 1 + src/gui/widgets/qsizegrip.cpp | 17 +++------- src/gui/widgets/qstackedwidget.cpp | 46 +++++++++++++++++++++++++-- src/gui/widgets/qtabwidget.cpp | 54 ++++++++++++++++++++++++++++++++ src/gui/widgets/qtabwidget.h | 1 + tests/auto/qtabwidget/tst_qtabwidget.cpp | 48 ++++++++++++++++++++++++++++ 8 files changed, 170 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qlayoutitem.cpp b/src/gui/kernel/qlayoutitem.cpp index 6a91d95..d1a82c2 100644 --- a/src/gui/kernel/qlayoutitem.cpp +++ b/src/gui/kernel/qlayoutitem.cpp @@ -516,9 +516,7 @@ bool QWidgetItem::hasHeightForWidth() const { if (isEmpty()) return false; - if (wid->layout()) - return wid->layout()->hasHeightForWidth(); - return wid->sizePolicy().hasHeightForWidth(); + return wid->d_func()->hasHeightForWidth(); } /*! diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 10fa4b9..a4ab8da 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -9626,6 +9626,23 @@ int QWidget::heightForWidth(int w) const return -1; } + +/*! + \internal + + *virtual private* + + This is a bit hackish, but ideally we would have created a virtual function + in the public API (however, too late...) so that subclasses could reimplement + their own function. + Instead we add a virtual function to QWidgetPrivate. + ### Qt5: move to public class and make virtual +*/ +bool QWidgetPrivate::hasHeightForWidth() const +{ + return layout ? layout->hasHeightForWidth() : size_policy.hasHeightForWidth(); +} + /*! \fn QWidget *QWidget::childAt(int x, int y) const diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 89ea256..05a859c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -493,6 +493,7 @@ public: bool setMinimumSize_helper(int &minw, int &minh); bool setMaximumSize_helper(int &maxw, int &maxh); + virtual bool hasHeightForWidth() const; void setConstraints_sys(); QWidget *childAt_helper(const QPoint &, bool) const; void updateGeometry_helper(bool forceUpdate); diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp index c9d613a..b5b611c 100644 --- a/src/gui/widgets/qsizegrip.cpp +++ b/src/gui/widgets/qsizegrip.cpp @@ -78,15 +78,6 @@ static QWidget *qt_sizegrip_topLevelWidget(QWidget* w) return w; } -static inline bool hasHeightForWidth(QWidget *widget) -{ - if (!widget) - return false; - if (QLayout *layout = widget->layout()) - return layout->hasHeightForWidth(); - return widget->sizePolicy().hasHeightForWidth(); -} - class QSizeGripPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QSizeGrip) @@ -318,7 +309,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) #ifdef Q_WS_X11 // Use a native X11 sizegrip for "real" top-level windows if supported. if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { XEvent xev; xev.xclient.type = ClientMessage; xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE); @@ -340,7 +331,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e) } #endif // Q_WS_X11 #ifdef Q_WS_WIN - if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { uint orientation = 0; if (d->atBottom()) orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT; @@ -429,12 +420,12 @@ void QSizeGrip::mouseMoveEvent(QMouseEvent * e) #ifdef Q_WS_X11 if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE)) - && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) + && tlw->isTopLevel() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) return; #endif #ifdef Q_WS_WIN if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId() - && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !hasHeightForWidth(tlw)) { + && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) { MSG msg; while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)); return; diff --git a/src/gui/widgets/qstackedwidget.cpp b/src/gui/widgets/qstackedwidget.cpp index 2509a21..6c4061c 100644 --- a/src/gui/widgets/qstackedwidget.cpp +++ b/src/gui/widgets/qstackedwidget.cpp @@ -49,12 +49,54 @@ QT_BEGIN_NAMESPACE +/** + QStackedLayout does not support height for width (simply because it does not reimplement + heightForWidth() and hasHeightForWidth()). That is not possible to fix without breaking + binary compatibility. (QLayout is subject to multiple inheritance). + However, we can fix QStackedWidget by simply using a modified version of QStackedLayout + that reimplements the hfw-related functions: + */ +class QStackedLayoutHFW : public QStackedLayout +{ +public: + QStackedLayoutHFW(QWidget *parent = 0) : QStackedLayout(parent) {} + bool hasHeightForWidth() const; + int heightForWidth(int width) const; +}; + +bool QStackedLayoutHFW::hasHeightForWidth() const +{ + const int n = count(); + + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + if (item->hasHeightForWidth()) + return true; + } + } + return false; +} + +int QStackedLayoutHFW::heightForWidth(int width) const +{ + const int n = count(); + + int hfw = 0; + for (int i = 0; i < n; ++i) { + if (QLayoutItem *item = itemAt(i)) { + hfw = qMax(hfw, item->heightForWidth(width)); + } + } + return hfw; +} + + class QStackedWidgetPrivate : public QFramePrivate { Q_DECLARE_PUBLIC(QStackedWidget) public: QStackedWidgetPrivate():layout(0){} - QStackedLayout *layout; + QStackedLayoutHFW *layout; bool blockChildAdd; }; @@ -138,7 +180,7 @@ QStackedWidget::QStackedWidget(QWidget *parent) : QFrame(*new QStackedWidgetPrivate, parent) { Q_D(QStackedWidget); - d->layout = new QStackedLayout(this); + d->layout = new QStackedLayoutHFW(this); connect(d->layout, SIGNAL(widgetRemoved(int)), this, SIGNAL(widgetRemoved(int))); connect(d->layout, SIGNAL(currentChanged(int)), this, SIGNAL(currentChanged(int))); } diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 583c112..01e9d40 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -195,6 +195,7 @@ public: void _q_removeTab(int); void _q_tabMoved(int from, int to); void init(); + bool hasHeightForWidth() const; QTabBar *tabs; QStackedWidget *stack; @@ -246,6 +247,15 @@ void QTabWidgetPrivate::init() } +bool QTabWidgetPrivate::hasHeightForWidth() const +{ + bool has = size_policy.hasHeightForWidth(); + if (!has && stack) + has = qt_widget_private(stack)->hasHeightForWidth(); + return has; +} + + /*! Initialize \a option with the values from this QTabWidget. This method is useful for subclasses when they need a QStyleOptionTabWidgetFrame, but don't want to fill @@ -871,6 +881,50 @@ QSize QTabWidget::minimumSizeHint() const .expandedTo(QApplication::globalStrut()); } +/* + \reimp +*/ +int QTabWidget::heightForWidth(int width) const +{ + Q_D(const QTabWidget); + QStyleOptionTabWidgetFrameV2 opt; + initStyleOption(&opt); + opt.state = QStyle::State_None; + + QSize zero(0,0); + const QSize padding = style()->sizeFromContents(QStyle::CT_TabWidget, &opt, zero, this) + .expandedTo(QApplication::globalStrut()); + + QSize lc(0, 0), rc(0, 0); + if (d->leftCornerWidget) + lc = d->leftCornerWidget->sizeHint(); + if(d->rightCornerWidget) + rc = d->rightCornerWidget->sizeHint(); + if (!d->dirty) { + QTabWidget *that = (QTabWidget*)this; + that->setUpLayout(true); + } + QSize t(d->tabs->sizeHint()); + + if(usesScrollButtons()) + t = t.boundedTo(QSize(200,200)); + else + t = t.boundedTo(QApplication::desktop()->size()); + + const bool tabIsHorizontal = (d->pos == North || d->pos == South); + const int contentsWidth = width - padding.width(); + int stackWidth = contentsWidth; + if (!tabIsHorizontal) + stackWidth -= qMax(t.width(), qMax(lc.width(), rc.width())); + + int stackHeight = d->stack->heightForWidth(stackWidth); + QSize s(stackWidth, stackHeight); + + QSize contentSize = basicSize(tabIsHorizontal, lc, rc, s, t); + return (contentSize + padding).expandedTo(QApplication::globalStrut()).height(); +} + + /*! \reimp */ diff --git a/src/gui/widgets/qtabwidget.h b/src/gui/widgets/qtabwidget.h index 68200c8..ee50655 100644 --- a/src/gui/widgets/qtabwidget.h +++ b/src/gui/widgets/qtabwidget.h @@ -129,6 +129,7 @@ public: QSize sizeHint() const; QSize minimumSizeHint() const; + int heightForWidth(int width) const; void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner); QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const; diff --git a/tests/auto/qtabwidget/tst_qtabwidget.cpp b/tests/auto/qtabwidget/tst_qtabwidget.cpp index 6d5a873..334d45c 100644 --- a/tests/auto/qtabwidget/tst_qtabwidget.cpp +++ b/tests/auto/qtabwidget/tst_qtabwidget.cpp @@ -122,6 +122,8 @@ class tst_QTabWidget:public QObject { void keyboardNavigation(); void paintEventCount(); void minimumSizeHint(); + void heightForWidth_data(); + void heightForWidth(); private: int addPage(); @@ -646,5 +648,51 @@ void tst_QTabWidget::minimumSizeHint() QVERIFY(minSize.height() <= actSize.height()); } +void tst_QTabWidget::heightForWidth_data() +{ + QTest::addColumn("tabPosition"); + QTest::newRow("West") << int(QTabWidget::West); + QTest::newRow("North") << int(QTabWidget::North); + QTest::newRow("East") << int(QTabWidget::East); + QTest::newRow("South") << int(QTabWidget::South); +} + +void tst_QTabWidget::heightForWidth() +{ + QFETCH(int, tabPosition); + + QWidget *window = new QWidget; + QVBoxLayout *lay = new QVBoxLayout(window); + lay->setMargin(0); + lay->setSpacing(0); + QTabWidget *tabWid = new QTabWidget(window); + QWidget *w = new QWidget; + tabWid->addTab(w, QLatin1String("HFW page")); + tabWid->setTabPosition(QTabWidget::TabPosition(tabPosition)); + QVBoxLayout *lay2 = new QVBoxLayout(w); + QLabel *label = new QLabel("Label with wordwrap turned on makes it trade height for width." + " Make it a really long text so that it spans on several lines" + " when the label is on its narrowest." + " I don't like to repeat myself." + " I don't like to repeat myself." + " I don't like to repeat myself." + " I don't like to repeat myself." + ); + label->setWordWrap(true); + lay2->addWidget(label); + lay2->setMargin(0); + + lay->addWidget(tabWid); + int h = window->heightForWidth(160); + window->resize(160, h); + window->show(); + + QTest::qWaitForWindowShown(window); + QVERIFY(label->height() >= label->heightForWidth(label->width())); + + delete window; +} + + QTEST_MAIN(tst_QTabWidget) #include "tst_qtabwidget.moc" -- cgit v0.12 From 08537771bdf9a4759915deda2534337c5cbd12e1 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 22 Apr 2010 20:49:49 +0200 Subject: Revert "Fix strerror_r in case it returns a pointer that is not our buffer" This reverts commit 56891588a23adfe4ac6a8fbe01083464dc67e79b. --- src/corelib/global/qglobal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index e29ad79..dfa2c17 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2126,7 +2126,8 @@ QString qt_error_string(int errorCode) #elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) QByteArray buf(1024, '\0'); - ret = QString::fromLocal8Bit(strerror_r(errorCode, buf.data(), buf.size())); + strerror_r(errorCode, buf.data(), buf.size()); + ret = QString::fromLocal8Bit(buf.constData()); #else ret = QString::fromLocal8Bit(strerror(errorCode)); #endif -- cgit v0.12 From 387f3c10a9297b12e8f03c630d283abbe4caf22f Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 19 Apr 2010 12:53:00 +0200 Subject: Minor optimisation in QMenu Stops the QMenu re-painting itself for every mouse move event. Reviewed-By: gabi --- src/gui/widgets/qmenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index f9b132e..c157a2f 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2812,7 +2812,7 @@ void QMenu::mouseMoveEvent(QMouseEvent *e) if (d->sloppyRegion.contains(e->pos())) { d->sloppyAction = action; QMenuPrivate::sloppyDelayTimer = startTimer(style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)*6); - } else { + } else if (action != d->currentAction) { d->setCurrentAction(action, style()->styleHint(QStyle::SH_Menu_SubMenuPopupDelay, 0, this)); } } -- cgit v0.12 From 242845a50410e7b97206f6374408a2e53b5c29fb Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Thu, 15 Apr 2010 15:28:31 +0200 Subject: Added support for symlinks and junction points on Windows Since ntfs symlinks (not .lnk files) can use relative paths to targets, support for relative links needed to be added. Directory junctions can also be used to mount another filesystem directly into an existing folder. Such junctions in that case use the volume id of the target volume for the link path. Therefor this commit also includes an implementation for resolving volume ids. To be independent of existing directories in test code i added a function to create own junction points. Reviewed-by: Joao Task-number: QTBUG-9009, QTBUG-7036 --- src/corelib/io/qfsfileengine.cpp | 2 + src/corelib/io/qfsfileengine_win.cpp | 18 +++- tests/auto/qfileinfo/tst_qfileinfo.cpp | 113 ++++++++++++++++++++++++- tests/benchmarks/corelib/io/qfileinfo/main.cpp | 44 +++++++++- tests/shared/filesystem.h | 58 +++++++++++++ 5 files changed, 231 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index a1ffb81..3cf08a7 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -208,6 +208,8 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) fi.setFile(prefix); if (fi.isSymLink()) { QString target = fi.symLinkTarget(); + if(QFileInfo(target).isRelative()) + target = fi.absolutePath() + slash + target; if (separatorPos != -1) { if (fi.isDir() && !target.endsWith(slash)) target.append(slash); diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index eeca07e..668379f 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1275,7 +1275,12 @@ static QString readSymLink(const QString &link) REPARSE_DATA_BUFFER *rdb = (REPARSE_DATA_BUFFER*)qMalloc(bufsize); DWORD retsize = 0; if (::DeviceIoControl(handle, FSCTL_GET_REPARSE_POINT, 0, 0, rdb, bufsize, &retsize, 0)) { - if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) { + if (rdb->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { + int length = rdb->MountPointReparseBuffer.SubstituteNameLength / sizeof(wchar_t); + int offset = rdb->MountPointReparseBuffer.SubstituteNameOffset / sizeof(wchar_t); + const wchar_t* PathBuffer = &rdb->MountPointReparseBuffer.PathBuffer[offset]; + result = QString::fromWCharArray(PathBuffer, length); + } else if (rdb->ReparseTag == IO_REPARSE_TAG_SYMLINK) { int length = rdb->SymbolicLinkReparseBuffer.SubstituteNameLength / sizeof(wchar_t); int offset = rdb->SymbolicLinkReparseBuffer.SubstituteNameOffset / sizeof(wchar_t); const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset]; @@ -1287,6 +1292,15 @@ static QString readSymLink(const QString &link) } qFree(rdb); CloseHandle(handle); + + QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); + if(matchVolName.indexIn(result) == 0) { + DWORD len; + wchar_t buffer[MAX_PATH]; + QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); + if(GetVolumePathNamesForVolumeNameW(volumeName.utf16(), buffer, MAX_PATH, &len) != 0) + result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); + } } #else Q_UNUSED(link); @@ -1538,7 +1552,7 @@ bool QFSFileEnginePrivate::isSymlink() const if (hFind != INVALID_HANDLE_VALUE) { ::FindClose(hFind); if ((findData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) - && findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK) { + && (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK || findData.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)) { is_link = true; } } diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 403c5f9..d482cbc 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -56,6 +56,7 @@ #endif #ifdef Q_OS_WIN #include +#include #endif #include #include @@ -65,6 +66,7 @@ #endif #include "../network-settings.h" #include +#include "../../shared/filesystem.h" #if defined(Q_OS_SYMBIAN) # define SRCDIR "" @@ -161,6 +163,8 @@ private slots: void refresh(); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + void ntfsJunctionPointsAndSymlinks_data(); + void ntfsJunctionPointsAndSymlinks(); void brokenShortcut(); #endif @@ -194,8 +198,15 @@ tst_QFileInfo::~tst_QFileInfo() #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QDir().rmdir("./.hidden-directory"); #endif -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QDir().rmdir("./hidden-directory"); + QDir().rmdir("abs_symlink"); + QDir().rmdir("rel_symlink"); + QDir().rmdir("junction_pwd"); + QDir().rmdir("junction_root"); + QDir().rmdir("mountpoint"); + QFile::remove("abs_symlink.cpp"); + QFile::remove("rel_symlink.cpp"); #endif } @@ -1236,6 +1247,106 @@ void tst_QFileInfo::refresh() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() +{ + QTest::addColumn("path"); + QTest::addColumn("isSymLink"); + QTest::addColumn("linkTarget"); + QTest::addColumn("canonicalFilePath"); + + QDir pwd; + pwd.mkdir("target"); + + QLibrary kernel32("kernel32"); + typedef BOOLEAN (WINAPI *PtrCreateSymbolicLink)(LPCWSTR, LPCWSTR, DWORD); + PtrCreateSymbolicLink createSymbolicLinkW = 0; + createSymbolicLinkW = (PtrCreateSymbolicLink) kernel32.resolve("CreateSymbolicLinkW"); + if (!createSymbolicLinkW) + QSKIP("symbolic links not supported by operating system",SkipSingle); + + { + //Directory symlinks + QDir target("target"); + QVERIFY(target.exists()); + + QString absTarget = QDir::toNativeSeparators(target.absolutePath()); + QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink"); + QString relTarget = "target"; + QString relSymlink = "rel_symlink"; + QString fileInTarget(absTarget); + fileInTarget.append("\\file"); + QString fileInSymlink(absSymlink); + fileInSymlink.append("\\file"); + QFile file(fileInTarget); + file.open(QIODevice::ReadWrite); + file.close(); + + QVERIFY(pwd.exists("abs_symlink") || createSymbolicLinkW(absSymlink.utf16(),absTarget.utf16(),0x1)); + QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW(relSymlink.utf16(),relTarget.utf16(),0x1)); + QVERIFY(file.exists()); + + QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); + QTest::newRow("relative dir symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalPath(); + QTest::newRow("file in symlink dir") << fileInSymlink << false << "" << target.canonicalPath().append("/file"); + } + { + //File symlinks + QFileInfo target(SRCDIR "tst_qfileinfo.cpp"); + QString absTarget = QDir::toNativeSeparators(target.absoluteFilePath()); + QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink.cpp"); + QString relTarget = QDir::toNativeSeparators(pwd.relativeFilePath(target.absoluteFilePath())); + QString relSymlink = "rel_symlink.cpp"; + QVERIFY(pwd.exists("abs_symlink.cpp") || createSymbolicLinkW(absSymlink.utf16(),absTarget.utf16(),0x0)); + QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW(relSymlink.utf16(),relTarget.utf16(),0x0)); + + QTest::newRow("absolute file symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); + QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalFilePath(); + } + + //Junctions + QString target = "target"; + QString junction = "junction_pwd"; + FileSystem::createNtfsJunction(target, junction); + QFileInfo targetInfo(target); + QTest::newRow("junction_pwd") << junction << true << targetInfo.absoluteFilePath() << targetInfo.canonicalFilePath(); + + QFileInfo fileInJunction(targetInfo.absoluteFilePath().append("/file")); + QFile file(fileInJunction.absoluteFilePath()); + file.open(QIODevice::ReadWrite); + file.close(); + QVERIFY(file.exists()); + QTest::newRow("file in junction") << fileInJunction.absoluteFilePath() << false << "" << fileInJunction.canonicalFilePath(); + + target = QDir::rootPath(); + junction = "junction_root"; + FileSystem::createNtfsJunction(target, junction); + targetInfo.setFile(target); + QTest::newRow("junction_root") << junction << true << targetInfo.absoluteFilePath() << targetInfo.canonicalFilePath(); + + //Mountpoint + wchar_t buffer[MAX_PATH]; + QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); + QVERIFY(GetVolumeNameForVolumeMountPointW(rootPath.utf16(), buffer, MAX_PATH)); + QString rootVolume = QString::fromWCharArray(buffer); + junction = "mountpoint"; + rootVolume.replace("\\\\?\\","\\??\\"); + FileSystem::createNtfsJunction(rootVolume, junction); + QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); +} + +void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() +{ + QFETCH(QString, path); + QFETCH(bool, isSymLink); + QFETCH(QString, linkTarget); + QFETCH(QString, canonicalFilePath); + + QFileInfo fi(path); + QCOMPARE(fi.isSymLink(), isSymLink); + QCOMPARE(fi.symLinkTarget(), linkTarget); + QCOMPARE(fi.canonicalFilePath(), canonicalFilePath); +} + void tst_QFileInfo::brokenShortcut() { QString linkName("borkenlink.lnk"); diff --git a/tests/benchmarks/corelib/io/qfileinfo/main.cpp b/tests/benchmarks/corelib/io/qfileinfo/main.cpp index 025787f..b272bda 100644 --- a/tests/benchmarks/corelib/io/qfileinfo/main.cpp +++ b/tests/benchmarks/corelib/io/qfileinfo/main.cpp @@ -43,15 +43,20 @@ #include #include #include +#include #include "private/qfsfileengine_p.h" +#include "../../../../shared/filesystem.h" class qfileinfo : public QObject { Q_OBJECT private slots: void canonicalFileNamePerformance(); - +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + void symLinkTargetPerformanceLNK(); + void symLinkTargetPerformanceMounpoint(); +#endif void initTestCase(); void cleanupTestCase(); public: @@ -78,6 +83,43 @@ void qfileinfo::canonicalFileNamePerformance() } } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +void qfileinfo::symLinkTargetPerformanceLNK() +{ + QVERIFY(QFile::link("file","link.lnk")); + QFileInfo info("link.lnk"); + info.setCaching(false); + QVERIFY(info.isSymLink()); + QString linkTarget; + QBENCHMARK { + for(int i=0; i<100; i++) + linkTarget = info.readLink(); + } + QVERIFY(QFile::remove("link.lnk")); +} + +void qfileinfo::symLinkTargetPerformanceMounpoint() +{ + wchar_t buffer[MAX_PATH]; + QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); + QVERIFY(GetVolumeNameForVolumeMountPointW(rootPath.utf16(), buffer, MAX_PATH)); + QString rootVolume = QString::fromWCharArray(buffer); + QString mountpoint = "mountpoint"; + rootVolume.replace("\\\\?\\","\\??\\"); + FileSystem::createNtfsJunction(rootVolume, mountpoint); + + QFileInfo info(mountpoint); + info.setCaching(false); + QVERIFY(info.isSymLink()); + QString linkTarget; + QBENCHMARK { + for(int i=0; i<100; i++) + linkTarget = info.readLink(); + } + QVERIFY(QDir().rmdir(mountpoint)); +} +#endif + QTEST_MAIN(qfileinfo) #include "main.moc" diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index 2d46c0d..cc1781e 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -48,6 +48,11 @@ #include #include +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) +# define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) +# define REPARSE_MOUNTPOINT_HEADER_SIZE 8 +#endif + struct FileSystem { ~FileSystem() @@ -86,6 +91,59 @@ struct FileSystem } return false; } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) + static void createNtfsJunction(QString target, QString linkName) + { + typedef struct { + DWORD ReparseTag; + DWORD ReparseDataLength; + WORD Reserved; + WORD ReparseTargetLength; + WORD ReparseTargetMaximumLength; + WORD Reserved1; + WCHAR ReparseTarget[1]; + } REPARSE_MOUNTPOINT_DATA_BUFFER, *PREPARSE_MOUNTPOINT_DATA_BUFFER; + + char reparseBuffer[MAX_PATH*3]; + HANDLE hFile; + DWORD returnedLength; + wchar_t fileSystem[MAX_PATH] = L""; + PREPARSE_MOUNTPOINT_DATA_BUFFER reparseInfo = (PREPARSE_MOUNTPOINT_DATA_BUFFER) reparseBuffer; + + QFileInfo junctionInfo(linkName); + linkName = QDir::toNativeSeparators(junctionInfo.absoluteFilePath()); + + GetVolumeInformationW( linkName.left(3).utf16(), NULL, 0, NULL, NULL, NULL, + fileSystem, sizeof(fileSystem)/sizeof(WCHAR)); + if(QString().fromWCharArray(fileSystem) != "NTFS") + QSKIP("This seems not to be an NTFS volume. Junctions are not allowed.",SkipSingle); + + if (!target.startsWith("\\??\\") && !target.startsWith("\\\\?\\")) { + QFileInfo targetInfo(target); + target = QDir::toNativeSeparators(targetInfo.absoluteFilePath()); + target.prepend("\\??\\"); + if(target.endsWith('\\') && target.at(target.length()-2) != ':') + target.chop(1); + } + QDir().mkdir(linkName); + hFile = CreateFileW( linkName.utf16(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL ); + QVERIFY(hFile != INVALID_HANDLE_VALUE ); + + memset( reparseInfo, 0, sizeof( *reparseInfo )); + reparseInfo->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT; + reparseInfo->ReparseTargetLength = target.size() * sizeof(wchar_t); + reparseInfo->ReparseTargetMaximumLength = reparseInfo->ReparseTargetLength + sizeof(wchar_t); + target.toWCharArray(reparseInfo->ReparseTarget); + reparseInfo->ReparseDataLength = reparseInfo->ReparseTargetLength + 12; + + bool ioc = DeviceIoControl(hFile, FSCTL_SET_REPARSE_POINT, reparseInfo, + reparseInfo->ReparseDataLength + REPARSE_MOUNTPOINT_HEADER_SIZE, + NULL, 0, &returnedLength, NULL); + CloseHandle( hFile ); + QVERIFY(ioc); + } +#endif private: QDir currentDir; -- 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 20e56eabcb9d8a743952b9b6c3422597631ba7eb Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 23 Apr 2010 11:03:21 +0200 Subject: Fix for missing wchar_t pointer cast in qfsfileengine_win.cpp This was cause by previous commit 242845a50410e7b97206f6374408a2e53b5c29fb Reviewed-by: Joao --- src/corelib/io/qfsfileengine_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 668379f..7d85cb1 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1298,7 +1298,7 @@ static QString readSymLink(const QString &link) DWORD len; wchar_t buffer[MAX_PATH]; QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); - if(GetVolumePathNamesForVolumeNameW(volumeName.utf16(), buffer, MAX_PATH, &len) != 0) + if(GetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0) result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); } } -- 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 4affdc09b88025a93025a60fbecff57ca6ac97b7 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 23 Apr 2010 16:53:32 +0200 Subject: Use GetProcAddress for GetVolumePathNamesForVolumeNameW This allows to compile also on Windows versions prior XP Reviewed-by: Thiago --- src/corelib/io/qfsfileengine_win.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 7d85cb1..be701dc 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -154,6 +154,8 @@ static TRUSTEE_W worldTrusteeW; typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD); static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0; +typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD); +static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0; QT_END_INCLUDE_NAMESPACE @@ -212,6 +214,9 @@ void QFSFileEnginePrivate::resolveLibs() HINSTANCE userenvHnd = LoadLibrary(L"userenv"); if (userenvHnd) ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); + HINSTANCE kernel32 = LoadLibrary(L"kernel32"); + if(kernel32) + ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW"); #endif } } @@ -1293,14 +1298,19 @@ static QString readSymLink(const QString &link) qFree(rdb); CloseHandle(handle); - QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); - if(matchVolName.indexIn(result) == 0) { - DWORD len; - wchar_t buffer[MAX_PATH]; - QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); - if(GetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0) - result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); +#if !defined(QT_NO_LIBRARY) + QFSFileEnginePrivate::resolveLibs(); + if (ptrGetVolumePathNamesForVolumeNameW) { + QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive); + if(matchVolName.indexIn(result) == 0) { + DWORD len; + wchar_t buffer[MAX_PATH]; + QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\")); + if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0) + result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer)); + } } +#endif } #else Q_UNUSED(link); -- cgit v0.12 From 7eea24f6c71cde7134cfb4b8c936f235da86289d Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 26 Apr 2010 10:27:25 +0200 Subject: Assistant: Fix some merge artifacts. --- tools/assistant/tools/assistant/helpviewer_qtb.cpp | 2 +- tools/assistant/tools/assistant/mainwindow.cpp | 15 ++++++--------- tools/assistant/tools/assistant/openpagesmanager.cpp | 4 +++- tools/assistant/tools/assistant/openpagesmodel.cpp | 3 +++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index c6bb7a8..78890b9 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -188,7 +188,7 @@ void HelpViewer::openLinkInNewTab() if(lastAnchor.isEmpty()) return; - OpenPagesManager::instance()->createNewTab(QUrl(lastAnchor)); + OpenPagesManager::instance()->createPage(QUrl(lastAnchor)); lastAnchor.clear(); } diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index a9bcd90..9578478 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -418,8 +418,13 @@ void MainWindow::setupActions() QMenu *menu = menuBar()->addMenu(tr("&File")); - m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab())); + OpenPagesManager * const openPages = OpenPagesManager::instance(); + m_newTabAction + = menu->addAction(tr("New &Tab"), openPages, SLOT(createPage())); m_newTabAction->setShortcut(QKeySequence::AddTab); + m_closeTabAction = menu->addAction(tr("&Close Tab"), + openPages, SLOT(closeCurrentPage())); + m_closeTabAction->setShortcuts(QKeySequence::Close); menu->addSeparator(); @@ -432,14 +437,6 @@ void MainWindow::setupActions() menu->addAction(globalActions->printAction()); menu->addSeparator(); - OpenPagesManager * const openPages = OpenPagesManager::instance(); - m_newTabAction - = menu->addAction(tr("New &Tab"), openPages, SLOT(createPage())); - m_newTabAction->setShortcut(QKeySequence::AddTab); - m_closeTabAction = menu->addAction(tr("&Close Tab"), - openPages, SLOT(closeCurrentPage())); - m_closeTabAction->setShortcuts(QKeySequence::Close); - QAction *tmp = menu->addAction(QIcon::fromTheme("application-exit"), tr("&Quit"), this, SLOT(close())); tmp->setMenuRole(QAction::QuitRole); diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp index cd4460a..472a846 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.cpp +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -42,9 +42,11 @@ #include "centralwidget.h" #include "helpenginewrapper.h" -#include "helpviewer.h" +#if defined(QT_NO_WEBKIT) #include "helpviewer_qtb.h" +#else #include "helpviewer_qwv.h" +#endif // QT_NO_WEBKIT #include "openpagesmodel.h" #include "openpageswidget.h" #include "tracer.h" diff --git a/tools/assistant/tools/assistant/openpagesmodel.cpp b/tools/assistant/tools/assistant/openpagesmodel.cpp index 9e31b84..92ca1ad 100644 --- a/tools/assistant/tools/assistant/openpagesmodel.cpp +++ b/tools/assistant/tools/assistant/openpagesmodel.cpp @@ -41,8 +41,11 @@ #include "openpagesmodel.h" #include "helpenginewrapper.h" +#if defined(QT_NO_WEBKIT) #include "helpviewer_qtb.h" +#else #include "helpviewer_qwv.h" +#endif // QT_NO_WEBKIT #include "tracer.h" #include -- cgit v0.12 From 4874b8ec9b302151a3942d67986b8c2fe3d10338 Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Mon, 26 Apr 2010 10:31:03 +0200 Subject: Added mkspec for MSVC 2010 Reviewed-by: Marius SO --- mkspecs/win32-msvc2010/qmake.conf | 91 ++++++++++++++++++++++++++++++++++ mkspecs/win32-msvc2010/qplatformdefs.h | 42 ++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 mkspecs/win32-msvc2010/qmake.conf create mode 100644 mkspecs/win32-msvc2010/qplatformdefs.h diff --git a/mkspecs/win32-msvc2010/qmake.conf b/mkspecs/win32-msvc2010/qmake.conf new file mode 100644 index 0000000..2a48938 --- /dev/null +++ b/mkspecs/win32-msvc2010/qmake.conf @@ -0,0 +1,91 @@ +# +# qmake configuration for win32-msvc2010 +# +# Written for Microsoft VC2005.NET +# + +MAKEFILE_GENERATOR = MSBUILD +TEMPLATE = app +CONFIG += qt warn_on release incremental flat link_prl precompile_header autogen_precompile_source copy_dir_files debug_and_release debug_and_release_target embed_manifest_dll embed_manifest_exe +QT += core gui +DEFINES += UNICODE WIN32 QT_LARGEFILE_SUPPORT +QMAKE_COMPILER_DEFINES += _MSC_VER=1600 WIN32 + +QMAKE_CC = cl +QMAKE_LEX = flex +QMAKE_LEXFLAGS = +QMAKE_YACC = byacc +QMAKE_YACCFLAGS = -d +QMAKE_CFLAGS = -nologo -Zm200 -Zc:wchar_t- +QMAKE_CFLAGS_WARN_ON = -W3 +QMAKE_CFLAGS_WARN_OFF = -W0 +QMAKE_CFLAGS_RELEASE = -O2 -MD +QMAKE_CFLAGS_DEBUG = -Zi -MDd +QMAKE_CFLAGS_YACC = +QMAKE_CFLAGS_LTCG = -GL + +QMAKE_CXX = $$QMAKE_CC +QMAKE_CXXFLAGS = $$QMAKE_CFLAGS +QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 +QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF +QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE +QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG +QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC +QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG +QMAKE_CXXFLAGS_STL_ON = -EHsc +QMAKE_CXXFLAGS_STL_OFF = +QMAKE_CXXFLAGS_RTTI_ON = -GR +QMAKE_CXXFLAGS_RTTI_OFF = +QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc +QMAKE_CXXFLAGS_EXCEPTIONS_OFF = + +QMAKE_INCDIR = +QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS] +QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS] + +QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src +QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< +QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< +QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src +QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< +QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< + +QMAKE_LINK = link +QMAKE_LFLAGS = /NOLOGO +QMAKE_LFLAGS_RELEASE = /INCREMENTAL:NO +QMAKE_LFLAGS_DEBUG = /DEBUG +QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:CONSOLE +QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS \"/MANIFESTDEPENDENCY:type=\'win32\' name=\'Microsoft.Windows.Common-Controls\' version=\'6.0.0.0\' publicKeyToken=\'6595b64144ccf1df\' language=\'*\' processorArchitecture=\'*\'\" +QMAKE_LFLAGS_DLL = /DLL +QMAKE_LFLAGS_LTCG = /LTCG + +QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib +QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib winspool.lib ws2_32.lib ole32.lib user32.lib advapi32.lib +QMAKE_LIBS_NETWORK = ws2_32.lib +QMAKE_LIBS_OPENGL = opengl32.lib glu32.lib gdi32.lib user32.lib +QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib + +QMAKE_LIBS_QT_ENTRY = -lqtmain + +QMAKE_MOC = $$[QT_INSTALL_BINS]\moc.exe +QMAKE_UIC = $$[QT_INSTALL_BINS]\uic.exe +QMAKE_IDC = $$[QT_INSTALL_BINS]\idc.exe + +QMAKE_IDL = midl +QMAKE_LIB = lib /NOLOGO +QMAKE_RC = rc + +QMAKE_ZIP = zip -r -9 + +QMAKE_COPY = copy /y +QMAKE_COPY_DIR = xcopy /s /q /y /i +QMAKE_MOVE = move +QMAKE_DEL_FILE = del +QMAKE_DEL_DIR = rmdir +QMAKE_CHK_DIR_EXISTS = if not exist +QMAKE_MKDIR = mkdir + +VCPROJ_EXTENSION = .vcxproj +VCSOLUTION_EXTENSION = .sln +VCPROJ_KEYWORD = Qt4VSv1.0 +load(qt_config) diff --git a/mkspecs/win32-msvc2010/qplatformdefs.h b/mkspecs/win32-msvc2010/qplatformdefs.h new file mode 100644 index 0000000..68f9ee0 --- /dev/null +++ b/mkspecs/win32-msvc2010/qplatformdefs.h @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include "../win32-msvc2005/qplatformdefs.h" -- cgit v0.12 From 2c99794e486234580fc0e149c1f176edb57d6565 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 26 Apr 2010 11:11:46 +0200 Subject: Assistant: Don't display close button when it's not functional. Plus: Show page title in context menu also when right-clicking on the close button. Reviewed-by: kh1 --- tools/assistant/tools/assistant/openpageswidget.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp index 648ead8..bbc86c3 100644 --- a/tools/assistant/tools/assistant/openpageswidget.cpp +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -63,7 +63,8 @@ void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt QStyledItemDelegate::paint(painter, option, index); - if (index.column() == 1 && option.state & QStyle::State_MouseOver) { + if (index.column() == 1 && index.model()->rowCount() > 1 + && option.state & QStyle::State_MouseOver) { QIcon icon((option.state & QStyle::State_Selected) ? ":/trolltech/assistant/images/closebutton.png" : ":/trolltech/assistant/images/darkclosebutton.png"); @@ -113,10 +114,12 @@ OpenPagesWidget::~OpenPagesWidget() void OpenPagesWidget::contextMenuRequested(QPoint pos) { - const QModelIndex &index = indexAt(pos); + QModelIndex index = indexAt(pos); if (!index.isValid()) return; + if (index.column() == 1) + index = index.sibling(index.row(), 0); QMenu contextMenu; QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data() .toString())); -- cgit v0.12 From 8daa3ee6591f0ec5f65552a8a9290228d6e9f0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 26 Apr 2010 10:30:56 +0200 Subject: QCheckBox did not have a minimumSizeHint() Fortunately the *default* horizontal size policy was QSizePolicy::Minimum. However if the size policy was set to for instance Preferred it could shrink down until it disappeared. The following patch will do the same as QLabel does it: sizeHint is the same as minimumSizeHint. Task-number: QTBUG-2606 Reviewed-by: Gabriel --- src/gui/widgets/qcheckbox.cpp | 9 +++++++++ src/gui/widgets/qcheckbox.h | 1 + tests/auto/qcheckbox/tst_qcheckbox.cpp | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/src/gui/widgets/qcheckbox.cpp b/src/gui/widgets/qcheckbox.cpp index bc0900e..64b47b4 100644 --- a/src/gui/widgets/qcheckbox.cpp +++ b/src/gui/widgets/qcheckbox.cpp @@ -300,6 +300,15 @@ QSize QCheckBox::sizeHint() const return d->sizeHint; } + +/*! + \reimp +*/ +QSize QCheckBox::minimumSizeHint() const +{ + return sizeHint(); +} + /*! \reimp */ diff --git a/src/gui/widgets/qcheckbox.h b/src/gui/widgets/qcheckbox.h index 7b6292d..95da261 100644 --- a/src/gui/widgets/qcheckbox.h +++ b/src/gui/widgets/qcheckbox.h @@ -65,6 +65,7 @@ public: QSize sizeHint() const; + QSize minimumSizeHint() const; void setTristate(bool y = true); bool isTristate() const; diff --git a/tests/auto/qcheckbox/tst_qcheckbox.cpp b/tests/auto/qcheckbox/tst_qcheckbox.cpp index d16370c..24d78fe 100644 --- a/tests/auto/qcheckbox/tst_qcheckbox.cpp +++ b/tests/auto/qcheckbox/tst_qcheckbox.cpp @@ -92,6 +92,7 @@ private slots: void setAccel(); void group(); void foregroundRole(); + void minimumSizeHint(); protected slots: void onClicked(); @@ -425,5 +426,11 @@ void tst_QCheckBox::foregroundRole() QVERIFY(testWidget->foregroundRole() == QPalette::WindowText); } +void tst_QCheckBox::minimumSizeHint() +{ + QCheckBox box(tr("CheckBox's sizeHint is the same as it's minimumSizeHint")); + QCOMPARE(box.sizeHint(), box.minimumSizeHint()); +} + QTEST_MAIN(tst_QCheckBox) #include "tst_qcheckbox.moc" -- cgit v0.12 From 3dd2b86db2b10998dc0a49e2310dd2e8699159cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 26 Apr 2010 11:53:55 +0200 Subject: QRadioButton did not have a minimumSizeHint() Fortunately the *default* horizontal size policy was QSizePolicy::Minimum. However if the size policy was set to for instance Preferred it could shrink down until it disappeared. The following patch will do the same as QLabel does it: sizeHint is the same as minimumSizeHint. Task-number: QTBUG-2606 --- src/gui/widgets/qradiobutton.cpp | 8 ++++++++ src/gui/widgets/qradiobutton.h | 1 + tests/auto/qradiobutton/tst_qradiobutton.cpp | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/src/gui/widgets/qradiobutton.cpp b/src/gui/widgets/qradiobutton.cpp index 20b6c720..56bd709 100644 --- a/src/gui/widgets/qradiobutton.cpp +++ b/src/gui/widgets/qradiobutton.cpp @@ -207,6 +207,14 @@ QSize QRadioButton::sizeHint() const /*! \reimp */ +QSize QRadioButton::minimumSizeHint() const +{ + return sizeHint(); +} + +/*! + \reimp +*/ bool QRadioButton::hitButton(const QPoint &pos) const { QStyleOptionButton opt; diff --git a/src/gui/widgets/qradiobutton.h b/src/gui/widgets/qradiobutton.h index 887b747..b7031e2 100644 --- a/src/gui/widgets/qradiobutton.h +++ b/src/gui/widgets/qradiobutton.h @@ -62,6 +62,7 @@ public: explicit QRadioButton(const QString &text, QWidget *parent=0); QSize sizeHint() const; + QSize minimumSizeHint() const; protected: bool event(QEvent *e); diff --git a/tests/auto/qradiobutton/tst_qradiobutton.cpp b/tests/auto/qradiobutton/tst_qradiobutton.cpp index c074496..531ebab 100644 --- a/tests/auto/qradiobutton/tst_qradiobutton.cpp +++ b/tests/auto/qradiobutton/tst_qradiobutton.cpp @@ -58,6 +58,7 @@ public: private slots: void task190739_focus(); + void minimumSizeHint(); private: }; @@ -96,6 +97,11 @@ void tst_QRadioButton::task190739_focus() } +void tst_QRadioButton::minimumSizeHint() +{ + QRadioButton button(tr("QRadioButtons sizeHint is the same as it's minimumSizeHint")); + QCOMPARE(button.sizeHint(), button.minimumSizeHint()); +} QTEST_MAIN(tst_QRadioButton) -- cgit v0.12 From 27668f4df1756225cfa07fe4195024b501d66d25 Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 26 Apr 2010 12:31:41 +0200 Subject: Fixes selection being cleared when right clicking on a selected item. Autotest included. Task-number: QTBUG-10138 Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 38 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d1c5fd2..6db583a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7015,7 +7015,7 @@ void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) setSelected(true); } } - } else if (!(flags() & ItemIsMovable)) { + } else if (!(flags() & ItemIsMovable) && !isSelected()) { event->ignore(); } if (d_ptr->isWidget) { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 03ce45a..6e7c83c 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -294,6 +294,7 @@ private slots: void explicitlyEnabled(); void selected(); void selected2(); + void selected3(); void selected_group(); void selected_textItem(); void selected_multi(); @@ -1453,6 +1454,43 @@ void tst_QGraphicsItem::selected2() } } +void tst_QGraphicsItem::selected3() +{ + QGraphicsScene scene; + QGraphicsItem *item1 = scene.addRect(QRectF(0, 0, 100, 100)); + item1->setFlag(QGraphicsItem::ItemIsSelectable); + + QGraphicsItem *item2 = scene.addRect(QRectF(100, 100, 100, 100)); + item2->setFlag(QGraphicsItem::ItemIsSelectable); + + item1->setSelected(true); + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); + + // Right click on a selected item should not clear the selection + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item1->boundingRect().center())); + QVERIFY(item1->isSelected()); + QCOMPARE(scene.selectedItems().count(), 1); + + // Right click on an unselected item should clear the selection + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item2->boundingRect().center())); + QVERIFY(!item1->isSelected()); + QCOMPARE(scene.selectedItems().count(), 0); + + item2->setSelected(true); + QVERIFY(item2->isSelected()); + QCOMPARE(scene.selectedItems().count(), 1); + + // Right click on the scene background should clear the selection + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(QPointF(0, 110))); + QVERIFY(!item2->isSelected()); + QCOMPARE(scene.selectedItems().count(), 0); +} + void tst_QGraphicsItem::selected_group() { QGraphicsScene scene; -- cgit v0.12 From 07ba36e03540591f25c75593f8a24c307ab4a8cd Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Mon, 26 Apr 2010 14:32:44 +0200 Subject: Fix a small typo in qevent.cpp Merge-request: 572 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/kernel/qevent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index acf7184..055c127 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4384,7 +4384,7 @@ void QGestureEvent::accept(QGesture *gesture) of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}. Clearing the accept flag indicates that the event receiver does not - want the gesture. Unwanted gestures may be propgated to the parent widget. + want the gesture. Unwanted gestures may be propagated to the parent widget. \sa QGestureEvent::accept() */ -- cgit v0.12 From 6909b28fbae1ebe5f70f4d21353bc5e7af9187ae Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 26 Apr 2010 14:26:18 +0200 Subject: Revert "Fixes selection being cleared when right clicking on a selected item." This reverts commit 27668f4df1756225cfa07fe4195024b501d66d25. --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 38 -------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 6db583a..d1c5fd2 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7015,7 +7015,7 @@ void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) setSelected(true); } } - } else if (!(flags() & ItemIsMovable) && !isSelected()) { + } else if (!(flags() & ItemIsMovable)) { event->ignore(); } if (d_ptr->isWidget) { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 6e7c83c..03ce45a 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -294,7 +294,6 @@ private slots: void explicitlyEnabled(); void selected(); void selected2(); - void selected3(); void selected_group(); void selected_textItem(); void selected_multi(); @@ -1454,43 +1453,6 @@ void tst_QGraphicsItem::selected2() } } -void tst_QGraphicsItem::selected3() -{ - QGraphicsScene scene; - QGraphicsItem *item1 = scene.addRect(QRectF(0, 0, 100, 100)); - item1->setFlag(QGraphicsItem::ItemIsSelectable); - - QGraphicsItem *item2 = scene.addRect(QRectF(100, 100, 100, 100)); - item2->setFlag(QGraphicsItem::ItemIsSelectable); - - item1->setSelected(true); - QGraphicsView view(&scene); - view.show(); - QTest::qWaitForWindowShown(&view); - - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); - - // Right click on a selected item should not clear the selection - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item1->boundingRect().center())); - QVERIFY(item1->isSelected()); - QCOMPARE(scene.selectedItems().count(), 1); - - // Right click on an unselected item should clear the selection - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item2->boundingRect().center())); - QVERIFY(!item1->isSelected()); - QCOMPARE(scene.selectedItems().count(), 0); - - item2->setSelected(true); - QVERIFY(item2->isSelected()); - QCOMPARE(scene.selectedItems().count(), 1); - - // Right click on the scene background should clear the selection - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(QPointF(0, 110))); - QVERIFY(!item2->isSelected()); - QCOMPARE(scene.selectedItems().count(), 0); -} - void tst_QGraphicsItem::selected_group() { QGraphicsScene scene; -- cgit v0.12 From 4c577d37d7caaa831e62c5651513656975af3134 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Mon, 26 Apr 2010 09:20:10 +0200 Subject: Fix for missing wchar_t pointer casts in filesystem.h Further a dummy row has been added to ntfsJunctionPointsAndSymlinks_data to make sure the test will not fail in case the _data function gets skipped. This was cause by previous commit 242845a50410e7b97206f6374408a2e53b5c29fb Reviewed-by: Joao --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 42 ++++++++++++++++++++++------------ tests/shared/filesystem.h | 12 ++++++---- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index d482cbc..5612999 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -39,6 +39,9 @@ ** ****************************************************************************/ +#ifdef Q_OS_WIN +#define _WIN32_WINNT 0x500 +#endif #include @@ -1093,7 +1096,7 @@ void tst_QFileInfo::isHidden_data() #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QVERIFY(QDir("./hidden-directory").exists() || QDir().mkdir("./hidden-directory")); - QVERIFY(SetFileAttributesW(QString("./hidden-directory").utf16(),FILE_ATTRIBUTE_HIDDEN)); + QVERIFY(SetFileAttributesW((wchar_t*)QString("./hidden-directory").utf16(),FILE_ATTRIBUTE_HIDDEN)); QTest::newRow("C:/path/to/hidden-directory") << QDir::currentPath() + QString::fromLatin1("/hidden-directory") << true; QTest::newRow("C:/path/to/hidden-directory/.") << QDir::currentPath() + QString::fromLatin1("/hidden-directory/.") << true; #endif @@ -1261,9 +1264,12 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() typedef BOOLEAN (WINAPI *PtrCreateSymbolicLink)(LPCWSTR, LPCWSTR, DWORD); PtrCreateSymbolicLink createSymbolicLinkW = 0; createSymbolicLinkW = (PtrCreateSymbolicLink) kernel32.resolve("CreateSymbolicLinkW"); - if (!createSymbolicLinkW) + if (!createSymbolicLinkW) { + //we need at least one data set for the test not to fail when skipping _data function + QDir target("target"); + QTest::newRow("dummy") << target.path() << false << "" << target.canonicalPath(); QSKIP("symbolic links not supported by operating system",SkipSingle); - + } { //Directory symlinks QDir target("target"); @@ -1281,8 +1287,8 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() file.open(QIODevice::ReadWrite); file.close(); - QVERIFY(pwd.exists("abs_symlink") || createSymbolicLinkW(absSymlink.utf16(),absTarget.utf16(),0x1)); - QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW(relSymlink.utf16(),relTarget.utf16(),0x1)); + QVERIFY(pwd.exists("abs_symlink") || createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1)); + QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1)); QVERIFY(file.exists()); QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); @@ -1296,8 +1302,8 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QString absSymlink = QDir::toNativeSeparators(pwd.absolutePath()).append("\\abs_symlink.cpp"); QString relTarget = QDir::toNativeSeparators(pwd.relativeFilePath(target.absoluteFilePath())); QString relSymlink = "rel_symlink.cpp"; - QVERIFY(pwd.exists("abs_symlink.cpp") || createSymbolicLinkW(absSymlink.utf16(),absTarget.utf16(),0x0)); - QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW(relSymlink.utf16(),relTarget.utf16(),0x0)); + QVERIFY(pwd.exists("abs_symlink.cpp") || createSymbolicLinkW((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x0)); + QVERIFY(pwd.exists(relSymlink) || createSymbolicLinkW((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x0)); QTest::newRow("absolute file symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalFilePath(); @@ -1324,14 +1330,20 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QTest::newRow("junction_root") << junction << true << targetInfo.absoluteFilePath() << targetInfo.canonicalFilePath(); //Mountpoint - wchar_t buffer[MAX_PATH]; - QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); - QVERIFY(GetVolumeNameForVolumeMountPointW(rootPath.utf16(), buffer, MAX_PATH)); - QString rootVolume = QString::fromWCharArray(buffer); - junction = "mountpoint"; - rootVolume.replace("\\\\?\\","\\??\\"); - FileSystem::createNtfsJunction(rootVolume, junction); - QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); + typedef BOOLEAN (WINAPI *PtrGetVolumeNameForVolumeMountPointW)(LPCWSTR, LPWSTR, DWORD); + PtrGetVolumeNameForVolumeMountPointW getVolumeNameForVolumeMountPointW = 0; + getVolumeNameForVolumeMountPointW = (PtrGetVolumeNameForVolumeMountPointW) kernel32.resolve("GetVolumeNameForVolumeMountPointW"); + if(getVolumeNameForVolumeMountPointW) + { + wchar_t buffer[MAX_PATH]; + QString rootPath = QDir::toNativeSeparators(QDir::rootPath()); + QVERIFY(getVolumeNameForVolumeMountPointW((wchar_t*)rootPath.utf16(), buffer, MAX_PATH)); + QString rootVolume = QString::fromWCharArray(buffer); + junction = "mountpoint"; + rootVolume.replace("\\\\?\\","\\??\\"); + FileSystem::createNtfsJunction(rootVolume, junction); + QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); + } } void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index cc1781e..079a6dc 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -49,8 +49,12 @@ #include #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -# define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) -# define REPARSE_MOUNTPOINT_HEADER_SIZE 8 +#include +#include +#ifndef IO_REPARSE_TAG_MOUNT_POINT +#define IO_REPARSE_TAG_MOUNT_POINT (0xA0000003L) +#endif +#define REPARSE_MOUNTPOINT_HEADER_SIZE 8 #endif struct FileSystem @@ -113,7 +117,7 @@ struct FileSystem QFileInfo junctionInfo(linkName); linkName = QDir::toNativeSeparators(junctionInfo.absoluteFilePath()); - GetVolumeInformationW( linkName.left(3).utf16(), NULL, 0, NULL, NULL, NULL, + GetVolumeInformationW( (wchar_t*)linkName.left(3).utf16(), NULL, 0, NULL, NULL, NULL, fileSystem, sizeof(fileSystem)/sizeof(WCHAR)); if(QString().fromWCharArray(fileSystem) != "NTFS") QSKIP("This seems not to be an NTFS volume. Junctions are not allowed.",SkipSingle); @@ -126,7 +130,7 @@ struct FileSystem target.chop(1); } QDir().mkdir(linkName); - hFile = CreateFileW( linkName.utf16(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, + hFile = CreateFileW( (wchar_t*)linkName.utf16(), GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL ); QVERIFY(hFile != INVALID_HANDLE_VALUE ); -- cgit v0.12 From 12c3858494167b701208a9f56faf79ec2a0f61cd Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 27 Apr 2010 09:14:54 +0200 Subject: Assistant: Fix license headers. --- .../assistant/tools/assistant/openpageswidget.cpp | 40 ++++++++++++++-------- tools/assistant/tools/assistant/openpageswidget.h | 40 ++++++++++++++-------- 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp index bbc86c3..96af7b5 100644 --- a/tools/assistant/tools/assistant/openpageswidget.cpp +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -1,20 +1,19 @@ -/************************************************************************** -** -** This file is part of the Assistant module of the Qt toolkit. -** -** Copyright (c) 2010 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) ** -** Commercial Usage +** This file is part of the Assistant module of the Qt Toolkit. ** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +21,23 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ ** -**************************************************************************/ +****************************************************************************/ #include "openpageswidget.h" diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h index 5b35321..511735e 100644 --- a/tools/assistant/tools/assistant/openpageswidget.h +++ b/tools/assistant/tools/assistant/openpageswidget.h @@ -1,20 +1,19 @@ -/************************************************************************** -** -** This file is part of the Assistant module of the Qt toolkit. -** -** Copyright (c) 2010 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) ** -** Commercial Usage +** This file is part of the Assistant module of the Qt Toolkit. ** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. ** ** GNU Lesser General Public License Usage -** ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL included in the @@ -22,10 +21,23 @@ ** ensure the GNU Lesser General Public License version 2.1 requirements ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESWIDGET_H #define OPENPAGESWIDGET_H -- 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 d513ab6e72cc6e180f788e67e48d04fc16a2817e Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 27 Apr 2010 11:13:17 +0200 Subject: Assistant: Fix line endings. --- .../assistant/tools/assistant/openpagesmanager.cpp | 620 ++++++++++----------- tools/assistant/tools/assistant/openpagesmanager.h | 208 +++---- .../assistant/tools/assistant/openpageswidget.cpp | 392 ++++++------- tools/assistant/tools/assistant/openpageswidget.h | 176 +++--- 4 files changed, 698 insertions(+), 698 deletions(-) diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp index 472a846..7a2228f 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.cpp +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -1,310 +1,310 @@ -/**************************************************************************** -** -** 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 Assistant module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "openpagesmanager.h" - -#include "centralwidget.h" -#include "helpenginewrapper.h" -#if defined(QT_NO_WEBKIT) -#include "helpviewer_qtb.h" -#else -#include "helpviewer_qwv.h" -#endif // QT_NO_WEBKIT -#include "openpagesmodel.h" -#include "openpageswidget.h" -#include "tracer.h" -#include "../shared/collectionconfiguration.h" - -#include - -QT_BEGIN_NAMESPACE - -OpenPagesManager *OpenPagesManager::createInstance(QObject *parent, - bool defaultCollection, const QUrl &cmdLineUrl) -{ - TRACE_OBJ - Q_ASSERT(!m_instance); - m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl); - return m_instance; -} - -OpenPagesManager *OpenPagesManager::instance() -{ - TRACE_OBJ - Q_ASSERT(m_instance); - return m_instance; -} - -OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection, - const QUrl &cmdLineUrl) - : QObject(parent), m_model(new OpenPagesModel(this)), - m_openPagesWidget(new OpenPagesWidget(m_model)) -{ - TRACE_OBJ - connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, - SLOT(setCurrentPage(QModelIndex))); - connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, - SLOT(closePage(QModelIndex))); - connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this, - SLOT(closePagesExcept(QModelIndex))); - setupInitialPages(defaultCollection, cmdLineUrl); -} - -int OpenPagesManager::pageCount() const -{ - TRACE_OBJ - return m_model->rowCount(); -} - -void OpenPagesManager::setupInitialPages(bool defaultCollection, - const QUrl &cmdLineUrl) -{ - TRACE_OBJ - if (cmdLineUrl.isValid()) { - createPage(cmdLineUrl); - return; - } - - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - int initialPage = 0; - switch (helpEngine.startOption()) { - case ShowHomePage: - m_model->addPage(helpEngine.homePage()); - break; - case ShowBlankPage: - m_model->addPage(QUrl(QLatin1String("about:blank"))); - break; - case ShowLastPages: { - const QStringList &lastShownPageList = helpEngine.lastShownPages(); - const int pageCount = lastShownPageList.count(); - if (pageCount == 0) { - if (defaultCollection) - m_model->addPage(QUrl(QLatin1String("help"))); - else - m_model->addPage(QUrl(QLatin1String("about:blank"))); - } else { - QStringList zoomFactors = helpEngine.lastZoomFactors(); - while (zoomFactors.count() < pageCount) - zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); - initialPage = helpEngine.lastTabPage(); - if (initialPage >= pageCount) { - qWarning("Initial page set to %d, maximum possible value is %d", - initialPage, pageCount - 1); - initialPage = 0; - } - for (int curPage = 0; curPage < pageCount; ++curPage) { - const QString &curFile = lastShownPageList.at(curPage); - if (helpEngine.findFile(curFile).isValid() - || curFile == QLatin1String("about:blank")) { - m_model->addPage(curFile, zoomFactors.at(curPage).toFloat()); - } else if (curPage <= initialPage && initialPage > 0) - --initialPage; - } - } - break; - } - default: - Q_ASSERT(!"Unhandled option"); - } - - if (m_model->rowCount() == 0) - m_model->addPage(helpEngine.homePage()); - for (int i = 0; i < m_model->rowCount(); ++i) - CentralWidget::instance()->addPage(m_model->pageAt(i)); - setCurrentPage(initialPage); -} - -HelpViewer *OpenPagesManager::createPage() -{ - TRACE_OBJ - return createPage(QUrl(QLatin1String("about:blank"))); -} - -void OpenPagesManager::closeCurrentPage() -{ - TRACE_OBJ - Q_ASSERT(m_model->rowCount() > 1); - const QModelIndexList selectedIndexes - = m_openPagesWidget->selectionModel()->selectedRows(); - if (selectedIndexes.isEmpty()) - return; - Q_ASSERT(selectedIndexes.count() == 1); - removePage(selectedIndexes.first().row()); -} - -HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch) -{ - TRACE_OBJ - if (AbstractHelpViewer::launchWithExternalApp(url)) - return 0; - - m_model->addPage(url); - const int index = m_model->rowCount() - 1; - HelpViewer * const page = m_model->pageAt(index); - CentralWidget::instance()->addPage(page, fromSearch); - setCurrentPage(index); - return page; -} - -HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url) -{ - return createPage(url, true); -} - -void OpenPagesManager::closePage(const QModelIndex &index) -{ - if (index.isValid()) - removePage(index.row()); -} - -void OpenPagesManager::closePages(const QString &nameSpace) -{ - TRACE_OBJ - closeOrReloadPages(nameSpace, false); -} - -void OpenPagesManager::reloadPages(const QString &nameSpace) -{ - TRACE_OBJ - closeOrReloadPages(nameSpace, true); - selectCurrentPage(); -} - -void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload) -{ - TRACE_OBJ - - for (int i = m_model->rowCount() - 1; i >= 0; --i) { - HelpViewer *page = m_model->pageAt(i); - if (page->source().host() != nameSpace) - continue; - if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid()) - page->reload(); - else if (m_model->rowCount() == 1) - page->setSource(QUrl(QLatin1String("about:blank"))); - else - removePage(i); - } -} - -bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const -{ - TRACE_OBJ - for (int i = 0; i < m_model->rowCount(); ++i) - if (m_model->pageAt(i)->source().host() == nameSpace) - return true; - return false; -} - -void OpenPagesManager::setCurrentPage(const QModelIndex &index) -{ - TRACE_OBJ - if (!index.isValid()) - return; - HelpViewer * const page = m_model->pageAt(index.row()); - CentralWidget::instance()->setCurrentPage(page); -} - -void OpenPagesManager::setCurrentPage(int index) -{ - TRACE_OBJ - CentralWidget::instance()->setCurrentPage(m_model->pageAt(index)); - selectCurrentPage(); -} - -void OpenPagesManager::selectCurrentPage() -{ - TRACE_OBJ - QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel(); - selModel->clearSelection(); - selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0), - QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex()); -} - -void OpenPagesManager::removePage(int index) -{ - TRACE_OBJ - CentralWidget::instance()->removePage(index); - m_model->removePage(index); - selectCurrentPage(); -} - - -void OpenPagesManager::closePagesExcept(const QModelIndex &index) -{ - TRACE_OBJ - if (!index.isValid()) - return; - - int i = 0; - HelpViewer *viewer = m_model->pageAt(index.row()); - while (m_model->rowCount() > 1) { - if (m_model->pageAt(i) != viewer) - removePage(i); - else - ++i; - } -} - -QWidget *OpenPagesManager::openPagesWidget() const -{ - return m_openPagesWidget; -} - -void OpenPagesManager::nextPage() -{ - nextOrPreviousPage(1); -} - -void OpenPagesManager::previousPage() -{ - nextOrPreviousPage(-1); -} - -void OpenPagesManager::nextOrPreviousPage(int offset) -{ - setCurrentPage((CentralWidget::instance()->currentIndex() + offset - + m_model->rowCount()) % m_model->rowCount()); -} - -OpenPagesManager *OpenPagesManager::m_instance = 0; - -QT_END_NAMESPACE +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "openpagesmanager.h" + +#include "centralwidget.h" +#include "helpenginewrapper.h" +#if defined(QT_NO_WEBKIT) +#include "helpviewer_qtb.h" +#else +#include "helpviewer_qwv.h" +#endif // QT_NO_WEBKIT +#include "openpagesmodel.h" +#include "openpageswidget.h" +#include "tracer.h" +#include "../shared/collectionconfiguration.h" + +#include + +QT_BEGIN_NAMESPACE + +OpenPagesManager *OpenPagesManager::createInstance(QObject *parent, + bool defaultCollection, const QUrl &cmdLineUrl) +{ + TRACE_OBJ + Q_ASSERT(!m_instance); + m_instance = new OpenPagesManager(parent, defaultCollection, cmdLineUrl); + return m_instance; +} + +OpenPagesManager *OpenPagesManager::instance() +{ + TRACE_OBJ + Q_ASSERT(m_instance); + return m_instance; +} + +OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection, + const QUrl &cmdLineUrl) + : QObject(parent), m_model(new OpenPagesModel(this)), + m_openPagesWidget(new OpenPagesWidget(m_model)) +{ + TRACE_OBJ + connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, + SLOT(setCurrentPage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, + SLOT(closePage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this, + SLOT(closePagesExcept(QModelIndex))); + setupInitialPages(defaultCollection, cmdLineUrl); +} + +int OpenPagesManager::pageCount() const +{ + TRACE_OBJ + return m_model->rowCount(); +} + +void OpenPagesManager::setupInitialPages(bool defaultCollection, + const QUrl &cmdLineUrl) +{ + TRACE_OBJ + if (cmdLineUrl.isValid()) { + createPage(cmdLineUrl); + return; + } + + HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); + int initialPage = 0; + switch (helpEngine.startOption()) { + case ShowHomePage: + m_model->addPage(helpEngine.homePage()); + break; + case ShowBlankPage: + m_model->addPage(QUrl(QLatin1String("about:blank"))); + break; + case ShowLastPages: { + const QStringList &lastShownPageList = helpEngine.lastShownPages(); + const int pageCount = lastShownPageList.count(); + if (pageCount == 0) { + if (defaultCollection) + m_model->addPage(QUrl(QLatin1String("help"))); + else + m_model->addPage(QUrl(QLatin1String("about:blank"))); + } else { + QStringList zoomFactors = helpEngine.lastZoomFactors(); + while (zoomFactors.count() < pageCount) + zoomFactors.append(CollectionConfiguration::DefaultZoomFactor); + initialPage = helpEngine.lastTabPage(); + if (initialPage >= pageCount) { + qWarning("Initial page set to %d, maximum possible value is %d", + initialPage, pageCount - 1); + initialPage = 0; + } + for (int curPage = 0; curPage < pageCount; ++curPage) { + const QString &curFile = lastShownPageList.at(curPage); + if (helpEngine.findFile(curFile).isValid() + || curFile == QLatin1String("about:blank")) { + m_model->addPage(curFile, zoomFactors.at(curPage).toFloat()); + } else if (curPage <= initialPage && initialPage > 0) + --initialPage; + } + } + break; + } + default: + Q_ASSERT(!"Unhandled option"); + } + + if (m_model->rowCount() == 0) + m_model->addPage(helpEngine.homePage()); + for (int i = 0; i < m_model->rowCount(); ++i) + CentralWidget::instance()->addPage(m_model->pageAt(i)); + setCurrentPage(initialPage); +} + +HelpViewer *OpenPagesManager::createPage() +{ + TRACE_OBJ + return createPage(QUrl(QLatin1String("about:blank"))); +} + +void OpenPagesManager::closeCurrentPage() +{ + TRACE_OBJ + Q_ASSERT(m_model->rowCount() > 1); + const QModelIndexList selectedIndexes + = m_openPagesWidget->selectionModel()->selectedRows(); + if (selectedIndexes.isEmpty()) + return; + Q_ASSERT(selectedIndexes.count() == 1); + removePage(selectedIndexes.first().row()); +} + +HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch) +{ + TRACE_OBJ + if (AbstractHelpViewer::launchWithExternalApp(url)) + return 0; + + m_model->addPage(url); + const int index = m_model->rowCount() - 1; + HelpViewer * const page = m_model->pageAt(index); + CentralWidget::instance()->addPage(page, fromSearch); + setCurrentPage(index); + return page; +} + +HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url) +{ + return createPage(url, true); +} + +void OpenPagesManager::closePage(const QModelIndex &index) +{ + if (index.isValid()) + removePage(index.row()); +} + +void OpenPagesManager::closePages(const QString &nameSpace) +{ + TRACE_OBJ + closeOrReloadPages(nameSpace, false); +} + +void OpenPagesManager::reloadPages(const QString &nameSpace) +{ + TRACE_OBJ + closeOrReloadPages(nameSpace, true); + selectCurrentPage(); +} + +void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload) +{ + TRACE_OBJ + + for (int i = m_model->rowCount() - 1; i >= 0; --i) { + HelpViewer *page = m_model->pageAt(i); + if (page->source().host() != nameSpace) + continue; + if (tryReload && HelpEngineWrapper::instance().findFile(page->source()).isValid()) + page->reload(); + else if (m_model->rowCount() == 1) + page->setSource(QUrl(QLatin1String("about:blank"))); + else + removePage(i); + } +} + +bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const +{ + TRACE_OBJ + for (int i = 0; i < m_model->rowCount(); ++i) + if (m_model->pageAt(i)->source().host() == nameSpace) + return true; + return false; +} + +void OpenPagesManager::setCurrentPage(const QModelIndex &index) +{ + TRACE_OBJ + if (!index.isValid()) + return; + HelpViewer * const page = m_model->pageAt(index.row()); + CentralWidget::instance()->setCurrentPage(page); +} + +void OpenPagesManager::setCurrentPage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->setCurrentPage(m_model->pageAt(index)); + selectCurrentPage(); +} + +void OpenPagesManager::selectCurrentPage() +{ + TRACE_OBJ + QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel(); + selModel->clearSelection(); + selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0), + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex()); +} + +void OpenPagesManager::removePage(int index) +{ + TRACE_OBJ + CentralWidget::instance()->removePage(index); + m_model->removePage(index); + selectCurrentPage(); +} + + +void OpenPagesManager::closePagesExcept(const QModelIndex &index) +{ + TRACE_OBJ + if (!index.isValid()) + return; + + int i = 0; + HelpViewer *viewer = m_model->pageAt(index.row()); + while (m_model->rowCount() > 1) { + if (m_model->pageAt(i) != viewer) + removePage(i); + else + ++i; + } +} + +QWidget *OpenPagesManager::openPagesWidget() const +{ + return m_openPagesWidget; +} + +void OpenPagesManager::nextPage() +{ + nextOrPreviousPage(1); +} + +void OpenPagesManager::previousPage() +{ + nextOrPreviousPage(-1); +} + +void OpenPagesManager::nextOrPreviousPage(int offset) +{ + setCurrentPage((CentralWidget::instance()->currentIndex() + offset + + m_model->rowCount()) % m_model->rowCount()); +} + +OpenPagesManager *OpenPagesManager::m_instance = 0; + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h index 95bf247..407ee79 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.h +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -1,104 +1,104 @@ -/**************************************************************************** -** -** 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 Assistant module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESMANAGER_H -#define OPENPAGESMANAGER_H - -#include - -QT_BEGIN_NAMESPACE - -class QModelIndex; -class QUrl; -class QWidget; - -class HelpViewer; -class OpenPagesModel; -class OpenPagesWidget; - -class OpenPagesManager : public QObject - { - Q_OBJECT - public: - static OpenPagesManager *createInstance(QObject *parent, - bool defaultCollection, const QUrl &cmdLineUrl); - static OpenPagesManager *instance(); - - bool pagesOpenForNamespace(const QString &nameSpace) const; - void closePages(const QString &nameSpace); - void reloadPages(const QString &nameSpace); - - QWidget* openPagesWidget() const; - - int pageCount() const; - - public slots: - HelpViewer *createPage(const QUrl &url, bool fromSearch = false); - HelpViewer *createNewPageFromSearch(const QUrl &url); - HelpViewer *createPage(); - void closeCurrentPage(); - void nextPage(); - void previousPage(); - -private slots: - void setCurrentPage(const QModelIndex &index); - void closePage(const QModelIndex &index); - void closePagesExcept(const QModelIndex &index); - -private: - OpenPagesManager(QObject *parent, bool defaultCollection, - const QUrl &cmdLineUrl); - void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); - void closeOrReloadPages(const QString &nameSpace, bool tryReload); - void setCurrentPage(int index); - void selectCurrentPage(); - void removePage(int index); - void nextOrPreviousPage(int offset); - - OpenPagesModel *m_model; - OpenPagesWidget *m_openPagesWidget; - - static OpenPagesManager *m_instance; - }; - -QT_END_NAMESPACE - -#endif // OPENPAGESMANAGER_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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESMANAGER_H +#define OPENPAGESMANAGER_H + +#include + +QT_BEGIN_NAMESPACE + +class QModelIndex; +class QUrl; +class QWidget; + +class HelpViewer; +class OpenPagesModel; +class OpenPagesWidget; + +class OpenPagesManager : public QObject + { + Q_OBJECT + public: + static OpenPagesManager *createInstance(QObject *parent, + bool defaultCollection, const QUrl &cmdLineUrl); + static OpenPagesManager *instance(); + + bool pagesOpenForNamespace(const QString &nameSpace) const; + void closePages(const QString &nameSpace); + void reloadPages(const QString &nameSpace); + + QWidget* openPagesWidget() const; + + int pageCount() const; + + public slots: + HelpViewer *createPage(const QUrl &url, bool fromSearch = false); + HelpViewer *createNewPageFromSearch(const QUrl &url); + HelpViewer *createPage(); + void closeCurrentPage(); + void nextPage(); + void previousPage(); + +private slots: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); + +private: + OpenPagesManager(QObject *parent, bool defaultCollection, + const QUrl &cmdLineUrl); + void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); + void closeOrReloadPages(const QString &nameSpace, bool tryReload); + void setCurrentPage(int index); + void selectCurrentPage(); + void removePage(int index); + void nextOrPreviousPage(int offset); + + OpenPagesModel *m_model; + OpenPagesWidget *m_openPagesWidget; + + static OpenPagesManager *m_instance; + }; + +QT_END_NAMESPACE + +#endif // OPENPAGESMANAGER_H diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp index 96af7b5..d702c28 100644 --- a/tools/assistant/tools/assistant/openpageswidget.cpp +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -1,196 +1,196 @@ -/**************************************************************************** -** -** 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 Assistant module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "openpageswidget.h" - -#include "openpagesmodel.h" - -#include -#include -#include -#include -#include -#include - -#ifdef Q_WS_MAC -#include -#endif - -QT_BEGIN_NAMESPACE - -OpenPagesDelegate::OpenPagesDelegate(QObject *parent) - : QStyledItemDelegate(parent) -{ -} - -void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - if (option.state & QStyle::State_MouseOver) { - if ((QApplication::mouseButtons() & Qt::LeftButton) == 0) - pressedIndex = QModelIndex(); - QBrush brush = option.palette.alternateBase(); - if (index == pressedIndex) - brush = option.palette.dark(); - painter->fillRect(option.rect, brush); - } - - QStyledItemDelegate::paint(painter, option, index); - - if (index.column() == 1 && index.model()->rowCount() > 1 - && option.state & QStyle::State_MouseOver) { - QIcon icon((option.state & QStyle::State_Selected) - ? ":/trolltech/assistant/images/closebutton.png" - : ":/trolltech/assistant/images/darkclosebutton.png"); - - const QRect iconRect(option.rect.right() - option.rect.height(), - option.rect.top(), option.rect.height(), option.rect.height()); - icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter); - } -} - - -OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) -{ - setModel(model); - setIndentation(0); - setItemDelegate((m_delegate = new OpenPagesDelegate(this))); - - setFrameStyle(QFrame::NoFrame); - setTextElideMode(Qt::ElideMiddle); - setAttribute(Qt::WA_MacShowFocusRect, false); - - viewport()->setAttribute(Qt::WA_Hover); - setSelectionBehavior(QAbstractItemView::SelectRows); - setSelectionMode(QAbstractItemView::SingleSelection); - - header()->hide(); - header()->setStretchLastSection(false); - header()->setResizeMode(0, QHeaderView::Stretch); - header()->setResizeMode(1, QHeaderView::Fixed); - header()->resizeSection(1, 18); - - installEventFilter(this); - setUniformRowHeights(true); - setContextMenuPolicy(Qt::CustomContextMenu); - - connect(this, SIGNAL(clicked(QModelIndex)), this, - SLOT(handleClicked(QModelIndex))); - connect(this, SIGNAL(pressed(QModelIndex)), this, - SLOT(handlePressed(QModelIndex))); - connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(contextMenuRequested(QPoint))); -} - -OpenPagesWidget::~OpenPagesWidget() -{ -} - -void OpenPagesWidget::contextMenuRequested(QPoint pos) -{ - QModelIndex index = indexAt(pos); - if (!index.isValid()) - return; - - if (index.column() == 1) - index = index.sibling(index.row(), 0); - QMenu contextMenu; - QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data() - .toString())); - QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1") - .arg(index.data().toString())); - - if (model()->rowCount() == 1) { - closeEditor->setEnabled(false); - closeOtherEditors->setEnabled(false); - } - - QAction *action = contextMenu.exec(mapToGlobal(pos)); - if (action == closeEditor) - emit closePage(index); - else if (action == closeOtherEditors) - emit closePagesExcept(index); -} - -void OpenPagesWidget::handlePressed(const QModelIndex &index) -{ - if (index.column() == 0) - emit setCurrentPage(index); - - if (index.column() == 1) - m_delegate->pressedIndex = index; -} - -void OpenPagesWidget::handleClicked(const QModelIndex &index) -{ - // implemented here to handle the funky close button and to work around a - // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver - if (index.column() == 1) { - if (model()->rowCount() > 1) - emit closePage(index); - - QWidget *vp = viewport(); - const QPoint &cursorPos = QCursor::pos(); - QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, - Qt::NoButton, 0, 0); - QCoreApplication::sendEvent(vp, &e); - } -} - -bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == this && event->type() == QEvent::KeyPress) { - if (currentIndex().isValid()) { - QKeyEvent *ke = static_cast(event); - const int key = ke->key(); - if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) - && ke->modifiers() == 0) { - emit setCurrentPage(currentIndex()); - } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace) - && ke->modifiers() == 0 && model()->rowCount() > 1) { - emit closePage(currentIndex()); - } - } - } - return QWidget::eventFilter(obj, event); -} - -QT_END_NAMESPACE +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "openpageswidget.h" + +#include "openpagesmodel.h" + +#include +#include +#include +#include +#include +#include + +#ifdef Q_WS_MAC +#include +#endif + +QT_BEGIN_NAMESPACE + +OpenPagesDelegate::OpenPagesDelegate(QObject *parent) + : QStyledItemDelegate(parent) +{ +} + +void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + if (option.state & QStyle::State_MouseOver) { + if ((QApplication::mouseButtons() & Qt::LeftButton) == 0) + pressedIndex = QModelIndex(); + QBrush brush = option.palette.alternateBase(); + if (index == pressedIndex) + brush = option.palette.dark(); + painter->fillRect(option.rect, brush); + } + + QStyledItemDelegate::paint(painter, option, index); + + if (index.column() == 1 && index.model()->rowCount() > 1 + && option.state & QStyle::State_MouseOver) { + QIcon icon((option.state & QStyle::State_Selected) + ? ":/trolltech/assistant/images/closebutton.png" + : ":/trolltech/assistant/images/darkclosebutton.png"); + + const QRect iconRect(option.rect.right() - option.rect.height(), + option.rect.top(), option.rect.height(), option.rect.height()); + icon.paint(painter, iconRect, Qt::AlignRight | Qt::AlignVCenter); + } +} + + +OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) +{ + setModel(model); + setIndentation(0); + setItemDelegate((m_delegate = new OpenPagesDelegate(this))); + + setFrameStyle(QFrame::NoFrame); + setTextElideMode(Qt::ElideMiddle); + setAttribute(Qt::WA_MacShowFocusRect, false); + + viewport()->setAttribute(Qt::WA_Hover); + setSelectionBehavior(QAbstractItemView::SelectRows); + setSelectionMode(QAbstractItemView::SingleSelection); + + header()->hide(); + header()->setStretchLastSection(false); + header()->setResizeMode(0, QHeaderView::Stretch); + header()->setResizeMode(1, QHeaderView::Fixed); + header()->resizeSection(1, 18); + + installEventFilter(this); + setUniformRowHeights(true); + setContextMenuPolicy(Qt::CustomContextMenu); + + connect(this, SIGNAL(clicked(QModelIndex)), this, + SLOT(handleClicked(QModelIndex))); + connect(this, SIGNAL(pressed(QModelIndex)), this, + SLOT(handlePressed(QModelIndex))); + connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, + SLOT(contextMenuRequested(QPoint))); +} + +OpenPagesWidget::~OpenPagesWidget() +{ +} + +void OpenPagesWidget::contextMenuRequested(QPoint pos) +{ + QModelIndex index = indexAt(pos); + if (!index.isValid()) + return; + + if (index.column() == 1) + index = index.sibling(index.row(), 0); + QMenu contextMenu; + QAction *closeEditor = contextMenu.addAction(tr("Close %1").arg(index.data() + .toString())); + QAction *closeOtherEditors = contextMenu.addAction(tr("Close All Except %1") + .arg(index.data().toString())); + + if (model()->rowCount() == 1) { + closeEditor->setEnabled(false); + closeOtherEditors->setEnabled(false); + } + + QAction *action = contextMenu.exec(mapToGlobal(pos)); + if (action == closeEditor) + emit closePage(index); + else if (action == closeOtherEditors) + emit closePagesExcept(index); +} + +void OpenPagesWidget::handlePressed(const QModelIndex &index) +{ + if (index.column() == 0) + emit setCurrentPage(index); + + if (index.column() == 1) + m_delegate->pressedIndex = index; +} + +void OpenPagesWidget::handleClicked(const QModelIndex &index) +{ + // implemented here to handle the funky close button and to work around a + // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver + if (index.column() == 1) { + if (model()->rowCount() > 1) + emit closePage(index); + + QWidget *vp = viewport(); + const QPoint &cursorPos = QCursor::pos(); + QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, + Qt::NoButton, 0, 0); + QCoreApplication::sendEvent(vp, &e); + } +} + +bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == this && event->type() == QEvent::KeyPress) { + if (currentIndex().isValid()) { + QKeyEvent *ke = static_cast(event); + const int key = ke->key(); + if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) + && ke->modifiers() == 0) { + emit setCurrentPage(currentIndex()); + } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace) + && ke->modifiers() == 0 && model()->rowCount() > 1) { + emit closePage(currentIndex()); + } + } + } + return QWidget::eventFilter(obj, event); +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h index 511735e..46c0022 100644 --- a/tools/assistant/tools/assistant/openpageswidget.h +++ b/tools/assistant/tools/assistant/openpageswidget.h @@ -1,88 +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 Assistant module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESWIDGET_H -#define OPENPAGESWIDGET_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class OpenPagesModel; - -class OpenPagesDelegate : public QStyledItemDelegate -{ - Q_OBJECT -public: - explicit OpenPagesDelegate(QObject *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - - mutable QModelIndex pressedIndex; -}; - -class OpenPagesWidget : public QTreeView -{ - Q_OBJECT -public: - OpenPagesWidget(OpenPagesModel *model); - ~OpenPagesWidget(); - -signals: - void setCurrentPage(const QModelIndex &index); - void closePage(const QModelIndex &index); - void closePagesExcept(const QModelIndex &index); - -private slots: - void contextMenuRequested(QPoint pos); - void handlePressed(const QModelIndex &index); - void handleClicked(const QModelIndex &index); - -private: - bool eventFilter(QObject *obj, QEvent *event); - - OpenPagesDelegate *m_delegate; -}; - -QT_END_NAMESPACE - -#endif // OPENPAGESWIDGET_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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESWIDGET_H +#define OPENPAGESWIDGET_H + +#include +#include + +QT_BEGIN_NAMESPACE + +class OpenPagesModel; + +class OpenPagesDelegate : public QStyledItemDelegate +{ + Q_OBJECT +public: + explicit OpenPagesDelegate(QObject *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + mutable QModelIndex pressedIndex; +}; + +class OpenPagesWidget : public QTreeView +{ + Q_OBJECT +public: + OpenPagesWidget(OpenPagesModel *model); + ~OpenPagesWidget(); + +signals: + void setCurrentPage(const QModelIndex &index); + void closePage(const QModelIndex &index); + void closePagesExcept(const QModelIndex &index); + +private slots: + void contextMenuRequested(QPoint pos); + void handlePressed(const QModelIndex &index); + void handleClicked(const QModelIndex &index); + +private: + bool eventFilter(QObject *obj, QEvent *event); + + OpenPagesDelegate *m_delegate; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESWIDGET_H -- cgit v0.12 From 2d1199ea9dafe31221f928a9e866893db180d1bf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 27 Apr 2010 11:20:07 +0200 Subject: tst_networkselftest: fix building on Windows --- tests/auto/networkselftest/tst_networkselftest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/networkselftest/tst_networkselftest.cpp b/tests/auto/networkselftest/tst_networkselftest.cpp index d25fcb6..ecbc08c 100644 --- a/tests/auto/networkselftest/tst_networkselftest.cpp +++ b/tests/auto/networkselftest/tst_networkselftest.cpp @@ -965,11 +965,11 @@ void tst_NetworkSelfTest::smbServer() QVERIFY2(f, qt_error_string().toLocal8Bit()); char buf[128]; - ssize_t ret = fread(buf, sizeof buf, 1, f); + size_t ret = fread(buf, sizeof buf, 1, f); fclose(f); QCOMPARE(ret, strlen(contents)); - QVERIFY(memcmp(ret, contents, strlen(contents)) == 0); + QVERIFY(memcmp(buf, contents, strlen(contents)) == 0); #else // try to use Samba QString progname = "smbclient"; -- cgit v0.12 From 0bb78b7a6e6c8d539cc4c69e4703c62cbe176bc6 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Tue, 27 Apr 2010 10:19:04 +0200 Subject: Repositioned _WIN32_WINNT define in tst_qfileinfo and tst_qdir This define is needed to make sure that some structures used for creating junctions and symlinks get properly defined in winioctl.h. Reviewed-by: TrustMe --- tests/auto/qdir/tst_qdir.cpp | 5 +++++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index c8c835f..71469bb 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -49,6 +49,11 @@ #include #include #include "../network-settings.h" + +#if defined(Q_OS_WIN) +#define _WIN32_WINNT 0x500 +#endif + #include "../../shared/filesystem.h" #if defined(Q_OS_SYMBIAN) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 5612999..ca8c1c9 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -39,9 +39,6 @@ ** ****************************************************************************/ -#ifdef Q_OS_WIN -#define _WIN32_WINNT 0x500 -#endif #include @@ -58,6 +55,7 @@ #include #endif #ifdef Q_OS_WIN +#define _WIN32_WINNT 0x500 #include #include #endif -- cgit v0.12 From 72590485ab9bbc0c689df535cb0658b5d0d63288 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Tue, 27 Apr 2010 15:02:50 +0200 Subject: Remove legacy macros. Task-number: QTBUG-8434 Reviewed-by: Morten Sorvig --- src/gui/kernel/qmacdefines_mac.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/gui/kernel/qmacdefines_mac.h b/src/gui/kernel/qmacdefines_mac.h index d767470..d190d23 100644 --- a/src/gui/kernel/qmacdefines_mac.h +++ b/src/gui/kernel/qmacdefines_mac.h @@ -94,12 +94,6 @@ Yes, it is an informative comment ;-) #include -#undef OLD_DEBUG -#ifdef DEBUG -# define OLD_DEBUG DEBUG -# undef DEBUG -#endif -#define DEBUG 0 #ifdef qDebug # define old_qDebug qDebug # undef qDebug @@ -179,12 +173,6 @@ typedef AERecord AppleEvent; #undef check #endif -#undef DEBUG -#ifdef OLD_DEBUG -# define DEBUG OLD_DEBUG -# undef OLD_DEBUG -#endif - #ifdef old_qDebug # undef qDebug # define qDebug QT_NO_QDEBUG_MACRO -- cgit v0.12 From f1ee96c635443f4aff2cf57dbadec529ca06d332 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 27 Apr 2010 17:34:21 +0200 Subject: Unable to load plugin DLLs compiled with the '/clr' option Before loading the plugins, to make sure we are loading a valid one, we call qt_plugin_query_verification_data() and verify the version information. The DLLS built with '/clr' compiler flag, needs full initialization before a function can be called. With a prior patch, as an optimaization we had changed LoadLibrary() to LoadLibraryEx(), this will not initialize or load the dependencies, so it crashed when calling that function. Now this exception is caught and LoadLibrary(equivalent) is called. Task-number: QTBUG-10012 Reviewed-by: Jan-Arve --- src/corelib/plugin/qlibrary.cpp | 140 +++++++++++++++++++++++++++------------- 1 file changed, 96 insertions(+), 44 deletions(-) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 0f99948..2ed113d 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -609,6 +609,46 @@ bool QLibrary::isLibrary(const QString &fileName) } +#if defined (Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_CC_INTEL) +#define QT_USE_MS_STD_EXCEPTION 1 +const char* qt_try_versioninfo(void *pfn, bool *exceptionThrown) +{ + *exceptionThrown = false; + const char *szData = 0; + typedef const char * (*VerificationFunction)(); + VerificationFunction func = reinterpret_cast(pfn); + __try { + if(func) + szData = func(); + } __except(EXCEPTION_EXECUTE_HANDLER) { + *exceptionThrown = true; + } + return szData; +} +#endif + +#ifdef Q_CC_BOR +typedef const char * __stdcall (*QtPluginQueryVerificationDataFunction)(); +#else +typedef const char * (*QtPluginQueryVerificationDataFunction)(); +#endif + +bool qt_get_verificationdata(QtPluginQueryVerificationDataFunction pfn, uint *qt_version, bool *debug, QByteArray *key, bool *exceptionThrown) +{ + *exceptionThrown = false; + const char *szData = 0; + if (!pfn) + return false; +#ifdef QT_USE_MS_STD_EXCEPTION + szData = qt_try_versioninfo((void *)pfn, exceptionThrown); + if (*exceptionThrown) + return false; +#else + szData = pfn(); +#endif + return qt_parse_pattern(szData, qt_version, debug, key); +} + bool QLibraryPrivate::isPlugin(QSettings *settings) { errorString.clear(); @@ -684,70 +724,82 @@ bool QLibraryPrivate::isPlugin(QSettings *settings) } else #endif { - bool temporary_load = false; + bool retryLoadLibrary = false; // Only used on Windows with MS compiler.(false in other cases) + do { + bool temporary_load = false; #ifdef Q_OS_WIN - HMODULE hTempModule = 0; + HMODULE hTempModule = 0; #endif - if (!pHnd) { + if (!pHnd) { #ifdef Q_OS_WIN - //avoid 'Bad Image' message box - UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); - hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, DONT_RESOLVE_DLL_REFERENCES); - SetErrorMode(oldmode); + DWORD dwFlags = (retryLoadLibrary) ? 0: DONT_RESOLVE_DLL_REFERENCES; + //avoid 'Bad Image' message box + UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX); + hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, dwFlags); + SetErrorMode(oldmode); #else # if defined(Q_OS_SYMBIAN) - //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists - if (fileinfo.exists()) + //Guard against accidentally trying to load non-plugin libraries by making sure the stub exists + if (fileinfo.exists()) # endif - temporary_load = load_sys(); + temporary_load = load_sys(); #endif - } -# ifdef Q_CC_BOR - typedef const char * __stdcall (*QtPluginQueryVerificationDataFunction)(); -# else - typedef const char * (*QtPluginQueryVerificationDataFunction)(); -# endif + } #ifdef Q_OS_WIN - QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule - ? (QtPluginQueryVerificationDataFunction) + QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = hTempModule ? (QtPluginQueryVerificationDataFunction) #ifdef Q_OS_WINCE - ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data") + ::GetProcAddress(hTempModule, L"qt_plugin_query_verification_data") #else - ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data") + ::GetProcAddress(hTempModule, "qt_plugin_query_verification_data") #endif : (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); #else - QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL; + QtPluginQueryVerificationDataFunction qtPluginQueryVerificationDataFunction = NULL; # if defined(Q_OS_SYMBIAN) - if (temporary_load) { - qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); - // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal - if (!qtPluginQueryVerificationDataFunction) - qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1"); - } + if (temporary_load) { + qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); + // If resolving with function name failed (i.e. not STDDLL), try resolving using known ordinal + if (!qtPluginQueryVerificationDataFunction) + qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("1"); + } # else - qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); + qtPluginQueryVerificationDataFunction = (QtPluginQueryVerificationDataFunction) resolve("qt_plugin_query_verification_data"); # endif #endif - - if (!qtPluginQueryVerificationDataFunction - || !qt_parse_pattern(qtPluginQueryVerificationDataFunction(), &qt_version, &debug, &key)) { - qt_version = 0; - key = "unknown"; - if (temporary_load) - unload_sys(); - } else { - success = true; - } -#ifdef Q_OS_WIN - if (hTempModule) { - BOOL ok = ::FreeLibrary(hTempModule); - if (ok) { - hTempModule = 0; + bool exceptionThrown = false; + bool ret = qt_get_verificationdata(qtPluginQueryVerificationDataFunction, + &qt_version, &debug, &key, &exceptionThrown); + if (!exceptionThrown) { + if (!ret) { + qt_version = 0; + key = "unknown"; + if (temporary_load) + unload_sys(); + } else { + success = true; + } + retryLoadLibrary = false; + } +#ifdef QT_USE_MS_STD_EXCEPTION + else { + // An exception was thrown when calling qt_plugin_query_verification_data(). + // This usually happens when plugin is compiled with the /clr compiler flag, + // & will only work if the dependencies are loaded & DLLMain() is called. + // LoadLibrary() will do this, try once with this & if it fails dont load. + retryLoadLibrary = !retryLoadLibrary; } +#endif +#ifdef Q_OS_WIN + if (hTempModule) { + BOOL ok = ::FreeLibrary(hTempModule); + if (ok) { + hTempModule = 0; + } - } + } #endif + } while(retryLoadLibrary); // Will be 'false' in all cases other than when an + // exception is thrown(will happen only when using a MS compiler) } // Qt 4.5 compatibility: stl doesn't affect binary compatibility -- cgit v0.12 From e2e48651d4ab5941a5358d213579fbe7490b1f2a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 27 Apr 2010 18:05:54 +0200 Subject: Fix configure for versions of mingw (including 64 bit) Task-number: QTBUG-10235 --- tools/configure/configureapp.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 687f8a1..2fe2da2 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1880,6 +1880,22 @@ QString Configure::findFileInPaths(const QString &fileName, const QString &paths return QString(); } +static QString mingwPaths(const QString &mingwPath, const QString &pathName) +{ + QString ret; + QDir mingwDir = QFileInfo(mingwPath).dir(); + const QFileInfoList subdirs = mingwDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (int i = 0 ;i < subdirs.length(); ++i) { + const QFileInfo &fi = subdirs.at(i); + const QString name = fi.fileName(); + if (name == pathName) + ret += fi.absoluteFilePath() + ';'; + else if (name.contains("mingw")) + ret += fi.absoluteFilePath() + QDir::separator() + pathName + ';'; + } + return ret; +} + bool Configure::findFile( const QString &fileName ) { const QString file = fileName.toLower(); @@ -1890,18 +1906,22 @@ bool Configure::findFile( const QString &fileName ) QString paths; if (file.endsWith(".h")) { if (!mingwPath.isNull()) { - if (!findFileInPaths(file, mingwPath + QLatin1String("/../include")).isNull()) + if (!findFileInPaths(file, mingwPaths(mingwPath, "include")).isNull()) return true; //now let's try the additional compiler path - QDir mingwLibDir = mingwPath + QLatin1String("/../lib/gcc/mingw32"); - foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { - if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull()) - return true; + + const QFileInfoList mingwConfigs = QDir(mingwPath + QLatin1String("/../lib/gcc")).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (int i = 0; i < mingwConfigs.length(); ++i) { + const QDir mingwLibDir = mingwConfigs.at(i).absoluteFilePath(); + foreach(const QFileInfo &version, mingwLibDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) { + if (!findFileInPaths(file, version.absoluteFilePath() + QLatin1String("/include")).isNull()) + return true; + } } } paths = QString::fromLocal8Bit(getenv("INCLUDE")); } else if ( file.endsWith( ".lib" ) || file.endsWith( ".a" ) ) { - if (!mingwPath.isNull() && !findFileInPaths(file, mingwPath + QLatin1String("/../lib")).isNull()) + if (!mingwPath.isNull() && !findFileInPaths(file, mingwPaths(mingwPath, "lib")).isNull()) return true; paths = QString::fromLocal8Bit(getenv("LIB")); } else { -- cgit v0.12 From 1d0cfb6e5b1cc612ba3baed3b39159739d60f130 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Wed, 28 Apr 2010 00:58:23 +0200 Subject: Fix a small typo in setColor description (brush -> color) --- src/gui/kernel/qpalette.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 6e8c90e..98e8f66 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -795,7 +795,7 @@ const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const /*! \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color) - Sets the brush in the specified color \a group, used for the given + Sets the color in the specified color \a group, used for the given color \a role, to the specified solid \a color. \sa setBrush() color() ColorRole -- cgit v0.12 From 5d033928fc94e04cb4d7746dae2269f2be753925 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 26 Apr 2010 17:41:47 +0200 Subject: Fix tab stop in QPainter::drawText() Even though we'd set the local tabstops variable to eight times the width of 'x', we'd never use this value anywhere, causing the text layout to use a default value of 80. This looked okay with some font sizes, but since it did not depend on the size of font, the tab in a large font would be too small and potentially the same size or smaller than a single character/space. We enable setting the tabstops on the layout whenever it hasn't been explicitly set on the QTextOption. Task-number: QTBUG-1638 Reviewed-by: Trond --- src/gui/painting/qpainter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 898a996..fbeb6e6 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7906,6 +7906,9 @@ start_lengthVariant: engine.option = *option; } + if (engine.option.tabStop() < 0 && tabstops > 0) + engine.option.setTabStop(tabstops); + engine.option.setTextDirection(layout_direction); if (tf & Qt::AlignJustify) engine.option.setAlignment(Qt::AlignJustify); -- cgit v0.12 From 89db625958949cf94f112fc2f9e6a3bf6399e43b Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 28 Apr 2010 11:06:15 +0200 Subject: QTabBar: smaller minimumSizeHint in ElideMode, and unit-test. When a tabbar had a large number of tabs with short text (5 to 7 characters), no eliding would happen, the window would keep growing until it became wider than the desktop. This commit therefore reduces the minimumSizeHint using more aggressive eliding when eliding is enabled. Also, at some point I had doubts about whether minimumSizeHint took eliding into consideration at all, so I also added a unit-test for minimumSizeHint and sizeHint of tabbars, in various modes. Merge-request: 583 Reviewed-by: Olivier Goffart --- src/gui/widgets/qtabbar.cpp | 13 ++++++++----- tests/auto/qtabbar/tst_qtabbar.cpp | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 7559311..7095ca9 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1240,6 +1240,8 @@ QSize QTabBar::sizeHint() const QSize QTabBar::minimumSizeHint() const { Q_D(const QTabBar); + if (d->layoutDirty) + const_cast(d)->layoutTabs(); if (!d->useScrollButtons) { QRect r; for (int i = 0; i < d->tabList.count(); ++i) @@ -1252,22 +1254,23 @@ QSize QTabBar::minimumSizeHint() const return QSize(d->rightB->sizeHint().width() * 2 + 75, sizeHint().height()); } +// Compute the most-elided possible text, for minimumSizeHint static QString computeElidedText(Qt::TextElideMode mode, const QString &text) { - if (text.length() <= 7) + if (text.length() <= 3) return text; static const QLatin1String Ellipses("..."); QString ret; switch (mode) { case Qt::ElideRight: - ret = text.left(4) + Ellipses; + ret = text.left(2) + Ellipses; break; case Qt::ElideMiddle: - ret = text.left(2) + Ellipses + text.right(2); + ret = text.left(1) + Ellipses + text.right(1); break; case Qt::ElideLeft: - ret = Ellipses + text.right(4); + ret = Ellipses + text.right(2); break; case Qt::ElideNone: ret = text; @@ -1914,7 +1917,7 @@ void QTabBar::keyPressEvent(QKeyEvent *event) event->ignore(); return; } - int offset = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1; + int offset = event->key() == (isRightToLeft() ? Qt::Key_Right : Qt::Key_Left) ? -1 : 1; d->setCurrentNextEnabledIndex(offset); } diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp index 72f9dd3..28bed6b 100644 --- a/tests/auto/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/qtabbar/tst_qtabbar.cpp @@ -76,6 +76,7 @@ private slots: void setElideMode_data(); void setElideMode(); + void sizeHints(); void setUsesScrollButtons_data(); void setUsesScrollButtons(); @@ -278,6 +279,45 @@ void tst_QTabBar::setElideMode() QTEST(int(tabBar.elideMode()), "expectedMode"); } +void tst_QTabBar::sizeHints() +{ + QTabBar tabBar; + tabBar.setFont(QFont("Arial", 10)); + tabBar.addTab("tab 01"); + tabBar.addTab("tab 02"); + tabBar.addTab("tab 03"); + tabBar.addTab("tab 04"); + tabBar.addTab("tab 05"); + tabBar.addTab("tab 06"); + tabBar.addTab("This is tab7"); + tabBar.addTab("This is tab8"); + tabBar.addTab("This is tab9 with a very long title"); + + // No eliding and no scrolling -> tabbar becomes very wide + tabBar.setUsesScrollButtons(false); + tabBar.setElideMode(Qt::ElideNone); +// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); + QVERIFY(tabBar.minimumSizeHint().width() > 700); + QVERIFY(tabBar.sizeHint().width() > 700); + + // Scrolling enabled -> no reason to become very wide + tabBar.setUsesScrollButtons(true); + // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); + QVERIFY(tabBar.minimumSizeHint().width() < 200); + QVERIFY(tabBar.sizeHint().width() > 700); // unchanged + + // Eliding enabled -> no reason to become very wide + tabBar.setUsesScrollButtons(false); + tabBar.setElideMode(Qt::ElideRight); +// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); + QVERIFY(tabBar.minimumSizeHint().width() < 500); + QVERIFY(tabBar.sizeHint().width() > 700); // unchanged + + tabBar.addTab("This is tab10 with a very long title"); + QVERIFY(tabBar.minimumSizeHint().width() < 600); + QVERIFY(tabBar.sizeHint().width() > 700); // unchanged +} + void tst_QTabBar::setUsesScrollButtons_data() { QTest::addColumn("usesArrows"); -- cgit v0.12 From eb4a3bbf2a780f87105c09d354adde04b0bf6ad8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 28 Apr 2010 11:13:38 +0200 Subject: Update changelog after last change. Document the change introduced by the merge request 583 (89db625958949cf94f112fc2f9e6a3bf6399e43b) --- dist/changes-4.8.0 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 39ea604..27bb885 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -40,6 +40,8 @@ QtCore QtGui ----- + - QTabBar: reduced minimumSizeHint if ElideMode is set. + **************************************************************************** * Database Drivers * -- 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 498786a2ab27680b27f8e57b422ff8f32f0c3790 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 28 Apr 2010 17:20:18 +0200 Subject: Temporarily disable tests that use createNtfsJunction() This function uses to/fromWCharArray() which uses wchar_t pointer in its signature. This currently makes the CI system complain about unresolved symbols when using vs2005. Reviewed-by: TrustMe --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 ++ tests/shared/filesystem.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index ca8c1c9..ddc8aeb 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1307,6 +1307,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalFilePath(); } +#if 0 //Junctions QString target = "target"; QString junction = "junction_pwd"; @@ -1342,6 +1343,7 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() FileSystem::createNtfsJunction(rootVolume, junction); QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); } +#endif } void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index 079a6dc..dad4ef8c 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -95,6 +95,8 @@ struct FileSystem } return false; } + +#if 0 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) static void createNtfsJunction(QString target, QString linkName) { @@ -148,6 +150,7 @@ struct FileSystem QVERIFY(ioc); } #endif +#endif private: QDir currentDir; -- cgit v0.12 From cbdd0bfe63beed9e0a4596e6d9e5b0be1ea9eb46 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 29 Apr 2010 15:08:45 +0200 Subject: Skip failing auto-test on Mac and Linux QWS To be fixed later. Update to commit 89db625958949cf94f112fc2f9e6a3bf6399e43b. Reviewed-by: Olivier --- tests/auto/qtabbar/tst_qtabbar.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qtabbar/tst_qtabbar.cpp b/tests/auto/qtabbar/tst_qtabbar.cpp index 5819c3c..84a6991 100644 --- a/tests/auto/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/qtabbar/tst_qtabbar.cpp @@ -284,6 +284,7 @@ void tst_QTabBar::setElideMode() void tst_QTabBar::sizeHints() { QTabBar tabBar; + QSKIP("To be fixed on Mac (font size below not large enough) and Linux QWS (probably too large for the screen).", SkipSingle); tabBar.setFont(QFont("Arial", 10)); tabBar.addTab("tab 01"); tabBar.addTab("tab 02"); -- 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 20143e765b627ba2f8ab77ea9b842dd1549f19f3 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Thu, 29 Apr 2010 16:25:20 +0200 Subject: Fix conversion between QVariant and QScriptValue. Function converting from QVariant to QScriptValue is smart and tries to unwrap a value. So QVariant(1234) after conversion will be equal to QScriptValue(1234). It is ok, but QVariant(QVariant(...)) should be unpacked only once. Reviewed-by: Kent Hansen Task-number: QTBUG-10315 --- src/script/api/qscriptengine.cpp | 2 +- tests/auto/qscriptengine/tst_qscriptengine.cpp | 32 ++++++++++++++++++++++ .../qscriptextqobject/tst_qscriptextqobject.cpp | 22 ++++++++++++--- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 03d535c..014889b 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2983,7 +2983,7 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const break; #endif case QMetaType::QVariant: - result = jscValueFromVariant(exec, *reinterpret_cast(ptr)); + result = eng->newVariant(*reinterpret_cast(ptr)); break; default: if (type == qMetaTypeId()) { diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 89ea1db..5501755 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -2059,6 +2059,38 @@ void tst_QScriptEngine::valueConversion() QVERIFY(!val.isVariant()); QVERIFY(val.isUndefined()); } + // Checking nested QVariants + { + QVariant tmp1; + QVariant tmp2(QMetaType::QVariant, &tmp1); + QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); + + QScriptValue val1 = qScriptValueFromValue(&eng, tmp1); + QScriptValue val2 = qScriptValueFromValue(&eng, tmp2); + QVERIFY(val1.isValid()); + QVERIFY(val2.isValid()); + QVERIFY(val1.isUndefined()); + QVERIFY(!val2.isUndefined()); + QVERIFY(!val1.isVariant()); + QVERIFY(val2.isVariant()); + } + { + QVariant tmp1(123); + QVariant tmp2(QMetaType::QVariant, &tmp1); + QVariant tmp3(QMetaType::QVariant, &tmp2); + QVERIFY(QMetaType::Type(tmp1.type()) == QMetaType::Int); + QVERIFY(QMetaType::Type(tmp2.type()) == QMetaType::QVariant); + QVERIFY(QMetaType::Type(tmp3.type()) == QMetaType::QVariant); + + QScriptValue val1 = qScriptValueFromValue(&eng, tmp2); + QScriptValue val2 = qScriptValueFromValue(&eng, tmp3); + QVERIFY(val1.isValid()); + QVERIFY(val2.isValid()); + QVERIFY(val1.isVariant()); + QVERIFY(val2.isVariant()); + QVERIFY(val1.toVariant().toInt() == 123); + QVERIFY(qScriptValueFromValue(&eng, val2.toVariant()).toVariant().toInt() == 123); + } { QScriptValue val = qScriptValueFromValue(&eng, QVariant(true)); QVERIFY(!val.isVariant()); diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 09070e6..fe83861 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -1664,6 +1664,7 @@ void tst_QScriptExtQObject::connectAndDisconnect() m_myObject->emitMySignalWithVariantArg(123); QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QVERIFY(m_engine->evaluate("signalArgs[0]").isNumber()); QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0); QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined()); @@ -1679,16 +1680,29 @@ void tst_QScriptExtQObject::connectAndDisconnect() QVERIFY(m_engine->evaluate("signalArgs[0]").isUndefined()); QVERIFY(m_engine->evaluate("myObject.mySignalWithScriptEngineArg.disconnect(myHandler)").isUndefined()); - // signal with QVariant arg: argument conversion should work + // signal with QVariant arg: QVariant should be unwrapped only once m_myObject->clearConnectedSignal(); QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.connect(myHandler)").isUndefined()); QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithVariantArg(QVariant))); m_engine->evaluate("gotSignal = false"); - m_myObject->emitMySignalWithVariantArg(123); + QVariant tmp(123); + QVariant signalArg(QMetaType::QVariant, &tmp); + m_myObject->emitMySignalWithVariantArg(signalArg); QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); - QVERIFY(m_engine->evaluate("signalArgs[0]").isNumber()); - QCOMPARE(m_engine->evaluate("signalArgs[0]").toNumber(), 123.0); + QVERIFY(m_engine->evaluate("signalArgs[0]").isVariant()); + QCOMPARE(m_engine->evaluate("signalArgs[0]").toVariant().toDouble(), 123.0); + QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined()); + + // signal with QVariant arg: with an invalid QVariant + m_myObject->clearConnectedSignal(); + QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.connect(myHandler)").isUndefined()); + QCOMPARE(m_myObject->connectedSignal().constData(), SIGNAL(mySignalWithVariantArg(QVariant))); + m_engine->evaluate("gotSignal = false"); + m_myObject->emitMySignalWithVariantArg(QVariant()); + QCOMPARE(m_engine->evaluate("gotSignal").toBoolean(), true); + QCOMPARE(m_engine->evaluate("signalArgs.length").toNumber(), 1.0); + QVERIFY(m_engine->evaluate("signalArgs[0]").isUndefined()); QVERIFY(m_engine->evaluate("myObject.mySignalWithVariantArg.disconnect(myHandler)").isUndefined()); // signal with argument type that's unknown to the meta-type system -- 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 9c56dc1a2540a3bd6215d1165827f619c84a0b34 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Tue, 27 Apr 2010 06:12:47 +0400 Subject: avoid infinite recursion in canonicalized() if cwd is a symlink if current directory is a symlink to another directory on the same drive (the simplest example; say, c:\current\dir is a symlink to c:\target) then the first valid prefix for "c:\target" in canonicalized() is "c:" (NOT "c:\") and would be treated like "c:\current\dir" again...and again... until stack overflow :) Merge-Request: 494 Task-number: QTBUG-7610 Reviewed-by: Zeno Albisser --- src/corelib/io/qfsfileengine.cpp | 12 +++++++++--- tests/auto/qfileinfo/tst_qfileinfo.cpp | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 3cf08a7..511a1a6 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -189,9 +189,15 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) known.insert(path); do { #ifdef Q_OS_WIN - // UNC, skip past the first two elements - if (separatorPos == 0 && tmpPath.startsWith(QLatin1String("//"))) - separatorPos = tmpPath.indexOf(slash, 2); + if (separatorPos == 0) { + if (tmpPath.size() >= 2 && tmpPath.at(0) == slash && tmpPath.at(1) == slash) { + // UNC, skip past the first two elements + separatorPos = tmpPath.indexOf(slash, 2); + } else if (tmpPath.size() >= 3 && tmpPath.at(1) == QLatin1Char(':') && tmpPath.at(2) == slash) { + // volume root, skip since it can not be a symlink + separatorPos = 2; + } + } if (separatorPos != -1) #endif separatorPos = tmpPath.indexOf(slash, separatorPos + 1); diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index ddc8aeb..83b650a 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -589,6 +590,25 @@ void tst_QFileInfo::canonicalFilePath() } # endif #endif + +#ifdef Q_OS_WIN + typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD); + PtrCreateSymbolicLink ptrCreateSymbolicLink = + (PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLink"); + + if (!ptrCreateSymbolicLink || + ptrCreateSymbolicLink((wchar_t*)QString("res").utf16(), (wchar_t*)QString("resources").utf16(), 1) == 0) { + QSKIP("Symbolic links aren't supported by FS", SkipAll); + } + + QString currentPath = QDir::currentPath(); + QCOMPARE(QDir::setCurrent("res"), true); + + QCOMPARE(QFileInfo("file1").canonicalFilePath(), currentPath + "/resources/file1"); + + QCOMPARE(QDir::setCurrent(currentPath), true); + QFile::remove("res"); +#endif } void tst_QFileInfo::fileName_data() -- cgit v0.12 From 9c419f945f1644e1bb66f4b5216a3d3adddb75b9 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Thu, 29 Apr 2010 16:56:12 +0200 Subject: Fix to allow upper- and lowercase .dll suffix on windows This fix is needed since windows uses case insensitive filesystems. Reviewed-by: Joao Task-number: QTBUG-10305 --- src/corelib/plugin/qlibrary.cpp | 4 ++-- tests/auto/qlibrary/tst_qlibrary.cpp | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 2ed113d..ccde2b0 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -534,7 +534,7 @@ bool QLibraryPrivate::loadPlugin() \table \header \i Platform \i Valid suffixes - \row \i Windows \i \c .dll + \row \i Windows \i \c .dll, \c .DLL \row \i Unix/Linux \i \c .so \row \i AIX \i \c .a \row \i HP-UX \i \c .sl, \c .so (HP-UXi) @@ -547,7 +547,7 @@ bool QLibraryPrivate::loadPlugin() bool QLibrary::isLibrary(const QString &fileName) { #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) - return fileName.endsWith(QLatin1String(".dll")); + return fileName.endsWith(QLatin1String(".dll"), Qt::CaseInsensitive); #elif defined(Q_OS_SYMBIAN) // Plugin stubs are also considered libraries in Symbian. return (fileName.endsWith(QLatin1String(".dll")) || diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index d4884db..3d26e0b 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -53,6 +53,7 @@ #define a_VALID false #define so_VALID false #define dll_VALID false +#define DLL_VALID false #if defined(Q_OS_DARWIN) # undef bundle_VALID @@ -88,6 +89,8 @@ #elif defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) # undef dll_VALID # define dll_VALID true +# undef DLL_VALID +# define DLL_VALID true # define SUFFIX ".dll" # define PREFIX "" @@ -352,6 +355,7 @@ void tst_QLibrary::isLibrary_data() QTest::newRow(".a") << QString("mylib.a") << a_VALID; QTest::newRow(".bundle") << QString("mylib.bundle") << bundle_VALID; QTest::newRow(".dll") << QString("mylib.dll") << dll_VALID; + QTest::newRow(".DLL") << QString("MYLIB.DLL") << DLL_VALID; QTest::newRow(".dl2" ) << QString("mylib.dl2") << false; QTest::newRow(".dylib") << QString("mylib.dylib") << dylib_VALID; QTest::newRow(".sl") << QString("mylib.sl") << sl_VALID; @@ -556,7 +560,11 @@ void tst_QLibrary::fileName() } QVERIFY(ok); +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + QCOMPARE(lib.fileName().toLower(), expectedFilename.toLower()); +#else QCOMPARE(lib.fileName(), expectedFilename); +#endif } -- 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 388705d3616c3edd0bb1c7bfef2f093a446ff13a Mon Sep 17 00:00:00 2001 From: James Perrett Date: Mon, 15 Mar 2010 15:54:31 +0100 Subject: Bug fix: Allow $QTDIR to contain regex metacharacters Quote $QTDIR (and variables based on it) when they are used in regex patterns - this allows $QTDIR to contain valid pathname characters that are also regex metacharacters, such as '.' and '+'. Merge-Request: 506 Reviewed-by: Zeno Albisser --- bin/syncqt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index e36eeb6..71b71db 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -75,6 +75,7 @@ my @modules_to_sync ; $force_relative = 1 if ( -d "/System/Library/Frameworks" ); my $out_basedir = $basedir; $out_basedir =~ s=\\=/=g; +my $quoted_basedir = "\Q$basedir"; # functions ---------------------------------------------------------- @@ -349,11 +350,9 @@ sub syncHeader { ###################################################################### sub fixPaths { my ($file, $dir) = @_; - $dir =~ s=^$basedir/=$out_basedir/= if(!($basedir eq $out_basedir)); + $dir =~ s=^$quoted_basedir/=$out_basedir/= if(!($basedir eq $out_basedir)); $file =~ s=\\=/=g; - $file =~ s/\+/\\+/g; $dir =~ s=\\=/=g; - $dir =~ s/\+/\\+/g; #setup my $ret = $file; @@ -377,7 +376,7 @@ sub fixPaths { my $slash = index($file_dir, "/", $i); last if($slash == -1); my $tmp = substr($file_dir, 0, $slash); - last unless($dir =~ m,^$tmp/,); + last unless($dir =~ m,^\Q$tmp\E/,); $match_dir = $tmp; $i = $slash; } @@ -388,7 +387,7 @@ sub fixPaths { for(my $i = 0; $i < $count; $i++) { $dots .= "../"; } - $ret =~ s,^$match_dir,$dots,; + $ret =~ s,^\Q$match_dir\E,$dots,; } $ret =~ s,/+,/,g; return $ret; @@ -504,13 +503,13 @@ sub symlinkFile if ($isunix) { print "symlink created for $file " unless $quiet; - if ( $force_relative && ($ifile =~ /^$basedir/)) { + if ( $force_relative && ($ifile =~ /^$quoted_basedir/)) { my $t = getcwd(); my $c = -1; my $p = "../"; - $t =~ s-^$basedir/--; + $t =~ s-^$quoted_basedir/--; $p .= "../" while( ($c = index( $t, "/", $c + 1)) != -1 ); - $file =~ s-^$basedir/-$p-; + $file =~ s-^$quoted_basedir/-$p-; print " ($file)\n" unless $quiet; } print "\n" unless $quiet; @@ -830,7 +829,7 @@ foreach (@modules_to_sync) { if ($public_header) { @headers = ( "$out_basedir/include/$lib/$header" ); push @headers, "$out_basedir/include/Qt/$header" - if ("$lib" ne "phonon" && "$subdir" =~ /^$basedir\/src/); + if ("$lib" ne "phonon" && "$subdir" =~ /^$quoted_basedir\/src/); foreach(@classes) { my $header_base = basename($header); -- cgit v0.12 From 32893c4e04461553ec7608de9035ba0f30165c82 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Mon, 3 May 2010 18:09:00 +0200 Subject: added closing parenthesis in helpviewer_qtb.cpp Reviewed-by: TrustMe --- tools/assistant/tools/assistant/helpviewer_qtb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index 78890b9..32ffbc1 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -68,7 +68,7 @@ HelpViewer::HelpViewer(qreal zoom) QFont font = viewerFont(); font.setPointSize(int(font.pointSize() + zoom)); setViewerFont(font); - connect(this, SIGNAL(sourceChanged(QUrl), this, SIGNAL(titleChanged())); + connect(this, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged())); } HelpViewer::~HelpViewer() -- cgit v0.12 From a30b5ebbbcc4af0b82894edf4e026d4aea25bd95 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 4 May 2010 11:02:15 +0200 Subject: Restore file deleted during merge conflict resolution Reviewed-by: Trust Me --- tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir diff --git a/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir new file mode 100644 index 0000000..98d6b74 --- /dev/null +++ b/tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir @@ -0,0 +1,2 @@ +Foo 1.1 Foo.qml +Foo 1.0 Foo.qml -- cgit v0.12 From 1cfc49a59eaa54fa8060530e585052d41fd58cad Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Tue, 4 May 2010 14:10:46 +0200 Subject: Revert "Temporarily disable tests that use createNtfsJunction()" This reverts commit 498786a2ab27680b27f8e57b422ff8f32f0c3790. --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 2 -- tests/shared/filesystem.h | 3 --- 2 files changed, 5 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index 83b650a..c260946 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -1327,7 +1327,6 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(relTarget) << target.canonicalFilePath(); } -#if 0 //Junctions QString target = "target"; QString junction = "junction_pwd"; @@ -1363,7 +1362,6 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() FileSystem::createNtfsJunction(rootVolume, junction); QTest::newRow("mountpoint") << junction << true << QDir::fromNativeSeparators(rootPath) << QDir::rootPath(); } -#endif } void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() diff --git a/tests/shared/filesystem.h b/tests/shared/filesystem.h index dad4ef8c..079a6dc 100644 --- a/tests/shared/filesystem.h +++ b/tests/shared/filesystem.h @@ -95,8 +95,6 @@ struct FileSystem } return false; } - -#if 0 #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) static void createNtfsJunction(QString target, QString linkName) { @@ -150,7 +148,6 @@ struct FileSystem QVERIFY(ioc); } #endif -#endif private: QDir currentDir; -- 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 d873afaa7adfc5e633191332d0674aa1977904d1 Mon Sep 17 00:00:00 2001 From: kh1 Date: Tue, 4 May 2010 18:17:02 +0200 Subject: Sync against latest Qt Creator. Reviewed-by: ck --- tools/assistant/tools/assistant/aboutdialog.cpp | 9 +- tools/assistant/tools/assistant/assistant.pro | 9 +- tools/assistant/tools/assistant/centralwidget.cpp | 508 ++++++++------------- tools/assistant/tools/assistant/centralwidget.h | 51 ++- tools/assistant/tools/assistant/contentwindow.cpp | 7 +- tools/assistant/tools/assistant/findwidget.cpp | 2 +- tools/assistant/tools/assistant/findwidget.h | 5 +- tools/assistant/tools/assistant/globalactions.cpp | 2 +- tools/assistant/tools/assistant/helpviewer.cpp | 64 ++- tools/assistant/tools/assistant/helpviewer.h | 101 +++- tools/assistant/tools/assistant/helpviewer_p.h | 111 +++++ tools/assistant/tools/assistant/helpviewer_qtb.cpp | 328 ++++++++----- tools/assistant/tools/assistant/helpviewer_qtb.h | 114 ----- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 211 ++++++--- tools/assistant/tools/assistant/helpviewer_qwv.h | 120 ----- tools/assistant/tools/assistant/indexwindow.cpp | 5 +- .../assistant/tools/assistant/openpagesmanager.cpp | 8 +- tools/assistant/tools/assistant/openpagesmodel.cpp | 8 +- 18 files changed, 843 insertions(+), 820 deletions(-) create mode 100644 tools/assistant/tools/assistant/helpviewer_p.h delete mode 100644 tools/assistant/tools/assistant/helpviewer_qtb.h delete mode 100644 tools/assistant/tools/assistant/helpviewer_qwv.h diff --git a/tools/assistant/tools/assistant/aboutdialog.cpp b/tools/assistant/tools/assistant/aboutdialog.cpp index a9bc352..9935a1e 100644 --- a/tools/assistant/tools/assistant/aboutdialog.cpp +++ b/tools/assistant/tools/assistant/aboutdialog.cpp @@ -38,6 +38,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + +#include "aboutdialog.h" + #include "helpviewer.h" #include "tracer.h" @@ -51,8 +54,6 @@ #include #include -#include "aboutdialog.h" - QT_BEGIN_NAMESPACE AboutLabel::AboutLabel(QWidget *parent) @@ -96,8 +97,8 @@ QVariant AboutLabel::loadResource(int type, const QUrl &name) void AboutLabel::setSource(const QUrl &url) { TRACE_OBJ - if (url.isValid() && (!AbstractHelpViewer::isLocalUrl(url) - || !AbstractHelpViewer::canOpenPage(url.path()))) { + if (url.isValid() && (!HelpViewer::isLocalUrl(url) + || !HelpViewer::canOpenPage(url.path()))) { if (!QDesktopServices::openUrl(url)) { QMessageBox::warning(this, tr("Warning"), tr("Unable to launch external application.\n"), tr("OK")); diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index 50f5b7e..af306a5 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -32,6 +32,7 @@ HEADERS += aboutdialog.h \ filternamedialog.h \ helpenginewrapper.h \ helpviewer.h \ + helpviewer_p.h \ indexwindow.h \ installdialog.h \ mainwindow.h \ @@ -47,12 +48,6 @@ HEADERS += aboutdialog.h \ globalactions.h \ openpageswidget.h \ openpagesmanager.h - -contains(QT_CONFIG, webkit) { - HEADERS += helpviewer_qwv.h -} else { - HEADERS += helpviewer_qtb.h - } win32:HEADERS += remotecontrol_win.h SOURCES += aboutdialog.cpp \ @@ -84,7 +79,7 @@ SOURCES += aboutdialog.cpp \ globalactions.cpp \ openpageswidget.cpp \ openpagesmanager.cpp - contains(QT_CONFIG, webkit) { +contains(QT_CONFIG, webkit) { SOURCES += helpviewer_qwv.cpp } else { SOURCES += helpviewer_qtb.cpp diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 6d61570..edf7a50 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -43,15 +43,10 @@ #include "findwidget.h" #include "helpenginewrapper.h" +#include "helpviewer.h" #include "tracer.h" #include "../shared/collectionconfiguration.h" -#if defined(QT_NO_WEBKIT) -#include "helpviewer_qtb.h" -#else -#include "helpviewer_qwv.h" -#endif // QT_NO_WEBKIT - #include #include @@ -75,44 +70,31 @@ namespace { CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) - , findWidget(0) - , printer(0) +#ifndef QT_NO_PRINTER + , m_printer(0) +#endif + , m_findWidget(new FindWidget(this)) + , m_stackedWidget(new QStackedWidget(this)) { TRACE_OBJ staticCentralWidget = this; QVBoxLayout *vboxLayout = new QVBoxLayout(this); vboxLayout->setMargin(0); - m_stackedWidget = new QStackedWidget(this); vboxLayout->addWidget(m_stackedWidget); + vboxLayout->addWidget(m_findWidget); + m_findWidget->hide(); - findWidget = new FindWidget(this); - vboxLayout->addWidget(findWidget); - findWidget->hide(); - - connect(findWidget, SIGNAL(findNext()), this, SLOT(findNext())); - connect(findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious())); - connect(findWidget, SIGNAL(find(QString, bool)), this, - SLOT(find(QString, bool))); - connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab())); - -#if defined(QT_NO_WEBKIT) - QPalette p = palette(); - p.setColor(QPalette::Inactive, QPalette::Highlight, - p.color(QPalette::Active, QPalette::Highlight)); - p.setColor(QPalette::Inactive, QPalette::HighlightedText, - p.color(QPalette::Active, QPalette::HighlightedText)); - setPalette(p); -#endif + connect(m_findWidget, SIGNAL(findNext()), this, SLOT(findNext())); + connect(m_findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious())); + connect(m_findWidget, SIGNAL(find(QString, bool, bool)), this, + SLOT(find(QString, bool, bool))); + connect(m_findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab())); } CentralWidget::~CentralWidget() { TRACE_OBJ -#ifndef QT_NO_PRINTER - delete printer; -#endif - QStringList zoomFactors; QStringList currentPages; for (int i = 0; i < m_stackedWidget->count(); ++i) { @@ -128,6 +110,10 @@ CentralWidget::~CentralWidget() helpEngine.setLastShownPages(currentPages); helpEngine.setLastZoomFactors(zoomFactors); helpEngine.setLastTabPage(m_stackedWidget->currentIndex()); + +#ifndef QT_NO_PRINTER + delete m_printer; +#endif } CentralWidget *CentralWidget::instance() @@ -136,131 +122,113 @@ CentralWidget *CentralWidget::instance() return staticCentralWidget; } -void CentralWidget::zoomIn() +QUrl CentralWidget::currentSource() const { TRACE_OBJ - currentHelpViewer()->scaleUp(); + return currentHelpViewer()->source(); } -void CentralWidget::zoomOut() +QString CentralWidget::currentTitle() const { TRACE_OBJ - currentHelpViewer()->scaleDown(); + return currentHelpViewer()->title(); } -void CentralWidget::resetZoom() +bool CentralWidget::hasSelection() const { TRACE_OBJ - currentHelpViewer()->resetScale(); + return !currentHelpViewer()->selectedText().isEmpty(); } -void CentralWidget::setSource(const QUrl &url) +bool CentralWidget::isForwardAvailable() const { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); - viewer->setSource(url); - viewer->setFocus(Qt::OtherFocusReason); + return currentHelpViewer()->isForwardAvailable(); } -bool CentralWidget::hasSelection() const +bool CentralWidget::isBackwardAvailable() const { TRACE_OBJ - return currentHelpViewer()->hasSelection(); + return currentHelpViewer()->isBackwardAvailable(); } -QUrl CentralWidget::currentSource() const +HelpViewer* CentralWidget::viewerAt(int index) const { TRACE_OBJ - return currentHelpViewer()->source(); + return static_cast(m_stackedWidget->widget(index)); } -QString CentralWidget::currentTitle() const +HelpViewer* CentralWidget::currentHelpViewer() const { TRACE_OBJ - return currentHelpViewer()->documentTitle(); + return static_cast(m_stackedWidget->currentWidget()); } -void CentralWidget::copySelection() +void CentralWidget::addPage(HelpViewer *page, bool fromSearch) { TRACE_OBJ - currentHelpViewer()->copy(); + page->installEventFilter(this); + page->setFocus(Qt::OtherFocusReason); + connectSignals(page); + m_stackedWidget->addWidget(page); + if (fromSearch) { + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); + } } -void CentralWidget::showTextSearch() +void CentralWidget::removePage(int index) { TRACE_OBJ - findWidget->show(); + const bool currentChanged = index == currentIndex(); + m_stackedWidget->removeWidget(m_stackedWidget->widget(index)); + if (currentChanged) + emit currentViewerChanged(); } -void CentralWidget::initPrinter() +int CentralWidget::currentIndex() const { TRACE_OBJ -#ifndef QT_NO_PRINTER - if (!printer) - printer = new QPrinter(QPrinter::HighResolution); -#endif + return m_stackedWidget->currentIndex(); } -void CentralWidget::print() +void CentralWidget::setCurrentPage(HelpViewer *page) { TRACE_OBJ -#ifndef QT_NO_PRINTER - HelpViewer *viewer = currentHelpViewer(); - initPrinter(); - QPrintDialog dlg(printer, this); -#if defined(QT_NO_WEBKIT) - if (viewer->textCursor().hasSelection()) - dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection); -#endif - dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange); - dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies); - dlg.setWindowTitle(tr("Print Document")); - if (dlg.exec() == QDialog::Accepted) { - viewer->print(printer); - } -#endif + m_stackedWidget->setCurrentWidget(page); + emit currentViewerChanged(); } -void CentralWidget::printPreview() +// -- public slots + +void CentralWidget::copy() { TRACE_OBJ -#ifndef QT_NO_PRINTER - initPrinter(); - QPrintPreviewDialog preview(printer, this); - connect(&preview, SIGNAL(paintRequested(QPrinter*)), - SLOT(printPreview(QPrinter*))); - preview.exec(); -#endif + currentHelpViewer()->copy(); } -void CentralWidget::printPreview(QPrinter *p) +void CentralWidget::home() { TRACE_OBJ -#ifndef QT_NO_PRINTER - currentHelpViewer()->print(p); -#endif + currentHelpViewer()->home(); } -void CentralWidget::pageSetup() +void CentralWidget::zoomIn() { TRACE_OBJ -#ifndef QT_NO_PRINTER - initPrinter(); - QPageSetupDialog dlg(printer); - dlg.exec(); -#endif + currentHelpViewer()->scaleUp(); } -void CentralWidget::home() +void CentralWidget::zoomOut() { TRACE_OBJ - currentHelpViewer()->home(); + currentHelpViewer()->scaleDown(); } -bool CentralWidget::isForwardAvailable() const +void CentralWidget::resetZoom() { TRACE_OBJ - return currentHelpViewer()->isForwardAvailable(); + currentHelpViewer()->resetScale(); } void CentralWidget::forward() @@ -269,10 +237,11 @@ void CentralWidget::forward() currentHelpViewer()->forward(); } -bool CentralWidget::isBackwardAvailable() const +void CentralWidget::nextPage() { TRACE_OBJ - return currentHelpViewer()->isBackwardAvailable(); + m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() + 1) + % m_stackedWidget->count()); } void CentralWidget::backward() @@ -281,198 +250,112 @@ void CentralWidget::backward() currentHelpViewer()->backward(); } -void CentralWidget::connectSignals(HelpViewer *page) +void CentralWidget::previousPage() { TRACE_OBJ - connect(page, SIGNAL(copyAvailable(bool)), this, SIGNAL(copyAvailable(bool))); - connect(page, SIGNAL(forwardAvailable(bool)), this, - SIGNAL(forwardAvailable(bool))); - connect(page, SIGNAL(backwardAvailable(bool)), this, - SIGNAL(backwardAvailable(bool))); - connect(page, SIGNAL(sourceChanged(QUrl)), this, - SLOT(handleSourceChanged(QUrl))); - connect(page, SIGNAL(highlighted(QString)), this, - SIGNAL(highlighted(QString))); + m_stackedWidget->setCurrentIndex((m_stackedWidget->currentIndex() - 1) + % m_stackedWidget->count()); } -HelpViewer* CentralWidget::viewerAt(int index) const +void CentralWidget::print() { TRACE_OBJ - return static_cast(m_stackedWidget->widget(index)); +#ifndef QT_NO_PRINTER + initPrinter(); + QPrintDialog dlg(m_printer, this); + + if (!currentHelpViewer()->selectedText().isEmpty()) + dlg.addEnabledOption(QAbstractPrintDialog::PrintSelection); + dlg.addEnabledOption(QAbstractPrintDialog::PrintPageRange); + dlg.addEnabledOption(QAbstractPrintDialog::PrintCollateCopies); + dlg.setWindowTitle(tr("Print Document")); + if (dlg.exec() == QDialog::Accepted) + currentHelpViewer()->print(m_printer); +#endif } -HelpViewer* CentralWidget::currentHelpViewer() const +void CentralWidget::pageSetup() { TRACE_OBJ - return static_cast(m_stackedWidget->currentWidget()); +#ifndef QT_NO_PRINTER + initPrinter(); + QPageSetupDialog dlg(m_printer); + dlg.exec(); +#endif } -void CentralWidget::activateTab() +void CentralWidget::printPreview() { TRACE_OBJ - currentHelpViewer()->setFocus(); +#ifndef QT_NO_PRINTER + initPrinter(); + QPrintPreviewDialog preview(m_printer, this); + connect(&preview, SIGNAL(paintRequested(QPrinter*)), + SLOT(printPreview(QPrinter*))); + preview.exec(); +#endif } -bool CentralWidget::eventFilter(QObject *object, QEvent *e) +void CentralWidget::setSource(const QUrl &url) { TRACE_OBJ - if (e->type() == QEvent::KeyPress) { - QKeyEvent *ke = static_cast(e); - switch (ke->key()) { - default: { - return QWidget::eventFilter(object, e); - } break; - - case Qt::Key_Backspace: { - HelpViewer *viewer = currentHelpViewer(); - if (viewer == object) { -#if defined(QT_NO_WEBKIT) - if (viewer->isBackwardAvailable()) { -#else - if (viewer->isBackwardAvailable() && !viewer->hasFocus()) { -#endif - viewer->backward(); - return true; - } - } - } break; - } - } - - return QWidget::eventFilter(object, e); + HelpViewer *viewer = currentHelpViewer(); + viewer->setSource(url); + viewer->setFocus(Qt::OtherFocusReason); } -void CentralWidget::keyPressEvent(QKeyEvent *e) +void CentralWidget::setSourceFromSearch(const QUrl &url) { TRACE_OBJ - const QString &text = e->text(); - if (text.startsWith(QLatin1Char('/'))) { - if (!findWidget->isVisible()) { - findWidget->showAndClear(); - } else { - findWidget->show(); - } - } else { - QWidget::keyPressEvent(e); - } + connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, + SLOT(highlightSearchTerms())); + currentHelpViewer()->setSource(url); + currentHelpViewer()->setFocus(Qt::OtherFocusReason); } void CentralWidget::findNext() { TRACE_OBJ - find(findWidget->text(), true); + find(m_findWidget->text(), true, false); } void CentralWidget::findPrevious() { TRACE_OBJ - find(findWidget->text(), false); + find(m_findWidget->text(), false, false); } -void CentralWidget::find(const QString &ttf, bool forward) +void CentralWidget::find(const QString &ttf, bool forward, bool incremental) { TRACE_OBJ bool found = false; -#if defined(QT_NO_WEBKIT) - found = findInTextBrowser(ttf, forward); -#else - found = findInWebPage(ttf, forward); -#endif + if (HelpViewer *viewer = currentHelpViewer()) { + HelpViewer::FindFlags flags = 0; + if (!forward) + flags |= HelpViewer::FindBackward; + if (m_findWidget->caseSensitive()) + flags |= HelpViewer::FindCaseSensitively; + found = viewer->findText(ttf, flags, incremental, false); + } if (!found && ttf.isEmpty()) found = true; // the line edit is empty, no need to mark it red... - if (!findWidget->isVisible()) - findWidget->show(); - findWidget->setPalette(found); + if (!m_findWidget->isVisible()) + m_findWidget->show(); + m_findWidget->setPalette(found); } -bool CentralWidget::findInWebPage(const QString &ttf, bool forward) +void CentralWidget::activateTab() { TRACE_OBJ -#if !defined(QT_NO_WEBKIT) - HelpViewer *viewer = currentHelpViewer(); - bool found = false; - QWebPage::FindFlags options; - if (!ttf.isEmpty()) { - if (!forward) - options |= QWebPage::FindBackward; - - if (findWidget->caseSensitive()) - options |= QWebPage::FindCaseSensitively; - - found = viewer->findText(ttf, options); - findWidget->setTextWrappedVisible(false); - - if (!found) { - options |= QWebPage::FindWrapsAroundDocument; - found = viewer->findText(ttf, options); - if (found) - findWidget->setTextWrappedVisible(true); - } - } - // force highlighting of all other matches, also when empty (clear) - options = QWebPage::HighlightAllOccurrences; - if (findWidget->caseSensitive()) - options |= QWebPage::FindCaseSensitively; - viewer->findText(QLatin1String(""), options); - viewer->findText(ttf, options); - return found; - - // this needs to stay, case for active search results page - return findInTextBrowser(ttf, forward); -#else - Q_UNUSED(ttf); - Q_UNUSED(forward); -#endif - return false; + currentHelpViewer()->setFocus(); } -bool CentralWidget::findInTextBrowser(const QString &ttf, bool forward) +void CentralWidget::showTextSearch() { TRACE_OBJ - QTextBrowser *browser = qobject_cast(currentHelpViewer()); - - if (!browser || ttf.isEmpty()) - return false; - - QTextDocument *doc = browser->document(); - QTextCursor cursor = browser->textCursor(); - - if (!doc || cursor.isNull()) - return false; - - QTextDocument::FindFlags options; - - if (cursor.hasSelection()) { - cursor.setPosition(forward ? cursor.position() : cursor.anchor(), - QTextCursor::MoveAnchor); - } - - if (!forward) - options |= QTextDocument::FindBackward; - - if (findWidget->caseSensitive()) - options |= QTextDocument::FindCaseSensitively; - - findWidget->setTextWrappedVisible(false); - - bool found = true; - QTextCursor newCursor = doc->find(ttf, cursor, options); - if (newCursor.isNull()) { - QTextCursor ac(doc); - ac.movePosition(options & QTextDocument::FindBackward - ? QTextCursor::End : QTextCursor::Start); - newCursor = doc->find(ttf, ac, options); - if (newCursor.isNull()) { - found = false; - newCursor = cursor; - } else { - findWidget->setTextWrappedVisible(true); - } - } - browser->setTextCursor(newCursor); - return found; + m_findWidget->show(); } void CentralWidget::updateBrowserFont() @@ -484,25 +367,41 @@ void CentralWidget::updateBrowserFont() viewerAt(i)->setViewerFont(font); } -void -CentralWidget::setSourceFromSearch(const QUrl &url) +// -- protected + +void CentralWidget::keyPressEvent(QKeyEvent *e) { TRACE_OBJ - setSource(url); -#if defined(QT_NO_WEBKIT) - highlightSearchTerms(); -#else - connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, - SLOT(highlightSearchTerms())); -#endif + const QString &text = e->text(); + if (text.startsWith(QLatin1Char('/'))) { + if (!m_findWidget->isVisible()) { + m_findWidget->showAndClear(); + } else { + m_findWidget->show(); + } + } else { + QWidget::keyPressEvent(e); + } } -void -CentralWidget::highlightSearchTerms() +void CentralWidget::focusInEvent(QFocusEvent * /* event */) { TRACE_OBJ - HelpViewer *viewer = currentHelpViewer(); + // If we have a current help viewer then this is the 'focus proxy', + // otherwise it's the central widget. This is needed, so an embedding + // program can just set the focus to the central widget and it does + // The Right Thing(TM) + QObject *receiver = m_stackedWidget; + if (HelpViewer *viewer = currentHelpViewer()) + receiver = viewer; + QTimer::singleShot(1, receiver, SLOT(setFocus())); +} + +// -- private slots +void CentralWidget::highlightSearchTerms() +{ + TRACE_OBJ QHelpSearchEngine *searchEngine = HelpEngineWrapper::instance().searchEngine(); QList queryList = searchEngine->query(); @@ -521,91 +420,72 @@ CentralWidget::highlightSearchTerms() } } -#if defined(QT_NO_WEBKIT) - viewer->viewport()->setUpdatesEnabled(false); - - QTextCharFormat marker; - marker.setForeground(Qt::red); - - QTextCursor firstHit; - - QTextCursor c = viewer->textCursor(); - c.beginEditBlock(); - foreach (const QString& term, terms) { - c.movePosition(QTextCursor::Start); - viewer->setTextCursor(c); - - while (viewer->find(term, QTextDocument::FindWholeWords)) { - QTextCursor hit = viewer->textCursor(); - if (firstHit.isNull() || hit.position() < firstHit.position()) - firstHit = hit; - - hit.mergeCharFormat(marker); - } - } - - if (firstHit.isNull()) { - firstHit = viewer->textCursor(); - firstHit.movePosition(QTextCursor::Start); - } - firstHit.clearSelection(); - c.endEditBlock(); - viewer->setTextCursor(firstHit); - - viewer->viewport()->setUpdatesEnabled(true); -#else - viewer->findText("", QWebPage::HighlightAllOccurrences); - // clears existing selections + HelpViewer *viewer = currentHelpViewer(); foreach (const QString& term, terms) - viewer->findText(term, QWebPage::HighlightAllOccurrences); - + viewer->findText(term, 0, false, true); disconnect(viewer, SIGNAL(loadFinished(bool)), this, SLOT(highlightSearchTerms())); -#endif } -void CentralWidget::addPage(HelpViewer *page, bool fromSearch) +void CentralWidget::printPreview(QPrinter *p) { TRACE_OBJ - page->installEventFilter(this); - page->setFocus(Qt::OtherFocusReason); - connectSignals(page); - m_stackedWidget->addWidget(page); - if (fromSearch) { -#if defined(QT_NO_WEBKIT) - highlightSearchTerms(); -#else - connect(currentHelpViewer(), SIGNAL(loadFinished(bool)), this, - SLOT(highlightSearchTerms())); +#ifndef QT_NO_PRINTER + currentHelpViewer()->print(p); #endif - } } -void CentralWidget::removePage(int index) +void CentralWidget::handleSourceChanged(const QUrl &url) { TRACE_OBJ - const bool currentChanged = index == currentIndex(); - m_stackedWidget->removeWidget(m_stackedWidget->widget(index)); - if (currentChanged) - emit currentViewerChanged(); + if (sender() == currentHelpViewer()) + emit sourceChanged(url); } -void CentralWidget::setCurrentPage(HelpViewer *page) +// -- private + +void CentralWidget::initPrinter() { TRACE_OBJ - m_stackedWidget->setCurrentWidget(page); - emit currentViewerChanged(); +#ifndef QT_NO_PRINTER + if (!m_printer) + m_printer = new QPrinter(QPrinter::HighResolution); +#endif } -int CentralWidget::currentIndex() const +void CentralWidget::connectSignals(HelpViewer *page) { - return m_stackedWidget->currentIndex(); + TRACE_OBJ + connect(page, SIGNAL(copyAvailable(bool)), this, + SIGNAL(copyAvailable(bool))); + connect(page, SIGNAL(forwardAvailable(bool)), this, + SIGNAL(forwardAvailable(bool))); + connect(page, SIGNAL(backwardAvailable(bool)), this, + SIGNAL(backwardAvailable(bool))); + connect(page, SIGNAL(sourceChanged(QUrl)), this, + SLOT(handleSourceChanged(QUrl))); + connect(page, SIGNAL(highlighted(QString)), this, + SIGNAL(highlighted(QString))); } -void CentralWidget::handleSourceChanged(const QUrl &url) +bool CentralWidget::eventFilter(QObject *object, QEvent *e) { - if (sender() == currentHelpViewer()) - emit sourceChanged(url); + TRACE_OBJ + if (e->type() != QEvent::KeyPress) + return QWidget::eventFilter(object, e); + + HelpViewer *viewer = currentHelpViewer(); + QKeyEvent *keyEvent = static_cast (e); + if (viewer == object && keyEvent->key() == Qt::Key_Backspace) { + if (viewer->isBackwardAvailable()) { +#if !defined(QT_NO_WEBKIT) + // this helps in case there is an html field + if (!viewer->hasFocus()) +#endif + viewer->backward(); + } + } + return QWidget::eventFilter(object, e); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/centralwidget.h b/tools/assistant/tools/assistant/centralwidget.h index 9b8db30..69e334a 100644 --- a/tools/assistant/tools/assistant/centralwidget.h +++ b/tools/assistant/tools/assistant/centralwidget.h @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef CENTRALWIDGET_H #define CENTRALWIDGET_H @@ -55,12 +56,15 @@ class CentralWidget : public QWidget Q_OBJECT public: - CentralWidget(QWidget *parent); + CentralWidget(QWidget *parent = 0); ~CentralWidget(); - bool hasSelection() const; + static CentralWidget *instance(); + QUrl currentSource() const; QString currentTitle() const; + + bool hasSelection() const; bool isForwardAvailable() const; bool isBackwardAvailable() const; @@ -69,32 +73,38 @@ public: void addPage(HelpViewer *page, bool fromSearch = false); void removePage(int index); - void setCurrentPage(HelpViewer *page); - int currentIndex() const; - static CentralWidget *instance(); + int currentIndex() const; + void setCurrentPage(HelpViewer *page); public slots: + void copy(); + void home(); + void zoomIn(); void zoomOut(); void resetZoom(); - void copySelection(); - void showTextSearch(); + + void forward(); + void nextPage(); + + void backward(); + void previousPage(); + void print(); void pageSetup(); void printPreview(); - void updateBrowserFont(); + void setSource(const QUrl &url); void setSourceFromSearch(const QUrl &url); - void home(); - void forward(); - void backward(); - - void activateTab(); void findNext(); void findPrevious(); - void find(const QString &text, bool forward); + void find(const QString &text, bool forward, bool incremental); + + void activateTab(); + void showTextSearch(); + void updateBrowserFont(); signals: void currentViewerChanged(); @@ -107,23 +117,24 @@ signals: protected: void keyPressEvent(QKeyEvent *); + void focusInEvent(QFocusEvent *event); private slots: - void printPreview(QPrinter *printer); void highlightSearchTerms(); + void printPreview(QPrinter *printer); void handleSourceChanged(const QUrl &url); private: + void initPrinter(); void connectSignals(HelpViewer *page); bool eventFilter(QObject *object, QEvent *e); - bool findInWebPage(const QString &ttf, bool forward); - bool findInTextBrowser(const QString &ttf, bool forward); - void initPrinter(); private: +#ifndef QT_NO_PRINTER + QPrinter *m_printer; +#endif + FindWidget *m_findWidget; QStackedWidget *m_stackedWidget; - FindWidget *findWidget; - QPrinter *printer; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/contentwindow.cpp b/tools/assistant/tools/assistant/contentwindow.cpp index 3af4d34..3234980 100644 --- a/tools/assistant/tools/assistant/contentwindow.cpp +++ b/tools/assistant/tools/assistant/contentwindow.cpp @@ -38,13 +38,14 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "contentwindow.h" + #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" #include "openpagesmanager.h" +#include "tracer.h" #include #include @@ -145,7 +146,7 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e) qobject_cast(m_contentWidget->model()); if (contentModel) { QHelpContentItem *itm = contentModel->contentItemAt(index); - if (itm && AbstractHelpViewer::canOpenPage(itm->url().path())) + if (itm && HelpViewer::canOpenPage(itm->url().path())) OpenPagesManager::instance()->createPage(itm->url()); } } else if (button == Qt::LeftButton) { @@ -171,7 +172,7 @@ void ContentWindow::showContextMenu(const QPoint &pos) QMenu menu; QAction *curTab = menu.addAction(tr("Open Link")); QAction *newTab = menu.addAction(tr("Open Link in New Tab")); - if (!AbstractHelpViewer::canOpenPage(itm->url().path())) + if (!HelpViewer::canOpenPage(itm->url().path())) newTab->setEnabled(false); menu.move(m_contentWidget->mapToGlobal(pos)); diff --git a/tools/assistant/tools/assistant/findwidget.cpp b/tools/assistant/tools/assistant/findwidget.cpp index 60318d4..e46be61 100644 --- a/tools/assistant/tools/assistant/findwidget.cpp +++ b/tools/assistant/tools/assistant/findwidget.cpp @@ -203,7 +203,7 @@ void FindWidget::updateButtons() void FindWidget::textChanged(const QString &text) { TRACE_OBJ - emit find(text, true); + emit find(text, true, true); } bool FindWidget::eventFilter(QObject *object, QEvent *e) diff --git a/tools/assistant/tools/assistant/findwidget.h b/tools/assistant/tools/assistant/findwidget.h index cf78003..85e1959 100644 --- a/tools/assistant/tools/assistant/findwidget.h +++ b/tools/assistant/tools/assistant/findwidget.h @@ -67,11 +67,10 @@ public: void setTextWrappedVisible(bool visible); signals: - void escapePressed(); - void findNext(); void findPrevious(); - void find(const QString &text, bool forward); + void escapePressed(); + void find(const QString &text, bool forward, bool incremental); protected: void hideEvent(QHideEvent* event); diff --git a/tools/assistant/tools/assistant/globalactions.cpp b/tools/assistant/tools/assistant/globalactions.cpp index de47da0..a9cc392 100644 --- a/tools/assistant/tools/assistant/globalactions.cpp +++ b/tools/assistant/tools/assistant/globalactions.cpp @@ -116,7 +116,7 @@ GlobalActions::GlobalActions(QObject *parent) : QObject(parent) m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png"))); m_copyAction->setShortcuts(QKeySequence::Copy); m_copyAction->setEnabled(false); - connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copySelection())); + connect(m_copyAction, SIGNAL(triggered()), centralWidget, SLOT(copy())); m_actionList << m_copyAction; m_printAction = new QAction(tr("&Print..."), parent); diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 6499139..dfcacd1 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -38,6 +38,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "helpviewer.h" #include "helpenginewrapper.h" #include "tracer.h" @@ -49,18 +50,21 @@ #include #include +#include + +#include QT_BEGIN_NAMESPACE -const QLatin1String AbstractHelpViewer::DocPath("qthelp://com.trolltech."); +const QString HelpViewer::DocPath = QLatin1String("qthelp://com.trolltech."); -const QString AbstractHelpViewer::AboutBlank = +const QString HelpViewer::AboutBlank = QCoreApplication::translate("HelpViewer", "about:blank"); -const QString AbstractHelpViewer::LocalHelpFile = QLatin1String("qthelp://" +const QString HelpViewer::LocalHelpFile = QLatin1String("qthelp://" "com.trolltech.com.assistantinternal-1.0.0/assistant/assistant.html"); -const QString AbstractHelpViewer::PageNotFoundMessage = +const QString HelpViewer::PageNotFoundMessage = QCoreApplication::translate("HelpViewer", "Error 404...


The page could not be found


'%1'" "

"); @@ -102,17 +106,7 @@ struct ExtensionMap { { 0, 0 } }; -// -- AbstractHelpViewer - -AbstractHelpViewer::AbstractHelpViewer() -{ -} - -AbstractHelpViewer::~AbstractHelpViewer() -{ -} - -bool AbstractHelpViewer::isLocalUrl(const QUrl &url) +bool HelpViewer::isLocalUrl(const QUrl &url) { TRACE_OBJ const QString &scheme = url.scheme(); @@ -124,13 +118,13 @@ bool AbstractHelpViewer::isLocalUrl(const QUrl &url) || scheme == QLatin1String("about"); } -bool AbstractHelpViewer::canOpenPage(const QString &url) +bool HelpViewer::canOpenPage(const QString &url) { TRACE_OBJ return !mimeFromUrl(url).isEmpty(); } -QString AbstractHelpViewer::mimeFromUrl(const QUrl &url) +QString HelpViewer::mimeFromUrl(const QUrl &url) { TRACE_OBJ const QString &path = url.path(); @@ -146,7 +140,7 @@ QString AbstractHelpViewer::mimeFromUrl(const QUrl &url) return QLatin1String(""); } -bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url) +bool HelpViewer::launchWithExternalApp(const QUrl &url) { TRACE_OBJ if (isLocalUrl(url)) { @@ -177,4 +171,38 @@ bool AbstractHelpViewer::launchWithExternalApp(const QUrl &url) return false; } +// -- public slots + +void HelpViewer::home() +{ + TRACE_OBJ + setSource(HelpEngineWrapper::instance().homePage()); +} + +// -- private slots + +void HelpViewer::setLoadFinished(bool ok) +{ + Q_UNUSED(ok) + emit sourceChanged(source()); +} + +// -- private + +bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event) +{ + TRACE_OBJ + if (event->button() == Qt::XButton1) { + backward(); + return true; + } + + if (event->button() == Qt::XButton2) { + forward(); + return true; + } + + return false; +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index def9418..fc3d753 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -38,36 +38,69 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #ifndef HELPVIEWER_H #define HELPVIEWER_H +#include #include +#include +#include +#include #include -QT_BEGIN_NAMESPACE +#if defined(QT_NO_WEBKIT) +#include +#else +#include +#endif -class QMouseEvent; -class QUrl; +QT_BEGIN_NAMESPACE -class AbstractHelpViewer +#if !defined(QT_NO_WEBKIT) +class HelpViewer : public QWebView +#else +class HelpViewer : public QTextBrowser +#endif { + Q_OBJECT + class HelpViewerPrivate; + Q_DISABLE_COPY(HelpViewer) + public: - AbstractHelpViewer(); - virtual ~AbstractHelpViewer(); + enum FindFlag { + FindBackward = 0x01, + FindCaseSensitively = 0x02 + }; + Q_DECLARE_FLAGS(FindFlags, FindFlag) + + HelpViewer(qreal zoom, QWidget *parent = 0); + ~HelpViewer(); + + QFont viewerFont() const; + void setViewerFont(const QFont &font); + + void scaleUp(); + void scaleDown(); + + void resetScale(); + qreal scale() const; - virtual QFont viewerFont() const = 0; - virtual void setViewerFont(const QFont &font) = 0; + QString title() const; + void setTitle(const QString &title); - virtual void scaleUp() = 0; - virtual void scaleDown() = 0; - - virtual void resetScale() = 0; - virtual qreal scale() const = 0; + QUrl source() const; + void setSource(const QUrl &url); - virtual bool handleForwardBackwardMouseButtons(QMouseEvent *e) = 0; + QString selectedText() const; + bool isForwardAvailable() const; + bool isBackwardAvailable() const; - static const QLatin1String DocPath; + bool findText(const QString &text, FindFlags flags, bool incremental, + bool fromSearch); + + static const QString DocPath; static const QString AboutBlank; static const QString LocalHelpFile; static const QString PageNotFoundMessage; @@ -76,6 +109,44 @@ public: static bool canOpenPage(const QString &url); static QString mimeFromUrl(const QUrl &url); static bool launchWithExternalApp(const QUrl &url); + +public slots: + void copy(); + void home(); + + void forward(); + void backward(); + +signals: + void titleChanged(); +#if !defined(QT_NO_WEBKIT) + void copyAvailable(bool yes); + void sourceChanged(const QUrl &url); + void forwardAvailable(bool enabled); + void backwardAvailable(bool enabled); + void highlighted(const QString &link); +#else + void loadFinished(bool finished); +#endif + +protected: + void keyPressEvent(QKeyEvent *e); + void wheelEvent(QWheelEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +private slots: + void actionChanged(); + void setLoadFinished(bool ok); + +private: + bool eventFilter(QObject *obj, QEvent *event); + void contextMenuEvent(QContextMenuEvent *event); + QVariant loadResource(int type, const QUrl &name); + bool handleForwardBackwardMouseButtons(QMouseEvent *e); + +private: + HelpViewerPrivate *d; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_p.h b/tools/assistant/tools/assistant/helpviewer_p.h new file mode 100644 index 0000000..631d65f --- /dev/null +++ b/tools/assistant/tools/assistant/helpviewer_p.h @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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 Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 HELPVIEWERPRIVATE_H +#define HELPVIEWERPRIVATE_H + +#include "centralwidget.h" +#include "helpviewer.h" +#include "openpagesmanager.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +class HelpViewer::HelpViewerPrivate : public QObject +{ + Q_OBJECT + +public: + HelpViewerPrivate(int zoom) + : zoomCount(zoom) + , forceFont(false) + , lastAnchor(QString()) + + {} + + bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos) + { + lastAnchor = browser->anchorAt(pos); + if (lastAnchor.isEmpty()) + return false; + + lastAnchor = browser->source().resolved(lastAnchor).toString(); + if (lastAnchor.at(0) == QLatin1Char('#')) { + QString src = browser->source().toString(); + int hsh = src.indexOf(QLatin1Char('#')); + lastAnchor = (hsh >= 0 ? src.left(hsh) : src) + lastAnchor; + } + return true; + } + + void openLink(bool newPage) + { + if(lastAnchor.isEmpty()) + return; + if (newPage) + OpenPagesManager::instance()->createPage(lastAnchor); + else + CentralWidget::instance()->setSource(lastAnchor); + lastAnchor.clear(); + } + +public slots: + void openLink() + { + openLink(false); + } + + void openLinkInNewPage() + { + openLink(true); + } + +public: + int zoomCount; + bool forceFont; + QString lastAnchor; +}; + +QT_END_NAMESPACE + +#endif // HELPVIEWERPRIVATE_H diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index 32ffbc1..a73e1e1 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -38,10 +38,12 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "helpviewer_qtb.h" + +#include "helpviewer.h" #include "globalactions.h" #include "helpenginewrapper.h" +#include "helpviewer_p.h" #include "openpagesmanager.h" #include "tracer.h" @@ -54,33 +56,40 @@ QT_BEGIN_NAMESPACE -HelpViewer::HelpViewer(qreal zoom) - : zoomCount(zoom) - , controlPressed(false) - , lastAnchor(QString()) - , helpEngine(HelpEngineWrapper::instance()) - , forceFont(false) +HelpViewer::HelpViewer(qreal zoom, QWidget *parent) + : QTextBrowser(parent) + , d(new HelpViewerPrivate(zoom)) { TRACE_OBJ + QPalette p = palette(); + p.setColor(QPalette::Inactive, QPalette::Highlight, + p.color(QPalette::Active, QPalette::Highlight)); + p.setColor(QPalette::Inactive, QPalette::HighlightedText, + p.color(QPalette::Active, QPalette::HighlightedText)); + setPalette(p); + installEventFilter(this); document()->setDocumentMargin(8); QFont font = viewerFont(); font.setPointSize(int(font.pointSize() + zoom)); setViewerFont(font); + connect(this, SIGNAL(sourceChanged(QUrl)), this, SIGNAL(titleChanged())); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); } HelpViewer::~HelpViewer() { TRACE_OBJ + delete d; } QFont HelpViewer::viewerFont() const { TRACE_OBJ if (HelpEngineWrapper::instance().usesBrowserFont()) - return helpEngine.browserFont(); + return HelpEngineWrapper::instance().browserFont(); return qApp->font(); } @@ -88,186 +97,182 @@ void HelpViewer::setViewerFont(const QFont &newFont) { TRACE_OBJ if (font() != newFont) { - forceFont = true; + d->forceFont = true; setFont(newFont); - forceFont = false; + d->forceFont = false; } } void HelpViewer::scaleUp() { TRACE_OBJ - if (zoomCount < 10) { - ++zoomCount; - forceFont = true; + if (d->zoomCount < 10) { + d->zoomCount++; + d->forceFont = true; zoomIn(); - forceFont = false; + d->forceFont = false; } } void HelpViewer::scaleDown() { TRACE_OBJ - if (zoomCount > -5) { - --zoomCount; - forceFont = true; + if (d->zoomCount > -5) { + d->zoomCount--; + d->forceFont = true; zoomOut(); - forceFont = false; + d->forceFont = false; } } void HelpViewer::resetScale() { TRACE_OBJ - if (zoomCount != 0) { - forceFont = true; - zoomOut(zoomCount); - forceFont = false; + if (d->zoomCount != 0) { + d->forceFont = true; + zoomOut(d->zoomCount); + d->forceFont = false; } - zoomCount = 0; + d->zoomCount = 0; } -bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) +qreal HelpViewer::scale() const { - if (e->button() == Qt::XButton1) { - QTextBrowser::backward(); - return true; - } + TRACE_OBJ + return d->zoomCount; +} - if (e->button() == Qt::XButton2) { - QTextBrowser::forward(); - return true; - } - return false; +QString HelpViewer::title() const +{ + TRACE_OBJ + return documentTitle(); +} + +void HelpViewer::setTitle(const QString &title) +{ + TRACE_OBJ + setDocumentTitle(title); +} + +QUrl HelpViewer::source() const +{ + TRACE_OBJ + return QTextBrowser::source(); } void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ - const QString &string = url.toString(); - if (url.isValid() && string != QLatin1String("help")) { - if (launchWithExternalApp(url)) - return; - - const QUrl &resolvedUrl = helpEngine.findFile(url); - if (resolvedUrl.isValid()) { - QTextBrowser::setSource(resolvedUrl); - return; - } - } + if (launchWithExternalApp(url)) + return; - if (string != QLatin1String("help")) { - QTextBrowser::setSource(url); + QString string = url.toString(); + const HelpEngineWrapper &engine = HelpEngineWrapper::instance(); + const QUrl &resolvedUrl = (string == QLatin1String("help") ? LocalHelpFile : + engine.findFile(string)); + QTextBrowser::setSource(resolvedUrl); + if (!url.isValid()) { setHtml(string == QLatin1String("about:blank") ? AboutBlank : PageNotFoundMessage.arg(url.toString())); - emit sourceChanged(url); - } else { - QTextBrowser::setSource(LocalHelpFile); } + emit loadFinished(true); } -QVariant HelpViewer::loadResource(int type, const QUrl &name) +QString HelpViewer::selectedText() const { TRACE_OBJ - QByteArray ba; - if (type < 4) { - ba = helpEngine.fileData(name); - if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { - QImage image; - image.loadFromData(ba, "svg"); - if (!image.isNull()) - return image; - } - } - return ba; + return textCursor().selectedText(); } -void HelpViewer::openLinkInNewTab() +bool HelpViewer::isForwardAvailable() const { TRACE_OBJ - if(lastAnchor.isEmpty()) - return; - - OpenPagesManager::instance()->createPage(QUrl(lastAnchor)); - lastAnchor.clear(); + return QTextBrowser::isForwardAvailable(); } -void HelpViewer::openLinkInNewTab(const QString &link) +bool HelpViewer::isBackwardAvailable() const { TRACE_OBJ - lastAnchor = link; - openLinkInNewTab(); + return QTextBrowser::isBackwardAvailable(); } -bool HelpViewer::hasAnchorAt(const QPoint& pos) +bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental, + bool fromSearch) { TRACE_OBJ - lastAnchor = anchorAt(pos); - if (lastAnchor.isEmpty()) + QTextDocument *doc = document(); + QTextCursor cursor = textCursor(); + if (!doc || cursor.isNull()) return false; - lastAnchor = source().resolved(lastAnchor).toString(); - if (lastAnchor.at(0) == QLatin1Char('#')) { - QString src = source().toString(); - int hsh = src.indexOf(QLatin1Char('#')); - lastAnchor = (hsh>=0 ? src.left(hsh) : src) + lastAnchor; + const int position = cursor.selectionStart(); + if (incremental) + cursor.setPosition(position); + + QTextDocument::FindFlags textDocFlags; + if (flags & HelpViewer::FindBackward) + textDocFlags |= QTextDocument::FindBackward; + if (flags & HelpViewer::FindCaseSensitively) + textDocFlags |= QTextDocument::FindCaseSensitively; + + QTextCursor found = doc->find(text, cursor, textDocFlags); + if (found.isNull()) { + if ((flags & HelpViewer::FindBackward) == 0) + cursor.movePosition(QTextCursor::Start); + else + cursor.movePosition(QTextCursor::End); + found = doc->find(text, cursor, textDocFlags); } - return true; -} + if (fromSearch) { + cursor.beginEditBlock(); + viewport()->setUpdatesEnabled(false); -void HelpViewer::contextMenuEvent(QContextMenuEvent *e) -{ - TRACE_OBJ - QMenu menu(QLatin1String(""), 0); + QTextCharFormat marker; + marker.setForeground(Qt::red); + cursor.movePosition(QTextCursor::Start); + setTextCursor(cursor); - QUrl link; - QAction *copyAnchorAction = 0; - if (hasAnchorAt(e->pos())) { - link = anchorAt(e->pos()); - if (link.isRelative()) - link = source().resolved(link); - copyAnchorAction = menu.addAction(tr("Copy &Link Location")); - copyAnchorAction->setEnabled(!link.isEmpty() && link.isValid()); + while (find(text)) { + QTextCursor hit = textCursor(); + hit.mergeCharFormat(marker); + } - menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), this, - SLOT(openLinkInNewTab())); - menu.addSeparator(); + viewport()->setUpdatesEnabled(true); + cursor.endEditBlock(); } - menu.addActions(GlobalActions::instance()->actionList()); - QAction *action = menu.exec(e->globalPos()); - if (action == copyAnchorAction) - QApplication::clipboard()->setText(link.toString()); + bool cursorIsNull = found.isNull(); + if (cursorIsNull) { + found = textCursor(); + found.setPosition(position); + } + setTextCursor(found); + return !cursorIsNull; } -void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +// -- public slots + +void HelpViewer::copy() { TRACE_OBJ -#ifndef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(e)) - return; -#endif - - controlPressed = e->modifiers() & Qt::ControlModifier; - if ((controlPressed && hasAnchorAt(e->pos())) || - (e->button() == Qt::MidButton && hasAnchorAt(e->pos()))) { - openLinkInNewTab(); - return; - } + QTextBrowser::copy(); +} - QTextBrowser::mouseReleaseEvent(e); +void HelpViewer::forward() +{ + TRACE_OBJ + QTextBrowser::forward(); } -void HelpViewer::mousePressEvent(QMouseEvent *e) +void HelpViewer::backward() { -#ifdef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(e)) - return; -#endif - QTextBrowser::mousePressEvent(e); + TRACE_OBJ + QTextBrowser::backward(); } +// -- protected + void HelpViewer::keyPressEvent(QKeyEvent *e) { TRACE_OBJ @@ -280,11 +285,6 @@ void HelpViewer::keyPressEvent(QKeyEvent *e) QTextBrowser::keyPressEvent(e); } -void HelpViewer::home() -{ - TRACE_OBJ - setSource(helpEngine.homePage()); -} void HelpViewer::wheelEvent(QWheelEvent *e) { @@ -297,12 +297,92 @@ void HelpViewer::wheelEvent(QWheelEvent *e) } } +void HelpViewer::mousePressEvent(QMouseEvent *e) +{ + TRACE_OBJ +#ifdef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) + return; +#endif + QTextBrowser::mousePressEvent(e); +} + +void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +{ + TRACE_OBJ +#ifndef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(e)) + return; +#endif + + bool controlPressed = e->modifiers() & Qt::ControlModifier; + if ((controlPressed && d->hasAnchorAt(this, e->pos())) || + (e->button() == Qt::MidButton && d->hasAnchorAt(this, e->pos()))) { + d->openLinkInNewPage(); + return; + } + + QTextBrowser::mouseReleaseEvent(e); +} + +// -- private slots + +void HelpViewer::actionChanged() +{ + // stub + TRACE_OBJ +} + +// -- private + bool HelpViewer::eventFilter(QObject *obj, QEvent *event) { TRACE_OBJ - if (event->type() == QEvent::FontChange && !forceFont) + if (event->type() == QEvent::FontChange && !d->forceFont) return true; return QTextBrowser::eventFilter(obj, event); } +void HelpViewer::contextMenuEvent(QContextMenuEvent *event) +{ + TRACE_OBJ + QMenu menu(QLatin1String(""), 0); + + QUrl link; + QAction *copyAnchorAction = 0; + if (d->hasAnchorAt(this, event->pos())) { + link = anchorAt(event->pos()); + if (link.isRelative()) + link = source().resolved(link); + menu.addAction(tr("Open Link"), d, SLOT(openLink())); + menu.addAction(tr("Open Link in New Tab\tCtrl+LMB"), d, SLOT(openLinkInNewPage())); + + if (!link.isEmpty() && link.isValid()) + copyAnchorAction = menu.addAction(tr("Copy &Link Location")); + } else if (!selectedText().isEmpty()) { + menu.addAction(tr("Copy"), this, SLOT(copy())); + } else { + menu.addAction(tr("Reload"), this, SLOT(reload())); + } + + if (copyAnchorAction == menu.exec(event->globalPos())) + QApplication::clipboard()->setText(link.toString()); +} + +QVariant HelpViewer::loadResource(int type, const QUrl &name) +{ + TRACE_OBJ + QByteArray ba; + if (type < 4) { + ba = HelpEngineWrapper::instance().fileData(name); + if (name.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) { + QImage image; + image.loadFromData(ba, "svg"); + if (!image.isNull()) + return image; + } + } + return ba; +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.h b/tools/assistant/tools/assistant/helpviewer_qtb.h deleted file mode 100644 index 065557e..0000000 --- a/tools/assistant/tools/assistant/helpviewer_qtb.h +++ /dev/null @@ -1,114 +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 Qt Assistant of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt 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 HELPVIEWERQTB_H -#define HELPVIEWERQTB_H - -#include "helpviewer.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class HelpEngineWrapper; -class QContextMenuEvent; -class QKeyEvent; -class QMouseEvent; - -class HelpViewer : public QTextBrowser, public AbstractHelpViewer -{ - Q_OBJECT - -public: - HelpViewer(qreal zoom = 0.0); - ~HelpViewer(); - - QFont viewerFont() const; - void setViewerFont(const QFont &font); - - void scaleUp(); - void scaleDown(); - void resetScale(); - qreal scale() const { return zoomCount; } - - bool handleForwardBackwardMouseButtons(QMouseEvent *e); - - void setSource(const QUrl &url); - - inline bool hasSelection() const - { return textCursor().hasSelection(); } - -signals: - void titleChanged(); - -public Q_SLOTS: - void home(); - -protected: - void wheelEvent(QWheelEvent *e); - bool eventFilter(QObject *obj, QEvent *event); - -private: - QVariant loadResource(int type, const QUrl &name); - void openLinkInNewTab(const QString &link); - bool hasAnchorAt(const QPoint& pos); - void contextMenuEvent(QContextMenuEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent *e); - -private slots: - void openLinkInNewTab(); - -private: - int zoomCount; - bool controlPressed; - QString lastAnchor; - HelpEngineWrapper &helpEngine; - - bool forceFont; -}; - -QT_END_NAMESPACE - -#endif // HELPVIEWERQTB_H diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 63816fe..4fde20f 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include "helpviewer_qwv.h" +#include "helpviewer.h" #include "centralwidget.h" #include "helpenginewrapper.h" @@ -48,17 +48,21 @@ #include #include -#include #include +#include #include +#include + #include #include #include QT_BEGIN_NAMESPACE +// -- HelpNetworkReply + class HelpNetworkReply : public QNetworkReply { public: @@ -110,6 +114,8 @@ qint64 HelpNetworkReply::readData(char *buffer, qint64 maxlen) return len; } +// -- HelpNetworkAccessManager + class HelpNetworkAccessManager : public QNetworkAccessManager { public: @@ -131,15 +137,14 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, { TRACE_OBJ QString url = request.url().toString(); - HelpEngineWrapper &helpEngine = HelpEngineWrapper::instance(); - + const HelpEngineWrapper &engine = HelpEngineWrapper::instance(); // TODO: For some reason the url to load is already wrong (passed from webkit) // though the css file and the references inside should work that way. One // possible problem might be that the css is loaded at the same level as the // html, thus a path inside the css like (../images/foo.png) might cd out of // the virtual folder - if (!helpEngine.findFile(url).isValid()) { - if (url.startsWith(AbstractHelpViewer::DocPath)) { + if (!engine.findFile(url).isValid()) { + if (url.startsWith(HelpViewer::DocPath)) { QUrl newUrl = request.url(); if (!newUrl.path().startsWith(QLatin1String("/qdoc/"))) { newUrl.setPath(QLatin1String("qdoc") + newUrl.path()); @@ -148,14 +153,16 @@ QNetworkReply *HelpNetworkAccessManager::createRequest(Operation /*op*/, } } - const QString &mimeType = AbstractHelpViewer::mimeFromUrl(url); - const QByteArray &data = helpEngine.findFile(url).isValid() - ? helpEngine.fileData(url) - : AbstractHelpViewer::PageNotFoundMessage.arg(url).toUtf8(); + const QString &mimeType = HelpViewer::mimeFromUrl(url); + const QByteArray &data = engine.findFile(url).isValid() ? engine.fileData(url) + : HelpViewer::PageNotFoundMessage.arg(url).toUtf8(); + return new HelpNetworkReply(request, data, mimeType.isEmpty() ? QLatin1String("application/octet-stream") : mimeType); } +// -- HelpPage + class HelpPage : public QWebPage { public: @@ -188,7 +195,8 @@ HelpPage::HelpPage(QObject *parent) QWebPage *HelpPage::createWindow(QWebPage::WebWindowType) { TRACE_OBJ - HelpPage* newPage = static_cast(OpenPagesManager::instance()->createPage()->page()); + HelpPage* newPage = static_cast(OpenPagesManager::instance() + ->createPage()->page()); newPage->closeNewTabIfNeeded = closeNewTabIfNeeded; closeNewTabIfNeeded = false; return newPage; @@ -214,19 +222,18 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, closeNewTabIfNeeded = false; const QUrl &url = request.url(); - if (AbstractHelpViewer::launchWithExternalApp(url)) { + if (HelpViewer::launchWithExternalApp(url)) { if (closeNewTab) - QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentTab"); + QMetaObject::invokeMethod(OpenPagesManager::instance(), "closeCurrentPage"); return false; } if (type == QWebPage::NavigationTypeLinkClicked - && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton)) { - OpenPagesManager::instance()->createPage(url); - m_pressedButtons = Qt::NoButton; - m_keyboardModifiers = Qt::NoModifier; - return false; + && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) { + m_pressedButtons = Qt::NoButton; + m_keyboardModifiers = Qt::NoModifier; + OpenPagesManager::instance()->createPage(url); + return false; } return true; @@ -234,18 +241,19 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, // -- HelpViewer -HelpViewer::HelpViewer(qreal zoom) - : loadFinished(false) - , helpEngine(HelpEngineWrapper::instance()) +HelpViewer::HelpViewer(qreal zoom, QWidget *parent) + : QWebView(parent) { TRACE_OBJ setAcceptDrops(false); + settings()->setAttribute(QWebSettings::JavaEnabled, false); + settings()->setAttribute(QWebSettings::PluginsEnabled, false); setPage(new HelpPage(this)); page()->setNetworkAccessManager(new HelpNetworkAccessManager(this)); QAction* action = pageAction(QWebPage::OpenLinkInNewWindow); - action->setText(tr("Open Link in New Tab")); + action->setText(tr("Open Link in New Page")); pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false); pageAction(QWebPage::DownloadImageToDisk)->setVisible(false); @@ -257,7 +265,7 @@ HelpViewer::HelpViewer(qreal zoom) SLOT(actionChanged())); connect(pageAction(QWebPage::Forward), SIGNAL(changed()), this, SLOT(actionChanged())); - connect(page(), SIGNAL(linkHovered(QString,QString,QString)), this, + connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); @@ -275,8 +283,8 @@ HelpViewer::~HelpViewer() QFont HelpViewer::viewerFont() const { TRACE_OBJ - if (helpEngine.usesBrowserFont()) - return helpEngine.browserFont(); + if (HelpEngineWrapper::instance().usesBrowserFont()) + return HelpEngineWrapper::instance().browserFont(); QWebSettings *webSettings = QWebSettings::globalSettings(); return QFont(webSettings->fontFamily(QWebSettings::StandardFont), @@ -309,57 +317,145 @@ void HelpViewer::resetScale() setTextSizeMultiplier(1.0); } -bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *e) +qreal HelpViewer::scale() const { TRACE_OBJ - if (e->button() == Qt::XButton1) { - triggerPageAction(QWebPage::Back); - return true; - } + return textSizeMultiplier(); +} - if (e->button() == Qt::XButton2) { - triggerPageAction(QWebPage::Forward); - return true; - } +QString HelpViewer::title() const +{ + TRACE_OBJ + return QWebView::title(); +} + +void HelpViewer::setTitle(const QString &title) +{ + TRACE_OBJ + Q_UNUSED(title) +} - return false; +QUrl HelpViewer::source() const +{ + TRACE_OBJ + return url(); } void HelpViewer::setSource(const QUrl &url) { TRACE_OBJ - loadFinished = false; load(url.toString() == QLatin1String("help") ? LocalHelpFile : url); } -void HelpViewer::home() +QString HelpViewer::selectedText() const +{ + TRACE_OBJ + return QWebView::selectedText(); +} + +bool HelpViewer::isForwardAvailable() const +{ + TRACE_OBJ + return pageAction(QWebPage::Forward)->isEnabled(); +} + +bool HelpViewer::isBackwardAvailable() const +{ + TRACE_OBJ + return pageAction(QWebPage::Back)->isEnabled(); +} + +bool HelpViewer::findText(const QString &text, FindFlags flags, bool incremental, + bool fromSearch) +{ + TRACE_OBJ + Q_UNUSED((incremental && fromSearch)) + QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument; + if (flags & FindBackward) + options |= QWebPage::FindBackward; + if (flags & FindCaseSensitively) + options |= QWebPage::FindCaseSensitively; + + bool found = QWebView::findText(text, options); + options = QWebPage::HighlightAllOccurrences; + QWebView::findText(QLatin1String(""), options); // clear first + QWebView::findText(text, options); // force highlighting of all other matches + return found; +} + +// -- public slots + +void HelpViewer::copy() +{ + TRACE_OBJ + triggerPageAction(QWebPage::Copy); +} + +void HelpViewer::forward() +{ + TRACE_OBJ + QWebView::forward(); +} + +void HelpViewer::backward() +{ + TRACE_OBJ + back(); +} + +// -- protected + +void HelpViewer::keyPressEvent(QKeyEvent *e) { TRACE_OBJ - setSource(helpEngine.homePage()); + // TODO: remove this once we support multiple keysequences per command + if (e->key() == Qt::Key_Insert && e->modifiers() == Qt::CTRL) { + if (!selectedText().isEmpty()) + copy(); + } + QWebView::keyPressEvent(e); } -void HelpViewer::wheelEvent(QWheelEvent *e) +void HelpViewer::wheelEvent(QWheelEvent *event) { TRACE_OBJ - if (e->modifiers()& Qt::ControlModifier) { - e->accept(); - e->delta() > 0 ? scaleUp() : scaleDown(); + if (event->modifiers()& Qt::ControlModifier) { + event->accept(); + event->delta() > 0 ? scaleUp() : scaleDown(); } else { - QWebView::wheelEvent(e); + QWebView::wheelEvent(event); } } -void HelpViewer::mouseReleaseEvent(QMouseEvent *e) +void HelpViewer::mousePressEvent(QMouseEvent *event) +{ + TRACE_OBJ +#ifdef Q_OS_LINUX + if (handleForwardBackwardMouseButtons(event)) + return; +#endif + + if (HelpPage *currentPage = static_cast (page())) { + currentPage->m_pressedButtons = event->buttons(); + currentPage->m_keyboardModifiers = event->modifiers(); + } + + QWebView::mousePressEvent(event); +} + +void HelpViewer::mouseReleaseEvent(QMouseEvent *event) { TRACE_OBJ #ifndef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(e)) + if (handleForwardBackwardMouseButtons(event)) return; #endif - QWebView::mouseReleaseEvent(e); + QWebView::mouseReleaseEvent(event); } +// -- private slots + void HelpViewer::actionChanged() { TRACE_OBJ @@ -372,27 +468,18 @@ void HelpViewer::actionChanged() emit forwardAvailable(a->isEnabled()); } -void HelpViewer::mousePressEvent(QMouseEvent *event) +// -- private + +bool HelpViewer::eventFilter(QObject *obj, QEvent *event) { TRACE_OBJ -#ifdef Q_OS_LINUX - if (handleForwardBackwardMouseButtons(event)) - return; -#endif - - HelpPage *currentPage = static_cast(page()); - if (currentPage) { - currentPage->m_pressedButtons = event->buttons(); - currentPage->m_keyboardModifiers = event->modifiers(); - } - QWebView::mousePressEvent(event); + return QWebView::eventFilter(obj, event); } -void HelpViewer::setLoadFinished(bool ok) +void HelpViewer::contextMenuEvent(QContextMenuEvent *event) { TRACE_OBJ - loadFinished = ok; - emit sourceChanged(url()); + QWebView::contextMenuEvent(event); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.h b/tools/assistant/tools/assistant/helpviewer_qwv.h deleted file mode 100644 index 92d9e11..0000000 --- a/tools/assistant/tools/assistant/helpviewer_qwv.h +++ /dev/null @@ -1,120 +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 Qt Assistant of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt 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 HELPVIEWERQWV_H -#define HELPVIEWERQWV_H - -#include "helpviewer.h" - -#include -#include - -QT_BEGIN_NAMESPACE - -class HelpEngineWrapper; -class QMouseEvent; - -class HelpViewer : public QWebView, public AbstractHelpViewer -{ - Q_OBJECT - -public: - HelpViewer(qreal zoom = 0.0); - ~HelpViewer(); - - QFont viewerFont() const; - void setViewerFont(const QFont &font); - - void scaleUp(); - void scaleDown(); - void resetScale(); - qreal scale() const { return textSizeMultiplier(); } - - bool handleForwardBackwardMouseButtons(QMouseEvent *e); - - void setSource(const QUrl &url); - inline QUrl source() const { return url(); } - - inline QString documentTitle() const - { return title(); } - - inline bool hasSelection() const - { return !selectedText().isEmpty(); } // ### this is suboptimal - - inline void copy() - { return triggerPageAction(QWebPage::Copy); } - - inline bool isForwardAvailable() const - { return pageAction(QWebPage::Forward)->isEnabled(); } - inline bool isBackwardAvailable() const - { return pageAction(QWebPage::Back)->isEnabled(); } - inline bool hasLoadFinished() const - { return loadFinished; } - -public Q_SLOTS: - void home(); - void backward() { back(); } - -Q_SIGNALS: - void copyAvailable(bool enabled); - void forwardAvailable(bool enabled); - void backwardAvailable(bool enabled); - void highlighted(const QString &); - void sourceChanged(const QUrl &); - void titleChanged(); - -protected: - virtual void wheelEvent(QWheelEvent *); - void mouseReleaseEvent(QMouseEvent *e); - void mousePressEvent(QMouseEvent *event); - -private Q_SLOTS: - void actionChanged(); - void setLoadFinished(bool ok); - -private: - bool loadFinished; - HelpEngineWrapper &helpEngine; -}; - -QT_END_NAMESPACE - -#endif // HELPVIEWERQWV_H diff --git a/tools/assistant/tools/assistant/indexwindow.cpp b/tools/assistant/tools/assistant/indexwindow.cpp index 7a47e85..00f61f2 100644 --- a/tools/assistant/tools/assistant/indexwindow.cpp +++ b/tools/assistant/tools/assistant/indexwindow.cpp @@ -38,14 +38,15 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "tracer.h" #include "indexwindow.h" + #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" #include "openpagesmanager.h" #include "topicchooser.h" +#include "tracer.h" #include #include @@ -220,7 +221,7 @@ void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index) return; } - if (!AbstractHelpViewer::canOpenPage(url.path())) + if (!HelpViewer::canOpenPage(url.path())) CentralWidget::instance()->setSource(url); else OpenPagesManager::instance()->createPage(url); diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp index 7a2228f..6db1879 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.cpp +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -42,11 +42,7 @@ #include "centralwidget.h" #include "helpenginewrapper.h" -#if defined(QT_NO_WEBKIT) -#include "helpviewer_qtb.h" -#else -#include "helpviewer_qwv.h" -#endif // QT_NO_WEBKIT +#include "helpviewer.h" #include "openpagesmodel.h" #include "openpageswidget.h" #include "tracer.h" @@ -172,7 +168,7 @@ void OpenPagesManager::closeCurrentPage() HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch) { TRACE_OBJ - if (AbstractHelpViewer::launchWithExternalApp(url)) + if (HelpViewer::launchWithExternalApp(url)) return 0; m_model->addPage(url); diff --git a/tools/assistant/tools/assistant/openpagesmodel.cpp b/tools/assistant/tools/assistant/openpagesmodel.cpp index 92ca1ad..2663b85 100644 --- a/tools/assistant/tools/assistant/openpagesmodel.cpp +++ b/tools/assistant/tools/assistant/openpagesmodel.cpp @@ -41,11 +41,7 @@ #include "openpagesmodel.h" #include "helpenginewrapper.h" -#if defined(QT_NO_WEBKIT) -#include "helpviewer_qtb.h" -#else -#include "helpviewer_qwv.h" -#endif // QT_NO_WEBKIT +#include "helpviewer.h" #include "tracer.h" #include @@ -76,7 +72,7 @@ QVariant OpenPagesModel::data(const QModelIndex &index, int role) const if (!index.isValid() || index.row() >= rowCount() || index.column() > 0 || role != Qt::DisplayRole) return QVariant(); - QString title = m_pages.at(index.row())->documentTitle(); + QString title = m_pages.at(index.row())->title(); title.replace(QLatin1Char('&'), QLatin1String("&&")); return title.isEmpty() ? QLatin1String("(Untitled)") : title; } -- 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 578003cf087f663d23d5d67f96df75c9d50f9456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 6 May 2010 12:24:25 +0200 Subject: Fix tst_qaccessibility::accelerators on Mac QAccessibleInterface::text(QAccessibile::Accelerator) returns the Mac symbol for the key known as ALT on other platforms, so we must use QKeySequence::NativeText when verifying. --- tests/auto/qaccessibility/tst_qaccessibility.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp index e5a332a..b96323e 100644 --- a/tests/auto/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp @@ -4073,7 +4073,8 @@ void tst_QAccessibility::accelerators() window->show(); QAccessibleInterface *accLineEdit = QAccessible::queryAccessibleInterface(le); - QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString() + QLatin1String("L")); + QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("L")); + QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("L")); label->setText(tr("Q &")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString()); label->setText(tr("Q &&")); @@ -4081,11 +4082,11 @@ void tst_QAccessibility::accelerators() label->setText(tr("Q && A")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString()); label->setText(tr("Q &&&A")); - QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString() + QLatin1String("A")); + QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A")); label->setText(tr("Q &&A")); QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QString()); label->setText(tr("Q &A&B")); - QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString() + QLatin1String("A")); + QCOMPARE(accLineEdit->text(QAccessible::Accelerator, 0), QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + QLatin1String("A")); #if defined(Q_WS_X11) qt_x11_wait_for_window_manager(window); -- cgit v0.12 From e248183fc443c0e2c133506dfb7c38560aee4948 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 6 May 2010 18:46:49 +0200 Subject: QMetaObject::invokeMethod using Qt::BlockingQueuedConnection can handle the return value. When using Qt::BlockingQueuedConnection, we do not need to copy the arguments, and we can handle the return type. The argv we pass to the event is the param vector alocated on the stack. Since we don't need to destroy the argument, we can pass 0 for the types. The private QMetaCallEvent destructor is modified not to destroy the arguments if types_ is 0 Task-number: QTBUG-10440 Reviewed-by: Brad --- src/corelib/kernel/qmetaobject.cpp | 53 +++++------ src/corelib/kernel/qobject.cpp | 12 +-- tests/auto/qmetaobject/tst_qmetaobject.cpp | 136 +++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 38 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 4ad78fd..c2e12f8 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1548,6 +1548,12 @@ bool QMetaMethod::invoke(QObject *object, : Qt::QueuedConnection; } +#ifdef QT_NO_THREAD + if (connectionType == Qt::BlockingQueuedConnection) { + connectionType = Qt::DirectConnection; + } +#endif + // invoke! void *param[] = { returnValue.data(), @@ -1566,7 +1572,7 @@ bool QMetaMethod::invoke(QObject *object, int methodIndex = ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset(); if (connectionType == Qt::DirectConnection) { return QMetaObject::metacall(object, QMetaObject::InvokeMetaMethod, methodIndex, param) < 0; - } else { + } else if (connectionType == Qt::QueuedConnection) { if (returnValue.data()) { qWarning("QMetaMethod::invoke: Unable to invoke methods with return values in " "queued connections"); @@ -1599,40 +1605,21 @@ bool QMetaMethod::invoke(QObject *object, } } - if (connectionType == Qt::QueuedConnection) { - QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex, - 0, - -1, - nargs, - types, - args)); - } else { - if (currentThread == objectThread) { - qWarning("QMetaMethod::invoke: Dead lock detected in " - "BlockingQueuedConnection: Receiver is %s(%p)", - mobj->className(), object); - } + QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex, + 0, -1, nargs, types, args)); + } else { // blocking queued connection +#ifndef QT_NO_THREAD + if (currentThread == objectThread) { + qWarning("QMetaMethod::invoke: Dead lock detected in " + "BlockingQueuedConnection: Receiver is %s(%p)", + mobj->className(), object); + } - // blocking queued connection -#ifdef QT_NO_THREAD - QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex, - 0, - -1, - nargs, - types, - args)); -#else - QSemaphore semaphore; - QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex, - 0, - -1, - nargs, - types, - args, - &semaphore)); - semaphore.acquire(); + QSemaphore semaphore; + QCoreApplication::postEvent(object, new QMetaCallEvent(methodIndex, + 0, -1, 0, 0, param, &semaphore)); + semaphore.acquire(); #endif // QT_NO_THREAD - } } return true; } diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 6a6db51..0f419bd 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -515,12 +515,14 @@ QMetaCallEvent::QMetaCallEvent(int id, const QObject *sender, int signalId, */ QMetaCallEvent::~QMetaCallEvent() { - for (int i = 0; i < nargs_; ++i) { - if (types_[i] && args_[i]) - QMetaType::destroy(types_[i], args_[i]); + if (types_) { + for (int i = 0; i < nargs_; ++i) { + if (types_[i] && args_[i]) + QMetaType::destroy(types_[i], args_[i]); + } + qFree(types_); + qFree(args_); } - if (types_) qFree(types_); - if (args_) qFree(args_); #ifndef QT_NO_THREAD if (semaphore_) semaphore_->release(); diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index c0b1303..0ef452c 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -155,6 +155,7 @@ private slots: void connectSlotsByName(); void invokeMetaMember(); void invokeQueuedMetaMember(); + void invokeBlockingQueuedMetaMember(); void invokeCustomTypes(); void invokeMetaConstructor(); void invokeTypedefTypes(); @@ -334,6 +335,9 @@ public slots: void testLongLong(qint64 ll1, quint64 ll2); + void moveToThread(QThread *t) + { QObject::moveToThread(t); } + signals: void sig0(); QString sig1(QString s1); @@ -581,6 +585,138 @@ void tst_QMetaObject::invokeQueuedMetaMember() QCOMPARE(obj.slotResult, QString("testLongLong:-1,0")); } +void tst_QMetaObject::invokeBlockingQueuedMetaMember() +{ + QThread t; + t.start(); + QtTestObject obj; + obj.moveToThread(&t); + + QString t1("1"); QString t2("2"); QString t3("3"); QString t4("4"); QString t5("5"); + QString t6("6"); QString t7("7"); QString t8("8"); QString t9("9"); QString t10("X"); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl1", Qt::BlockingQueuedConnection, Q_ARG(QString, t1))); + QCOMPARE(obj.slotResult, QString("sl1:1")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl2", Qt::BlockingQueuedConnection, Q_ARG(const QString, t1), Q_ARG(QString, t2))); + QCOMPARE(obj.slotResult, QString("sl2:12")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl3", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), Q_ARG(QString, t3))); + QCOMPARE(obj.slotResult, QString("sl3:123")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl4", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), + Q_ARG(QString, t3), Q_ARG(QString, t4))); + QCOMPARE(obj.slotResult, QString("sl4:1234")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl5", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), + Q_ARG(QString, t3), Q_ARG(QString, t4), Q_ARG(QString, "5"))); + QCOMPARE(obj.slotResult, QString("sl5:12345")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl6", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), + Q_ARG(QString, t3), Q_ARG(QString, t4), Q_ARG(QString, t5), Q_ARG(QString, t6))); + QCOMPARE(obj.slotResult, QString("sl6:123456")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl7", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), + Q_ARG(QString, t3), Q_ARG(QString, t4), Q_ARG(QString, t5), Q_ARG(QString, t6), + Q_ARG(QString, t7))); + QCOMPARE(obj.slotResult, QString("sl7:1234567")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl8", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), + Q_ARG(QString, t3), Q_ARG(QString, t4), Q_ARG(QString, t5), Q_ARG(QString, t6), + Q_ARG(QString, t7), Q_ARG(QString, t8))); + QCOMPARE(obj.slotResult, QString("sl8:12345678")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl9", Qt::BlockingQueuedConnection, Q_ARG(QString, t1), Q_ARG(QString, t2), + Q_ARG(QString, t3), Q_ARG(QString, t4), Q_ARG(QString, t5), Q_ARG(QString, t6), + Q_ARG(QString, t7), Q_ARG(QString, t8), Q_ARG(QString, t9))); + QCOMPARE(obj.slotResult, QString("sl9:123456789")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Qt::BlockingQueuedConnection)); + QCOMPARE(obj.slotResult, QString("sl11")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "testSender", Qt::BlockingQueuedConnection)); + QCOMPARE(obj.slotResult, QString("0x0")); + + QString refStr("whatever"); + QVERIFY(QMetaObject::invokeMethod(&obj, "testReference", Qt::BlockingQueuedConnection, QGenericArgument("QString&", &refStr))); + QCOMPARE(obj.slotResult, QString("testReference:whatever")); + QCOMPARE(refStr, QString("gotcha")); + + qint64 ll1 = -1; + quint64 ll2 = 0; + QVERIFY(QMetaObject::invokeMethod(&obj, + "testLongLong", + Qt::BlockingQueuedConnection, + Q_ARG(qint64, ll1), + Q_ARG(quint64, ll2))); + QCOMPARE(obj.slotResult, QString("testLongLong:-1,0")); + + QString exp; + QVERIFY(QMetaObject::invokeMethod(&obj, "sl1", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, exp), Q_ARG(QString, "bubu"))); + QCOMPARE(exp, QString("yessir")); + QCOMPARE(obj.slotResult, QString("sl1:bubu")); + + QObject *ptr = 0; + QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QObject*,ptr))); + QCOMPARE(ptr, (QObject *)&obj); + QCOMPARE(obj.slotResult, QString("sl11")); + // try again with a space: + ptr = 0; + QVERIFY(QMetaObject::invokeMethod(&obj, "sl11", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QObject * , ptr))); + QCOMPARE(ptr, (QObject *)&obj); + QCOMPARE(obj.slotResult, QString("sl11")); + + const char *ptr2 = 0; + QVERIFY(QMetaObject::invokeMethod(&obj, "sl12", Qt::BlockingQueuedConnection, Q_RETURN_ARG(const char*, ptr2))); + QVERIFY(ptr2 != 0); + QCOMPARE(obj.slotResult, QString("sl12")); + // try again with a space: + ptr2 = 0; + QVERIFY(QMetaObject::invokeMethod(&obj, "sl12", Qt::BlockingQueuedConnection, Q_RETURN_ARG(char const * , ptr2))); + QVERIFY(ptr2 != 0); + QCOMPARE(obj.slotResult, QString("sl12")); + + // test w/ template args + QList returnValue, argument; + argument << QString("one") << QString("two") << QString("three"); + QVERIFY(QMetaObject::invokeMethod(&obj, "sl13", Qt::BlockingQueuedConnection, + Q_RETURN_ARG(QList, returnValue), + Q_ARG(QList, argument))); + QCOMPARE(returnValue, argument); + QCOMPARE(obj.slotResult, QString("sl13")); + + //test signals + QVERIFY(QMetaObject::invokeMethod(&obj, "sig0", Qt::BlockingQueuedConnection)); + QCOMPARE(obj.slotResult, QString("sl0")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "sig1", Qt::BlockingQueuedConnection, Q_ARG(QString, "baba"))); + QCOMPARE(obj.slotResult, QString("sl1:baba")); + + exp.clear(); + QVERIFY(QMetaObject::invokeMethod(&obj, "sig1", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QString, exp), Q_ARG(QString, "hehe"))); + QCOMPARE(exp, QString("yessir")); + QCOMPARE(obj.slotResult, QString("sl1:hehe")); + + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::doesNotExist()"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist", Qt::BlockingQueuedConnection)); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"))); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"))); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)"); + QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg"))); + + //should not have changed since last test. + QCOMPARE(exp, QString("yessir")); + QCOMPARE(obj.slotResult, QString("sl1:hehe")); + + QVERIFY(QMetaObject::invokeMethod(&obj, "moveToThread", Qt::BlockingQueuedConnection, Q_ARG(QThread*, QThread::current()))); + t.quit(); + QVERIFY(t.wait()); + +} + + void tst_QMetaObject::qtMetaObjectInheritance() { -- cgit v0.12 From 991943cabe0c972b8e67f73bf47b0c87c97eb6a2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 6 May 2010 21:04:59 +0200 Subject: QObject: Optimize BlockingQueuedConnection connections We do not need to copy the argument as we do for QueuedConnection Same logic as the previous change. Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 53 ++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0f419bd..8a4304e 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2562,7 +2562,7 @@ bool QObject::connect(const QObject *sender, const char *signal, } int *types = 0; - if ((type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection) + if ((type == Qt::QueuedConnection) && !(types = queuedConnectionTypes(smeta->method(signal_absolute_index).parameterTypes()))) return false; @@ -3117,8 +3117,7 @@ void QMetaObject::connectSlotsByName(QObject *o) } } -static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, - void **argv, QSemaphore *semaphore = 0) +static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv) { if (!c->argumentTypes && c->argumentTypes != &DIRECT_CONNECTION_ONLY) { QMetaMethod m = sender->metaObject()->method(signal); @@ -3148,30 +3147,9 @@ static void queued_activate(QObject *sender, int signal, QObjectPrivate::Connect signal, nargs, types, - args, - semaphore)); + args)); } -static void blocking_activate(QObject *sender, int signal, QObjectPrivate::Connection *c, void **argv) -{ - if (QThread::currentThread() == c->receiver->thread()) { - qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: " - "Sender is %s(%p), receiver is %s(%p)", - sender->metaObject()->className(), sender, - c->receiver->metaObject()->className(), c->receiver); - } - -#ifdef QT_NO_THREAD - queued_activate(sender, signal, c, argv); -#else - QSemaphore semaphore; - queued_activate(sender, signal, c, argv, &semaphore); - QMutex *mutex = signalSlotLock(sender); - mutex->unlock(); - semaphore.acquire(); - mutex->lock(); -#endif -} /*!\internal \obsolete. @@ -3235,23 +3213,38 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign continue; QObject * const receiver = c->receiver; + const int method = c->method; + const bool receiverInSameThread = currentThreadData == receiver->d_func()->threadData; // determine if this connection should be sent immediately or // put into the event queue if ((c->connectionType == Qt::AutoConnection - && (currentThreadData != sender->d_func()->threadData + && (!receiverInSameThread || receiver->d_func()->threadData != sender->d_func()->threadData)) || (c->connectionType == Qt::QueuedConnection)) { queued_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv); continue; +#ifndef QT_NO_THREAD } else if (c->connectionType == Qt::BlockingQueuedConnection) { - blocking_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv); + locker.unlock(); + if (receiverInSameThread) { + qWarning("Qt: Dead lock detected while activating a BlockingQueuedConnection: " + "Sender is %s(%p), receiver is %s(%p)", + sender->metaObject()->className(), sender, + receiver->metaObject()->className(), receiver); + } + QSemaphore semaphore; + QCoreApplication::postEvent(receiver, new QMetaCallEvent(method, + sender, signal_absolute_index, + 0, 0, + argv ? argv : empty_argv, + &semaphore)); + semaphore.acquire(); + locker.relock(); continue; +#endif } - - const int method = c->method; QObjectPrivate::Sender currentSender; - const bool receiverInSameThread = currentThreadData == receiver->d_func()->threadData; QObjectPrivate::Sender *previousSender = 0; if (receiverInSameThread) { currentSender.sender = sender; -- cgit v0.12 From 8955e088aa9e4b0496c32f27206fd6211a85782f Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 5 May 2010 16:36:02 +0200 Subject: Fix for qfsfileengine_win to return proper absolute path for C:\ When using canonicalPath on a QDir that currently just represents a root directory, a valid path name such as "C:\" should be returned. Previously we returned "C:" which in fact would point to the current working directory on drive C: and therefor is not necessarily the same. Reviewed-by: Thiago Task-number: QTBUG-6680 --- src/corelib/io/qfsfileengine_win.cpp | 10 +++++---- tests/auto/qdir/tst_qdir.cpp | 41 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index cc9b8c7..254c03e 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1664,10 +1664,12 @@ QString QFSFileEngine::fileName(FileName file) const if (!isRelativePath()) { #if !defined(Q_OS_WINCE) - if ((d->filePath.size() > 2 && d->filePath.at(1) == QLatin1Char(':') - && d->filePath.at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt - d->filePath.startsWith(QLatin1Char('/')) // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt - ) { + if (d->filePath.startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt + d->filePath.size() == 2 || // It's a drive letter that needs to get a working dir appended + (d->filePath.size() > 2 && d->filePath.at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt + d->filePath.contains(QLatin1String("/../")) || d->filePath.contains(QLatin1String("/./")) || + d->filePath.endsWith(QLatin1String("/..")) || d->filePath.endsWith(QLatin1String("/."))) + { ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(d->filePath)); } else { ret = d->filePath; diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 71469bb..b2dc960 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -172,6 +172,11 @@ private slots: void longFileName(); void updateFileLists(); + +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + void isRoot_data(); + void isRoot(); +#endif }; // Testing get/set functions @@ -805,6 +810,16 @@ void tst_QDir::canonicalPath_data() QTest::newRow("absPath") << appPath + "\\testData\\..\\testData" << appPath + "/testData"; #endif QTest::newRow("nonexistant") << "testd" << QString(); + +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) + QTest::newRow("drive:/") << QDir::rootPath() << QDir::rootPath(); + QTest::newRow("drive:\\") << QDir::toNativeSeparators(QDir::rootPath()) << QDir::rootPath(); + QTest::newRow("drive:/./") << QDir::rootPath().append("./") << QDir::rootPath(); + QTest::newRow("drive:/../.. ") << QDir::rootPath().append("../..") << QDir::rootPath(); + QTest::newRow("drive:\\.\\") << QDir::toNativeSeparators(QDir::rootPath().append("./")) << QDir::rootPath(); + QTest::newRow("drive:\\..\\..") << QDir::toNativeSeparators(QDir::rootPath().append("../..")) << QDir::rootPath(); + QTest::newRow("drive:") << QDir::rootPath().left(2) << QDir::currentPath(); +#endif } void tst_QDir::canonicalPath() @@ -1546,6 +1561,32 @@ void tst_QDir::updateFileLists() QCOMPARE(dir.entryList(), QStringList() << "sub-dir1" << "sub-dir2" << "file1.txt"); } +#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) +void tst_QDir::isRoot_data() +{ + QTest::addColumn("path"); + QTest::addColumn("isRoot"); + + QString test = QDir::rootPath(); + QTest::newRow("rootPath " + test) << test << true; + test = QDir::rootPath().append("./"); + QTest::newRow("./ appended " + test) << test << false; + test = QDir(QDir::rootPath().append("./")).canonicalPath(); + QTest::newRow("canonicalPath " + test) << test << true; + test = QDir::rootPath().left(2); + QTest::newRow("drive relative " + test) << test << false; +} + +void tst_QDir::isRoot() +{ + QFETCH(QString, path); + QFETCH(bool, isRoot); + + QDir dir(path); + QCOMPARE(dir.isRoot(),isRoot); +} +#endif + QTEST_MAIN(tst_QDir) #include "tst_qdir.moc" -- cgit v0.12 From 62096261a9a07968eeaa77ef205f33a570913377 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 7 May 2010 14:58:58 +0200 Subject: Fix compilation of the tst_qmetaobject test --- tests/auto/qmetaobject/tst_qmetaobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp index 0ef452c..370403e 100644 --- a/tests/auto/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp @@ -710,7 +710,7 @@ void tst_QMetaObject::invokeBlockingQueuedMetaMember() QCOMPARE(exp, QString("yessir")); QCOMPARE(obj.slotResult, QString("sl1:hehe")); - QVERIFY(QMetaObject::invokeMethod(&obj, "moveToThread", Qt::BlockingQueuedConnection, Q_ARG(QThread*, QThread::current()))); + QVERIFY(QMetaObject::invokeMethod(&obj, "moveToThread", Qt::BlockingQueuedConnection, Q_ARG(QThread*, QThread::currentThread()))); t.quit(); QVERIFY(t.wait()); -- cgit v0.12 From 5f52316a90b7e77295cefc5fac9d4acd0761d79f Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Mon, 10 May 2010 09:50:18 +0200 Subject: Fix tst_qdir to use const char* instead of QString for QTest::newRow This is only needed to compile on msvc2005 Reviewed-by: TrustMe --- tests/auto/qdir/tst_qdir.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index b2dc960..4704bb8 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -1568,13 +1568,13 @@ void tst_QDir::isRoot_data() QTest::addColumn("isRoot"); QString test = QDir::rootPath(); - QTest::newRow("rootPath " + test) << test << true; + QTest::newRow(QString("rootPath " + test).toLatin1()) << test << true; test = QDir::rootPath().append("./"); - QTest::newRow("./ appended " + test) << test << false; + QTest::newRow(QString("./ appended " + test).toLatin1()) << test << false; test = QDir(QDir::rootPath().append("./")).canonicalPath(); - QTest::newRow("canonicalPath " + test) << test << true; + QTest::newRow(QString("canonicalPath " + test).toLatin1()) << test << true; test = QDir::rootPath().left(2); - QTest::newRow("drive relative " + test) << test << false; + QTest::newRow(QString("drive relative " + test).toLatin1()) << test << false; } void tst_QDir::isRoot() -- 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 b32a3940f0d23332c73b8e0b60c442cdda91e67e Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Mon, 10 May 2010 13:25:54 +0200 Subject: Fix for root path issue in tst_qdir. (case "drive:") Windows only: Since the working directory is not necessarily located on the root drive, we should not rely on rootPath for the test. Reviewed-by: TrustMe --- tests/auto/qdir/tst_qdir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 4704bb8..661a4c7 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -818,7 +818,7 @@ void tst_QDir::canonicalPath_data() QTest::newRow("drive:/../.. ") << QDir::rootPath().append("../..") << QDir::rootPath(); QTest::newRow("drive:\\.\\") << QDir::toNativeSeparators(QDir::rootPath().append("./")) << QDir::rootPath(); QTest::newRow("drive:\\..\\..") << QDir::toNativeSeparators(QDir::rootPath().append("../..")) << QDir::rootPath(); - QTest::newRow("drive:") << QDir::rootPath().left(2) << QDir::currentPath(); + QTest::newRow("drive:") << QDir().canonicalPath().left(2) << QDir().canonicalPath(); #endif } -- 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 10f6220cc37207dbc35bd013af727552fb3799f7 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Tue, 11 May 2010 16:10:32 +0200 Subject: Fix the hidden status check for a file on Mac OS X. Add some more tests that would have failed before the fix. Remove test files after the run. Task-number: QTBUG-6619 Reviewed-by: Morten Sorvig --- src/corelib/io/qfsfileengine_unix.cpp | 3 +++ tests/auto/qfileinfo/tst_qfileinfo.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp index 5762d94..569801a 100644 --- a/src/corelib/io/qfsfileengine_unix.cpp +++ b/src/corelib/io/qfsfileengine_unix.cpp @@ -890,6 +890,9 @@ QAbstractFileEngine::FileFlags QFSFileEngine::fileFlags(FileFlags type) const if ((baseName.size() > 0 && baseName.at(0) == QLatin1Char('.')) # if !defined(QWS) && defined(Q_OS_MAC) || _q_isMacHidden(d->filePath) +# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + || d->st.st_flags & UF_HIDDEN +# endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 # endif ) { ret |= HiddenFlag; diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index f61426d..c7dce28 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -190,6 +190,8 @@ tst_QFileInfo::~tst_QFileInfo() QFile::remove("link.lnk"); QFile::remove("file1"); QFile::remove("dummyfile"); + QFile::remove("simplefile.txt"); + QFile::remove("longFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileNamelongFileName.txt"); #ifdef Q_OS_SYMBIAN QFile::remove("hidden.txt"); QFile::remove("nothidden.txt"); @@ -199,6 +201,7 @@ tst_QFileInfo::~tst_QFileInfo() #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) QDir().rmdir("./.hidden-directory"); + QFile::remove("link_to_tst_qfileinfo"); #endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) QDir().rmdir("./hidden-directory"); @@ -1128,6 +1131,8 @@ void tst_QFileInfo::isHidden_data() #if defined(Q_OS_MAC) // /bin has the hidden attribute on Mac OS X QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << true; + QTest::newRow("/dev/") << QString::fromLatin1("/dev/") << true; + QTest::newRow("/net/") << QString::fromLatin1("/net/") << true; #elif !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << false; #endif -- cgit v0.12 From e35304444d6413d00c2090fab5d8173e6b6b7f26 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 12 May 2010 12:18:54 +0200 Subject: QScriptValue autotest generator modification. Generator shouldn't leave whitespace at the end of line in the generated code. Reviewed-by: Kent Hansen --- tests/auto/qscriptvalue/testgen/testgenerator.cpp | 41 ++++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/tests/auto/qscriptvalue/testgen/testgenerator.cpp b/tests/auto/qscriptvalue/testgen/testgenerator.cpp index a291110..8e6d8e1 100644 --- a/tests/auto/qscriptvalue/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvalue/testgen/testgenerator.cpp @@ -238,17 +238,19 @@ static QString generateToXXXDef(const QString& name, const QList t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%2)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(name, typeName(), @@ -301,18 +303,21 @@ QString generateToXXXDef(const QString& name, const QList t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%10)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert(t.second)); - valueSet.append(QString::fromAscii(", ")); } + // toInteger shouldn't return NaN, so it would be nice to catch the case. QString hook; if (name == "toNumber") { @@ -367,17 +372,19 @@ static QString generateCastDef(const QList >& list) QStringList tagSet, valueSet; tagSet.reserve(list.count()); valueSet.reserve(list.count()); - int tmp = -1; - for(; i != list.constEnd(); ++i) { + for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%2)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(typeName(), tagSet.join(QString()), valueSet.join(QString()), QString::number(list.count())); } @@ -429,17 +436,19 @@ QString generateCastDef(const QList >& list) QStringList tagSet, valueSet; tagSet.reserve(list.count()); valueSet.reserve(list.count()); - int tmp = -1; - for(; i != list.constEnd(); ++i) { + for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair t = *i; t.first = escape(t.first); tagSet.append(QString("\n \"")); tagSet.append(t.first); tagSet.append(QString::fromAscii("\",")); - if (!((++tmp)%10)) + if (!valueSet.isEmpty()) + valueSet.append(QString(",")); + if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); + else + valueSet.append(QString::fromAscii(" ")); valueSet.append(prepareToInsert(t.second)); - valueSet.append(QString::fromAscii(", ")); } return result.arg(typeName(), tagSet.join(QString()), -- cgit v0.12 From 366913da05d833ebf447a061f9d859ec3a344658 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 12 May 2010 15:32:40 +0200 Subject: Fix Mac-specific tests about the hidden attribute. Create a new test only for Mac. --- tests/auto/qfileinfo/tst_qfileinfo.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfileinfo/tst_qfileinfo.cpp b/tests/auto/qfileinfo/tst_qfileinfo.cpp index c7dce28..4387553 100644 --- a/tests/auto/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/qfileinfo/tst_qfileinfo.cpp @@ -155,6 +155,9 @@ private slots: void isHidden_data(); void isHidden(); +#if defined(Q_OS_MAC) + void isHiddenFromFinder(); +#endif void isBundle_data(); void isBundle(); @@ -1131,8 +1134,6 @@ void tst_QFileInfo::isHidden_data() #if defined(Q_OS_MAC) // /bin has the hidden attribute on Mac OS X QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << true; - QTest::newRow("/dev/") << QString::fromLatin1("/dev/") << true; - QTest::newRow("/net/") << QString::fromLatin1("/net/") << true; #elif !defined(Q_OS_WIN) && !defined(Q_OS_SYMBIAN) QTest::newRow("/bin/") << QString::fromLatin1("/bin/") << false; #endif @@ -1182,6 +1183,27 @@ void tst_QFileInfo::isHidden() QCOMPARE(fi.isHidden(), isHidden); } +#if defined(Q_OS_MAC) +void tst_QFileInfo::isHiddenFromFinder() +{ + const char *filename = "test_foobar.txt"; + + QFile testFile(filename); + testFile.open(QIODevice::WriteOnly | QIODevice::Append); + testFile.write(QByteArray("world")); + testFile.close(); + + struct stat buf; + stat(filename, &buf); + chflags(filename, buf.st_flags | UF_HIDDEN); + + QFileInfo fi(filename); + QCOMPARE(fi.isHidden(), true); + + testFile.remove(); +} +#endif + void tst_QFileInfo::isBundle_data() { QTest::addColumn("path"); -- cgit v0.12 From 0c6973b15cc3884f35d7d414ab7d23d365c768e8 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 12 May 2010 17:07:42 +0200 Subject: Fix a coding style issue in a generated code in the QScriptValue tests. Fix the generator, few redundant commas and spaces where removed from generated code. The autotest suite wasn't regenerated. Reviewed-by: Kent Hansen --- tests/auto/qscriptvalue/testgen/testgenerator.cpp | 82 +++++++++++++---------- 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/tests/auto/qscriptvalue/testgen/testgenerator.cpp b/tests/auto/qscriptvalue/testgen/testgenerator.cpp index 8e6d8e1..9d7d33d 100644 --- a/tests/auto/qscriptvalue/testgen/testgenerator.cpp +++ b/tests/auto/qscriptvalue/testgen/testgenerator.cpp @@ -162,7 +162,7 @@ static QString generateIsXXXDef(const QString& name, const QList& list) " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString %1_array [] = {%2};\n\n"\ + "static QString %1_array[] = {%2};\n\n"\ "void tst_QScriptValue::%1_makeData(const char* expr)\n"\ "{\n"\ " static QSet %1;\n"\ @@ -193,9 +193,11 @@ static QString generateIsXXXDef(const QString& name, const QList& list) QStringList set; set.reserve(3 * list.count()); foreach(const QString& t, list) { + if (!set.isEmpty()) + set.append("\","); set.append("\n \""); set.append(escape(t)); - set.append("\","); + set.append("\""); } return result.arg(name, set.join(QString()), QString::number(list.count())); @@ -211,8 +213,8 @@ static QString generateToXXXDef(const QString& name, const QList %1;\n"\ @@ -236,16 +238,18 @@ static QString generateToXXXDef(const QString& name, const QList >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); else @@ -270,8 +274,8 @@ QString generateToXXXDef(const QString& name, const QList %1;\n"\ @@ -301,16 +305,18 @@ QString generateToXXXDef(const QString& name, const QList >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); else @@ -345,8 +351,8 @@ static QString generateCastDef(const QList >& list) " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString qscriptvalue_cast%1_tagArray [] = {%2};\n"\ - "static %1 qscriptvalue_cast%1_valueArray [] = {%3};\n"\ + "static QString qscriptvalue_cast%1_tagArray[] = {%2};\n"\ + "static %1 qscriptvalue_cast%1_valueArray[] = {%3};\n"\ "void tst_QScriptValue::qscriptvalue_cast%1_makeData(const char* expr)\n"\ "{\n"\ " static QHash value;\n"\ @@ -370,16 +376,18 @@ static QString generateCastDef(const QList >& list) typename QList >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%2)) valueSet.append(QString("\n ")); else @@ -399,8 +407,8 @@ QString generateCastDef(const QList >& list) " initScriptValues();\n"\ "}\n"\ "\n"\ - "static QString qscriptvalue_cast%1_tagArray [] = {%2};\n"\ - "static %1 qscriptvalue_cast%1_valueArray [] = {%3};\n"\ + "static QString qscriptvalue_cast%1_tagArray[] = {%2};\n"\ + "static %1 qscriptvalue_cast%1_valueArray[] = {%3};\n"\ "void tst_QScriptValue::qscriptvalue_cast%1_makeData(const char* expr)\n"\ "{\n"\ " static QHash value;\n"\ @@ -434,16 +442,18 @@ QString generateCastDef(const QList >& list) QList >::const_iterator i = list.constBegin(); QStringList tagSet, valueSet; - tagSet.reserve(list.count()); - valueSet.reserve(list.count()); + tagSet.reserve(4 * list.count()); + valueSet.reserve(3 * list.count()); for(int lineBreaker = 0; i != list.constEnd(); ++i) { QPair t = *i; t.first = escape(t.first); + if (!valueSet.isEmpty()) { + valueSet.append(QString(",")); + tagSet.append(QString::fromAscii(",")); + } tagSet.append(QString("\n \"")); tagSet.append(t.first); - tagSet.append(QString::fromAscii("\",")); - if (!valueSet.isEmpty()) - valueSet.append(QString(",")); + tagSet.append(QString::fromAscii("\"")); if (!((lineBreaker++)%10)) valueSet.append(QString("\n ")); else @@ -466,7 +476,7 @@ static QString generateCompareDef(const QString& comparisionType, const QList equals;\n"\ @@ -497,9 +507,13 @@ static QString generateCompareDef(const QString& comparisionType, const QList& allDataTags) static const QString templ = "void tst_QScriptValue::initScriptValues()\n"\ "{\n"\ " m_values.clear();\n"\ - " if (engine) \n"\ + " if (engine)\n"\ " delete engine;\n"\ " engine = new QScriptEngine;\n"\ "%1\n}\n\n"; -- cgit v0.12 From 2e649d8dc0c1ce0b54ac10e8c95ce6d047bdb0db Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 12 May 2010 15:07:52 +0200 Subject: Assistant: Enable switching between pages via an in-page combo box. --- tools/assistant/tools/assistant/helpviewer.cpp | 29 +++++++++++++++ tools/assistant/tools/assistant/helpviewer.h | 3 ++ tools/assistant/tools/assistant/helpviewer_p.h | 42 ++++++++++++++++++++-- tools/assistant/tools/assistant/helpviewer_qtb.cpp | 16 +++++---- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 16 +++++---- .../assistant/tools/assistant/openpagesmanager.cpp | 2 +- tools/assistant/tools/assistant/openpagesmanager.h | 8 ++--- 7 files changed, 95 insertions(+), 21 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index dfcacd1..81870a9 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -40,6 +40,8 @@ ****************************************************************************/ #include "helpviewer.h" +#include "helpviewer_p.h" + #include "helpenginewrapper.h" #include "tracer.h" @@ -49,6 +51,7 @@ #include #include +#include #include #include @@ -205,4 +208,30 @@ bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event) return false; } +bool HelpViewer::openPagesListRequested(const QMouseEvent *event) const +{ + return event->buttons() == Qt::RightButton + && event->modifiers() == Qt::ControlModifier; +} + +bool HelpViewer::openPagesListRequested(const QContextMenuEvent *event) const +{ + return event->reason() == QContextMenuEvent::Mouse + && event->modifiers() == Qt::ControlModifier; +} + +void HelpViewer::showOpenPagesList(const QPoint &pos) +{ + QComboBox * const openPagesBox = d->openPagesBox(this); + openPagesBox->move(pos); + openPagesBox->setCurrentIndex(CentralWidget::instance()->currentIndex()); + openPagesBox->showPopup(); +} + +HelpViewer::~HelpViewer() +{ + TRACE_OBJ + delete d; +} + QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index fc3d753..d881545 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -144,6 +144,9 @@ private: void contextMenuEvent(QContextMenuEvent *event); QVariant loadResource(int type, const QUrl &name); bool handleForwardBackwardMouseButtons(QMouseEvent *e); + bool openPagesListRequested(const QMouseEvent *event) const; + bool openPagesListRequested(const QContextMenuEvent *event) const; + void showOpenPagesList(const QPoint &pos); private: HelpViewerPrivate *d; diff --git a/tools/assistant/tools/assistant/helpviewer_p.h b/tools/assistant/tools/assistant/helpviewer_p.h index 631d65f..2bd4e16 100644 --- a/tools/assistant/tools/assistant/helpviewer_p.h +++ b/tools/assistant/tools/assistant/helpviewer_p.h @@ -47,7 +47,11 @@ #include "openpagesmanager.h" #include +#include +#ifdef QT_NO_WEBKIT #include +#endif +#include QT_BEGIN_NAMESPACE @@ -56,13 +60,19 @@ class HelpViewer::HelpViewerPrivate : public QObject Q_OBJECT public: +#ifdef QT_NO_WEBKIT HelpViewerPrivate(int zoom) : zoomCount(zoom) , forceFont(false) , lastAnchor(QString()) - - {} +#else + HelpViewerPrivate() +#endif + { + m_openPagesBox = 0; + } +#ifdef QT_NO_WEBKIT bool hasAnchorAt(QTextBrowser *browser, const QPoint& pos) { lastAnchor = browser->anchorAt(pos); @@ -88,8 +98,25 @@ public: CentralWidget::instance()->setSource(lastAnchor); lastAnchor.clear(); } +#endif // QT_NO_WEBKIT + + QComboBox *openPagesBox(QWidget *parent = 0) + { + if (!m_openPagesBox) { + m_openPagesBox = new QComboBox(parent); + m_openPagesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); + m_openPagesBox->setModel(OpenPagesManager::instance() + ->openPagesWidget()->model()); + connect(m_openPagesBox, SIGNAL(activated(int)), this, + SLOT(switchToPage(int))); + } + + return m_openPagesBox; + } public slots: + +#ifdef QT_NO_WEBKIT void openLink() { openLink(false); @@ -104,6 +131,17 @@ public: int zoomCount; bool forceFont; QString lastAnchor; +#endif // QT_NO_WEBKIT + +private slots: + + void switchToPage(int row) + { + OpenPagesManager::instance()->setCurrentPage(row); + } + +private: + QComboBox *m_openPagesBox; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index a73e1e1..98eb59f 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -79,12 +79,6 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent) connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); } -HelpViewer::~HelpViewer() -{ - TRACE_OBJ - delete d; -} - QFont HelpViewer::viewerFont() const { TRACE_OBJ @@ -304,6 +298,11 @@ void HelpViewer::mousePressEvent(QMouseEvent *e) if (handleForwardBackwardMouseButtons(e)) return; #endif + if (openPagesListRequested(e)) { + showOpenPagesList(e->pos()); + return; + } + QTextBrowser::mousePressEvent(e); } @@ -346,8 +345,11 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event) void HelpViewer::contextMenuEvent(QContextMenuEvent *event) { TRACE_OBJ - QMenu menu(QLatin1String(""), 0); + if (openPagesListRequested(event)) + return; + + QMenu menu(QString(), 0); QUrl link; QAction *copyAnchorAction = 0; if (d->hasAnchorAt(this, event->pos())) { diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 4fde20f..f9c8161 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "helpviewer.h" +#include "helpviewer_p.h" #include "centralwidget.h" #include "helpenginewrapper.h" @@ -242,7 +243,7 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, // -- HelpViewer HelpViewer::HelpViewer(qreal zoom, QWidget *parent) - : QWebView(parent) + : QWebView(parent), d(new HelpViewerPrivate) { TRACE_OBJ setAcceptDrops(false); @@ -275,11 +276,6 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent) setTextSizeMultiplier(zoom == 0.0 ? 1.0 : zoom); } -HelpViewer::~HelpViewer() -{ - TRACE_OBJ -} - QFont HelpViewer::viewerFont() const { TRACE_OBJ @@ -435,6 +431,11 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) return; #endif + if (openPagesListRequested(event)) { + showOpenPagesList(event->pos()); + return; + } + if (HelpPage *currentPage = static_cast (page())) { currentPage->m_pressedButtons = event->buttons(); currentPage->m_keyboardModifiers = event->modifiers(); @@ -479,7 +480,8 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event) void HelpViewer::contextMenuEvent(QContextMenuEvent *event) { TRACE_OBJ - QWebView::contextMenuEvent(event); + if (!openPagesListRequested(event)) + QWebView::contextMenuEvent(event); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp index 6db1879..b6005e8 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.cpp +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -280,7 +280,7 @@ void OpenPagesManager::closePagesExcept(const QModelIndex &index) } } -QWidget *OpenPagesManager::openPagesWidget() const +QAbstractItemView *OpenPagesManager::openPagesWidget() const { return m_openPagesWidget; } diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h index 407ee79..5e7a9af 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.h +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -46,9 +46,9 @@ QT_BEGIN_NAMESPACE +class QAbstractItemView; class QModelIndex; class QUrl; -class QWidget; class HelpViewer; class OpenPagesModel; @@ -66,10 +66,11 @@ class OpenPagesManager : public QObject void closePages(const QString &nameSpace); void reloadPages(const QString &nameSpace); - QWidget* openPagesWidget() const; + QAbstractItemView* openPagesWidget() const; int pageCount() const; - + void setCurrentPage(int index); + public slots: HelpViewer *createPage(const QUrl &url, bool fromSearch = false); HelpViewer *createNewPageFromSearch(const QUrl &url); @@ -88,7 +89,6 @@ private: const QUrl &cmdLineUrl); void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); void closeOrReloadPages(const QString &nameSpace, bool tryReload); - void setCurrentPage(int index); void selectCurrentPage(); void removePage(int index); void nextOrPreviousPage(int offset); -- 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 0b0733a867a818adfcaf0cf5a1da41cf42605124 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 17 May 2010 10:40:27 +0200 Subject: Assistant: Fix use of uninitialized address bar. Also bail out when we can't set up the help engine. --- tools/assistant/tools/assistant/mainwindow.cpp | 195 +++++++++++++------------ 1 file changed, 103 insertions(+), 92 deletions(-) diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 9578478..ca10d38 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -88,6 +88,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) @@ -152,6 +154,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) openPagesDock->setWidget(openPagesManager->openPagesWidget()); addDockWidget(Qt::LeftDockWidgetArea, openPagesDock); +#if 0 connect(bookMarkManager, SIGNAL(escapePressed()), this, SLOT(activateCurrentCentralWidgetTab())); connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget, @@ -164,6 +167,7 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine(); connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted())); connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished())); +#endif QString defWindowTitle = tr("Qt Assistant"); setWindowTitle(defWindowTitle); @@ -171,106 +175,113 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) setupActions(); statusBar()->show(); - if (initHelpDB()) { - setupFilterToolbar(); - setupAddressToolbar(); - - const QString windowTitle = helpEngineWrapper.windowTitle(); - setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); - QByteArray iconArray = helpEngineWrapper.applicationIcon(); - if (iconArray.size() > 0) { - QPixmap pix; - pix.loadFromData(iconArray); - QIcon appIcon(pix); - qApp->setWindowIcon(appIcon); - } else { - QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png")); - qApp->setWindowIcon(appIcon); - } + if (!initHelpDB()) { + qDebug("Fatal error: Help engine initialization failed. " + "Error message was: %s\nAssistant will now exit.", + qPrintable(HelpEngineWrapper::instance().error())); + std::exit(1); + } - // Show the widget here, otherwise the restore geometry and state won't work - // on x11. - show(); - QByteArray ba(helpEngineWrapper.mainWindow()); - if (!ba.isEmpty()) - restoreState(ba); - - ba = helpEngineWrapper.mainWindowGeometry(); - if (!ba.isEmpty()) { - restoreGeometry(ba); - } else { - tabifyDockWidget(contentDock, indexDock); - tabifyDockWidget(indexDock, bookmarkDock); - tabifyDockWidget(bookmarkDock, openPagesDock); - tabifyDockWidget(openPagesDock, searchDock); - contentDock->raise(); - const QRect screen = QApplication::desktop()->screenGeometry(); - resize(4*screen.width()/5, 4*screen.height()/5); - } + setupFilterToolbar(); + setupAddressToolbar(); - if (!helpEngineWrapper.hasFontSettings()) { - helpEngineWrapper.setUseAppFont(false); - helpEngineWrapper.setUseBrowserFont(false); - helpEngineWrapper.setAppFont(qApp->font()); - helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); - helpEngineWrapper.setBrowserFont(qApp->font()); - helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); - } else { - updateApplicationFont(); - } + const QString windowTitle = helpEngineWrapper.windowTitle(); + setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle); + QByteArray iconArray = helpEngineWrapper.applicationIcon(); + if (iconArray.size() > 0) { + QPixmap pix; + pix.loadFromData(iconArray); + QIcon appIcon(pix); + qApp->setWindowIcon(appIcon); + } else { + QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png")); + qApp->setWindowIcon(appIcon); + } - updateAboutMenuText(); - - QTimer::singleShot(0, this, SLOT(insertLastPages())); - if (m_cmdLine->enableRemoteControl()) - (void)new RemoteControl(this); - - if (m_cmdLine->contents() == CmdLineParser::Show) - showContents(); - else if (m_cmdLine->contents() == CmdLineParser::Hide) - hideContents(); - - if (m_cmdLine->index() == CmdLineParser::Show) - showIndex(); - else if (m_cmdLine->index() == CmdLineParser::Hide) - hideIndex(); - - if (m_cmdLine->bookmarks() == CmdLineParser::Show) - showBookmarksDockWidget(); - else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) - hideBookmarksDockWidget(); - - if (m_cmdLine->search() == CmdLineParser::Show) - showSearch(); - else if (m_cmdLine->search() == CmdLineParser::Hide) - hideSearch(); - - if (m_cmdLine->contents() == CmdLineParser::Activate) - showContents(); - else if (m_cmdLine->index() == CmdLineParser::Activate) - showIndex(); - else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) - showBookmarksDockWidget(); - - if (!m_cmdLine->currentFilter().isEmpty()) { - const QString &curFilter = m_cmdLine->currentFilter(); - if (helpEngineWrapper.customFilters().contains(curFilter)) - helpEngineWrapper.setCurrentFilter(curFilter); - } + // Show the widget here, otherwise the restore geometry and state won't work + // on x11. + show(); + QByteArray ba(helpEngineWrapper.mainWindow()); + if (!ba.isEmpty()) + restoreState(ba); - if (usesDefaultCollection()) - QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); - else - checkInitState(); + ba = helpEngineWrapper.mainWindowGeometry(); + if (!ba.isEmpty()) { + restoreGeometry(ba); + } else { + tabifyDockWidget(contentDock, indexDock); + tabifyDockWidget(indexDock, bookmarkDock); + tabifyDockWidget(bookmarkDock, openPagesDock); + tabifyDockWidget(openPagesDock, searchDock); + contentDock->raise(); + const QRect screen = QApplication::desktop()->screenGeometry(); + resize(4*screen.width()/5, 4*screen.height()/5); + } + + if (!helpEngineWrapper.hasFontSettings()) { + helpEngineWrapper.setUseAppFont(false); + helpEngineWrapper.setUseBrowserFont(false); + helpEngineWrapper.setAppFont(qApp->font()); + helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin); + helpEngineWrapper.setBrowserFont(qApp->font()); + helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin); + } else { + updateApplicationFont(); + } + + updateAboutMenuText(); + + QTimer::singleShot(0, this, SLOT(insertLastPages())); + if (m_cmdLine->enableRemoteControl()) + (void)new RemoteControl(this); - connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), - this, SLOT(documentationRemoved(QString))); - connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), - this, SLOT(documentationUpdated(QString))); + if (m_cmdLine->contents() == CmdLineParser::Show) + showContents(); + else if (m_cmdLine->contents() == CmdLineParser::Hide) + hideContents(); + + if (m_cmdLine->index() == CmdLineParser::Show) + showIndex(); + else if (m_cmdLine->index() == CmdLineParser::Hide) + hideIndex(); + + if (m_cmdLine->bookmarks() == CmdLineParser::Show) + showBookmarksDockWidget(); + else if (m_cmdLine->bookmarks() == CmdLineParser::Hide) + hideBookmarksDockWidget(); + + if (m_cmdLine->search() == CmdLineParser::Show) + showSearch(); + else if (m_cmdLine->search() == CmdLineParser::Hide) + hideSearch(); + + if (m_cmdLine->contents() == CmdLineParser::Activate) + showContents(); + else if (m_cmdLine->index() == CmdLineParser::Activate) + showIndex(); + else if (m_cmdLine->bookmarks() == CmdLineParser::Activate) + showBookmarksDockWidget(); + + if (!m_cmdLine->currentFilter().isEmpty()) { + const QString &curFilter = m_cmdLine->currentFilter(); + if (helpEngineWrapper.customFilters().contains(curFilter)) + helpEngineWrapper.setCurrentFilter(curFilter); } + + if (usesDefaultCollection()) + QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation())); + else + checkInitState(); + + connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)), + this, SLOT(documentationRemoved(QString))); + connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)), + this, SLOT(documentationUpdated(QString))); + setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North); GlobalActions::instance()->updateActions(); - showNewAddress(); + if (helpEngineWrapper.addressBarEnabled()) + showNewAddress(); } MainWindow::~MainWindow() -- cgit v0.12 From 2134980e4c480c04852ebeda138bdc656233a8f6 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 18 May 2010 10:43:35 +0200 Subject: Remove QT_NO_THREAD support for QHostInfo Reviewed-by: Thiago --- dist/changes-4.8.0 | 1 + src/network/kernel/qhostinfo.cpp | 26 ++------------------------ src/network/kernel/qhostinfo_p.h | 7 +------ src/network/kernel/qhostinfo_unix.cpp | 2 -- src/network/kernel/qhostinfo_win.cpp | 2 -- 5 files changed, 4 insertions(+), 34 deletions(-) diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 27bb885..9d16f11 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -36,6 +36,7 @@ Third party components QtCore ------ + - Removed support for QT_NO_THREAD define for QHostInfo. QtGui ----- diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index f287630..a2c2c63 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -60,9 +60,7 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_THREAD Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) -#endif //#define QHOSTINFO_DEBUG @@ -91,10 +89,8 @@ Q_GLOBAL_STATIC(QHostInfoLookupManager, theHostInfoLookupManager) \snippet doc/src/snippets/code/src_network_kernel_qhostinfo.cpp 0 - The slot is invoked when the results are ready. (If you use - Qt for Embedded Linux and disabled multithreading support by defining - \c QT_NO_THREAD, lookupHost() will block until the lookup has - finished.) The results are stored in a QHostInfo object. Call + The slot is invoked when the results are ready. The results are + stored in a QHostInfo object. Call addresses() to get the list of IP addresses for the host, and hostName() to get the host name that was looked up. @@ -180,14 +176,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, return id; } -#ifdef QT_NO_THREAD - QHostInfo hostInfo = QHostInfoAgent::fromName(name); - hostInfo.setLookupId(id); - QScopedPointer result(new QHostInfoResult); - QObject::connect(result.data(), SIGNAL(resultsReady(QHostInfo)), - receiver, member, Qt::QueuedConnection); - result.data()->emitResultsReady(hostInfo); -#else QHostInfoLookupManager *manager = theHostInfoLookupManager(); if (manager) { // the application is still alive @@ -208,8 +196,6 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, QObject::connect(&runnable->resultEmitter, SIGNAL(resultsReady(QHostInfo)), receiver, member, Qt::QueuedConnection); manager->scheduleLookup(runnable); } -#endif - return id; } @@ -220,12 +206,7 @@ int QHostInfo::lookupHost(const QString &name, QObject *receiver, */ void QHostInfo::abortHostLookup(int id) { -#ifndef QT_NO_THREAD theHostInfoLookupManager()->abortLookup(id); -#else - // we cannot abort if it was non threaded.. the result signal has already been posted - Q_UNUSED(id); -#endif } /*! @@ -426,7 +407,6 @@ void QHostInfo::setErrorString(const QString &str) \sa hostName() */ -#ifndef QT_NO_THREAD QHostInfoRunnable::QHostInfoRunnable(QString hn, int i) : toBeLookedUp(hn), id(i) { setAutoDelete(true); @@ -722,6 +702,4 @@ void QHostInfoCache::clear() cache.clear(); } -#endif // QT_NO_THREAD - QT_END_NAMESPACE diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index e11766b..acd2bf0 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -60,8 +60,6 @@ #include "QtCore/qwaitcondition.h" #include "QtCore/qobject.h" #include "QtCore/qpointer.h" - -#ifndef QT_NO_THREAD #include "QtCore/qthread.h" #include "QtCore/qthreadpool.h" #include "QtCore/qmutex.h" @@ -70,7 +68,7 @@ #include "QtCore/qqueue.h" #include #include -#endif + QT_BEGIN_NAMESPACE @@ -112,7 +110,6 @@ public: int lookupId; }; -#ifndef QT_NO_THREAD // These functions are outside of the QHostInfo class and strictly internal. // Do NOT use them outside of QAbstractSocket. QHostInfo Q_NETWORK_EXPORT qt_qhostinfo_lookup(const QString &name, QObject *receiver, const char *member, bool *valid, int *id); @@ -190,8 +187,6 @@ private slots: void waitForThreadPoolDone() { threadPool.waitForDone(); } }; -#endif - QT_END_NAMESPACE #endif // QHOSTINFO_P_H diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index a186e78..0887f89 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -131,9 +131,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) // Load res_init on demand. static volatile bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(&local_res_init)); -#endif if (!triedResolve) { resolveLibrary(); triedResolve = true; diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 4264f60..89aaa34 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -116,9 +116,7 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) // Load res_init on demand. static volatile bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD QMutexLocker locker(QMutexPool::globalInstanceGet(&local_getaddrinfo)); -#endif if (!triedResolve) { resolveLibrary(); triedResolve = true; -- cgit v0.12 From aef03d80f7d9b71dfe777cd7927808d69dac0c27 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 23 Apr 2010 14:14:43 +0200 Subject: Optimize ~QList There is no need to check for d as it must never be 0 And the refcount ins QList::free() is nessecerly 0 since it is checked before the function is called Reviewed-by: ossi --- src/corelib/tools/qlist.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index 722744c..99c9795 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -712,7 +712,7 @@ Q_OUTOFLINE_TEMPLATE void QList::detach_helper() template Q_OUTOFLINE_TEMPLATE QList::~QList() { - if (d && !d->ref.deref()) + if (!d->ref.deref()) free(d); } @@ -740,8 +740,7 @@ Q_OUTOFLINE_TEMPLATE void QList::free(QListData::Data *data) { node_destruct(reinterpret_cast(data->array + data->begin), reinterpret_cast(data->array + data->end)); - if (data->ref == 0) - qFree(data); + qFree(data); } -- cgit v0.12 From c25a6e090c8074e68d7eb40f2533da8bab5e7dd8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 21 Apr 2010 20:17:08 +0200 Subject: Inline the common case when there is no contention. QMutex locking could be used in performence critical code (such as QObject and co.) where the cost of a function call is not neglectible. This would slow down the common case where there is only one thread and no contention. Since we need to keep the old symbol for binary compatibilty, introduce new *Inline function. Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 8 +- src/corelib/thread/qmutex.cpp | 133 ++++++++++++++++++++--------- src/corelib/thread/qmutex.h | 71 ++++++++++++--- src/corelib/thread/qmutex_p.h | 11 ++- src/corelib/thread/qmutex_unix.cpp | 2 +- src/corelib/thread/qmutex_win.cpp | 2 +- src/corelib/thread/qorderedmutexlocker_p.h | 14 +-- 7 files changed, 174 insertions(+), 67 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8a4304e..f1262d6 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -893,7 +893,7 @@ QObject::~QObject() if (c->next) c->next->prev = c->prev; } if (needToUnlock) - m->unlock(); + m->unlockInline(); connectionList.first = c->nextConnectionList; delete c; @@ -917,7 +917,7 @@ QObject::~QObject() bool needToUnlock = QOrderedMutexLocker::relock(signalSlotMutex, m); //the node has maybe been removed while the mutex was unlocked in relock? if (!node || node->sender != sender) { - m->unlock(); + m->unlockInline(); continue; } node->receiver = 0; @@ -927,7 +927,7 @@ QObject::~QObject() node = node->next; if (needToUnlock) - m->unlock(); + m->unlockInline(); } } @@ -2983,7 +2983,7 @@ bool QMetaObjectPrivate::disconnectHelper(QObjectPrivate::Connection *c, } if (needToUnlock) - receiverMutex->unlock(); + receiverMutex->unlockInline(); c->receiver = 0; diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 43df13a..eb6f729 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -130,7 +130,7 @@ QMutex::QMutex(RecursionMode mode) \warning Destroying a locked mutex may result in undefined behavior. */ QMutex::~QMutex() -{ delete d; } +{ delete static_cast(d); } /*! Locks the mutex. If another thread has locked the mutex then this @@ -146,6 +146,7 @@ QMutex::~QMutex() */ void QMutex::lock() { + QMutexPrivate *d = static_cast(this->d); Qt::HANDLE self; if (d->recursive) { @@ -184,43 +185,7 @@ void QMutex::lock() bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1); if (!isLocked) { - int spinCount = 0; - int lastSpinCount = d->lastSpinCount; - - enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 }; - const int maximumSpinCount = lastSpinCount + AdditionalSpins; - - do { - if (spinCount++ > maximumSpinCount) { - // puts("spinning useless, sleeping"); - isLocked = d->contenders.fetchAndAddAcquire(1) == 0; - if (!isLocked) { -#ifndef QT_NO_DEBUG - if (d->owner == self) - qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner; -#endif - - // didn't get the lock, wait for it - isLocked = d->wait(); - Q_ASSERT_X(isLocked, "QMutex::lock", - "Internal error, infinite wait has timed out."); - - // don't need to wait for the lock anymore - d->contenders.deref(); - } - // decrease the lastSpinCount since we didn't actually get the lock by spinning - spinCount = -d->lastSpinCount / SpinCountPenalizationDivisor; - break; - } - - isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1); - } while (!isLocked); - - // adjust the last spin lock count - lastSpinCount = d->lastSpinCount; - d->lastSpinCount = spinCount >= 0 - ? qMax(lastSpinCount, spinCount) - : lastSpinCount + spinCount; + lockInternal(); } #ifndef QT_NO_DEBUG @@ -247,6 +212,7 @@ void QMutex::lock() */ bool QMutex::tryLock() { + QMutexPrivate *d = static_cast(this->d); Qt::HANDLE self; if (d->recursive) { @@ -310,6 +276,7 @@ bool QMutex::tryLock() */ bool QMutex::tryLock(int timeout) { + QMutexPrivate *d = static_cast(this->d); Qt::HANDLE self; if (d->recursive) { @@ -366,8 +333,13 @@ bool QMutex::tryLock(int timeout) */ void QMutex::unlock() { - Q_ASSERT_X(d->owner == QThread::currentThreadId(), "QMutex::unlock()", - "A mutex must be unlocked in the same thread that locked it."); + QMutexPrivate *d = static_cast(this->d); +#ifndef QT_NO_DEBUG + //note: if the mutex has been locked with (try)lockInline, d->owner could have not been set, and this would be a false warning + if ((d->owner || d->recursive) && d->owner != QThread::currentThreadId()) + qWarning("QMutex::unlock(): A mutex must be unlocked in the same thread that locked it."); +#endif + if (d->recursive) { if (!--d->count) { @@ -506,6 +478,87 @@ void QMutex::unlock() Use the constructor that takes a RecursionMode parameter instead. */ +/*! + \internal helper for lockInline() + */ +void QMutex::lockInternal() +{ + QMutexPrivate *d = static_cast(this->d); + int spinCount = 0; + int lastSpinCount = d->lastSpinCount; + + enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 }; + const int maximumSpinCount = lastSpinCount + AdditionalSpins; + +#ifndef QT_NO_DEBUG + Qt::HANDLE self = QThread::currentThreadId(); +#endif + + do { + if (spinCount++ > maximumSpinCount) { + // puts("spinning useless, sleeping"); + bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0; + if (!isLocked) { +#ifndef QT_NO_DEBUG + if (d->owner == self) + qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner; +#endif + + // didn't get the lock, wait for it + isLocked = d->wait(); + Q_ASSERT_X(isLocked, "QMutex::lock", + "Internal error, infinite wait has timed out."); + + // don't need to wait for the lock anymore + d->contenders.deref(); + } + // decrease the lastSpinCount since we didn't actually get the lock by spinning + spinCount = -d->lastSpinCount / SpinCountPenalizationDivisor; + break; + } + } while (d->contenders != 0 || !d->contenders.testAndSetAcquire(0, 1)); + + // adjust the last spin lock count + lastSpinCount = d->lastSpinCount; + d->lastSpinCount = spinCount >= 0 + ? qMax(lastSpinCount, spinCount) + : lastSpinCount + spinCount; + +#ifndef QT_NO_DEBUG + d->owner = self; +#endif +} + +/*! + \internal +*/ +void QMutex::unlockInternal() +{ +#ifndef QT_NO_DEBUG + static_cast(d)->owner = 0; +#endif + static_cast(d)->wakeUp(); +} + +/*! + \fn QMutex::lockInline() + \internal + inline version of QMutex::lock() +*/ + +/*! + \fn QMutex::unlockInline() + \internal + inline version of QMutex::unlock() +*/ + +/*! + \fn QMutex::tryLockInline() + \internal + inline version of QMutex::tryLock() +*/ + + QT_END_NAMESPACE #endif // QT_NO_THREAD diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h index 509f300..710b794 100644 --- a/src/corelib/thread/qmutex.h +++ b/src/corelib/thread/qmutex.h @@ -43,6 +43,7 @@ #define QMUTEX_H #include +#include #include QT_BEGIN_HEADER @@ -53,7 +54,8 @@ QT_MODULE(Core) #ifndef QT_NO_THREAD -class QMutexPrivate; +class QAtomicInt; +class QMutexData; class Q_CORE_EXPORT QMutex { @@ -66,10 +68,13 @@ public: explicit QMutex(RecursionMode mode = NonRecursive); ~QMutex(); - void lock(); - bool tryLock(); + void lock(); //### Qt5: make inline; + inline void lockInline(); + bool tryLock(); //### Qt5: make inline; bool tryLock(int timeout); - void unlock(); + inline bool tryLockInline(); + void unlock(); //### Qt5: make inline; + inline void unlockInline(); #if defined(QT3_SUPPORT) inline QT3_SUPPORT bool locked() @@ -86,9 +91,11 @@ public: #endif private: + void lockInternal(); + void unlockInternal(); Q_DISABLE_COPY(QMutex) - QMutexPrivate *d; + QMutexData *d; }; class Q_CORE_EXPORT QMutexLocker @@ -99,7 +106,7 @@ public: Q_ASSERT_X((reinterpret_cast(m) & quintptr(1u)) == quintptr(0), "QMutexLocker", "QMutex pointer is misaligned"); if (m) { - m->lock(); + m->lockInline(); val = reinterpret_cast(m) | quintptr(1u); } else { val = 0; @@ -111,7 +118,7 @@ public: { if ((val & quintptr(1u)) == quintptr(1u)) { val &= ~quintptr(1u); - mutex()->unlock(); + mutex()->unlockInline(); } } @@ -119,7 +126,7 @@ public: { if (val) { if ((val & quintptr(1u)) == quintptr(0u)) { - mutex()->lock(); + mutex()->lockInline(); val |= quintptr(1u); } } @@ -145,6 +152,46 @@ private: quintptr val; }; +class QMutexData +{ + public: + QAtomicInt contenders; + const uint recursive : 1; + uint reserved : 31; + protected: + QMutexData(QMutex::RecursionMode mode); + ~QMutexData(); +}; + +inline void QMutex::unlockInline() +{ + if (d->recursive) { + unlock(); + } else if (!d->contenders.testAndSetRelease(1, 0)) { + unlockInternal(); + } +} + +inline bool QMutex::tryLockInline() +{ + if (d->recursive) { + return tryLock(); + } else { + return d->contenders.testAndSetAcquire(0, 1); + } +} + +inline void QMutex::lockInline() +{ + if (d->recursive) { + lock(); + } else if(!tryLockInline()) { + lockInternal(); + } +} + + + #else // QT_NO_THREAD @@ -157,9 +204,11 @@ public: inline ~QMutex() {} static inline void lock() {} - static inline bool tryLock() { return true; } - static inline bool tryLock(int timeout) { Q_UNUSED(timeout); return true; } - static void unlock() {} + static inline void lockInline() {} + static inline bool tryLock(int timeout = 0) { Q_UNUSED(timeout); return true; } + static inline bool tryLockInline() { return true; } + static inline void unlock() {} + static inline void unlockInline() {} #if defined(QT3_SUPPORT) static inline QT3_SUPPORT bool locked() { return false; } diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h index dce162a..6126423 100644 --- a/src/corelib/thread/qmutex_p.h +++ b/src/corelib/thread/qmutex_p.h @@ -56,10 +56,11 @@ #include #include +#include QT_BEGIN_NAMESPACE -class QMutexPrivate { +class QMutexPrivate : public QMutexData { public: QMutexPrivate(QMutex::RecursionMode mode); ~QMutexPrivate(); @@ -68,8 +69,6 @@ public: bool wait(int timeout = -1); void wakeUp(); - const bool recursive; - QAtomicInt contenders; volatile int lastSpinCount; Qt::HANDLE owner; uint count; @@ -83,6 +82,12 @@ public: #endif }; +inline QMutexData::QMutexData(QMutex::RecursionMode mode) + : recursive(mode == QMutex::Recursive) +{} + +inline QMutexData::~QMutexData() {} + QT_END_NAMESPACE #endif // QMUTEX_P_H diff --git a/src/corelib/thread/qmutex_unix.cpp b/src/corelib/thread/qmutex_unix.cpp index a58368c..7e7ef22 100644 --- a/src/corelib/thread/qmutex_unix.cpp +++ b/src/corelib/thread/qmutex_unix.cpp @@ -63,7 +63,7 @@ static void report_error(int code, const char *where, const char *what) QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode) - : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0), wakeup(false) + : QMutexData(mode), lastSpinCount(0), owner(0), count(0), wakeup(false) { report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init"); report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init"); diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp index 9d58953..a810000 100644 --- a/src/corelib/thread/qmutex_win.cpp +++ b/src/corelib/thread/qmutex_win.cpp @@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE QMutexPrivate::QMutexPrivate(QMutex::RecursionMode mode) - : recursive(mode == QMutex::Recursive), contenders(0), lastSpinCount(0), owner(0), count(0) + : QMutexData(mode), lastSpinCount(0), owner(0), count(0) { event = CreateEvent(0, FALSE, FALSE, 0); if (!event) diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h index 702125c..375ded1 100644 --- a/src/corelib/thread/qorderedmutexlocker_p.h +++ b/src/corelib/thread/qorderedmutexlocker_p.h @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE -class QMutex; +#include /* Locks 2 mutexes in a defined order, avoiding a recursive lock if @@ -79,8 +79,8 @@ public: void relock() { if (!locked) { - if (mtx1) mtx1->lock(); - if (mtx2) mtx2->lock(); + if (mtx1) mtx1->lockInline(); + if (mtx2) mtx2->lockInline(); locked = true; } } @@ -88,8 +88,8 @@ public: void unlock() { if (locked) { - if (mtx1) mtx1->unlock(); - if (mtx2) mtx2->unlock(); + if (mtx1) mtx1->unlockInline(); + if (mtx2) mtx2->unlockInline(); locked = false; } } @@ -100,10 +100,10 @@ public: if (mtx1 == mtx2) return false; if (mtx1 < mtx2) { - mtx2->lock(); + mtx2->lockInline(); return true; } - if (!mtx2->tryLock()) { + if (!mtx2->tryLockInline()) { mtx1->unlock(); mtx2->lock(); mtx1->lock(); -- cgit v0.12 From 34a37c95a5130af262854eb7a7ef041908cc7aa8 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 22 Apr 2010 14:18:45 +0200 Subject: Benchmark for QMutex. This currently only cover the case when there is no contention $ ./tst_bench_qmutex noThread -callgrind ********* Start testing of tst_QMutex ********* Config: Using QTest library 4.7.0, Qt 4.7.0 PASS : tst_QMutex::initTestCase() RESULT : tst_QMutex::noThread():"noLock": 60,000,054 instruction reads per iteration (total: 60,000,054, iterations: 1) RESULT : tst_QMutex::noThread():"QMutexInline": 240,000,057 instruction reads per iteration (total: 240,000,057, iterations: 1) RESULT : tst_QMutex::noThread():"QMutex": 380,000,056 instruction reads per iteration (total: 380,000,056, iterations: 1) RESULT : tst_QMutex::noThread():"QMutexLocker": 240,000,058 instruction reads per iteration (total: 240,000,058, iterations: 1) PASS : tst_QMutex::noThread() PASS : tst_QMutex::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped ********* Finished testing of tst_QMutex ********* $ make && ./tst_bench_qmutex noThread ********* Start testing of tst_QMutex ********* Config: Using QTest library 4.7.0, Qt 4.7.0 PASS : tst_QMutex::initTestCase() RESULT : tst_QMutex::noThread():"noLock": 27 msecs per iteration (total: 27, iterations: 1) RESULT : tst_QMutex::noThread():"QMutexInline": 212 msecs per iteration (total: 212, iterations: 1) RESULT : tst_QMutex::noThread():"QMutex": 257 msecs per iteration (total: 257, iterations: 1) RESULT : tst_QMutex::noThread():"QMutexLocker": 212 msecs per iteration (total: 212, iterations: 1) PASS : tst_QMutex::noThread() PASS : tst_QMutex::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped ********* Finished testing of tst_QMutex ********* --- tests/benchmarks/corelib/thread/qmutex/qmutex.pro | 6 + .../corelib/thread/qmutex/tst_qmutex.cpp | 131 +++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 tests/benchmarks/corelib/thread/qmutex/qmutex.pro create mode 100644 tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp diff --git a/tests/benchmarks/corelib/thread/qmutex/qmutex.pro b/tests/benchmarks/corelib/thread/qmutex/qmutex.pro new file mode 100644 index 0000000..eda2f11 --- /dev/null +++ b/tests/benchmarks/corelib/thread/qmutex/qmutex.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qmutex + +SOURCES += tst_qmutex.cpp + diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp new file mode 100644 index 0000000..fded508 --- /dev/null +++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp @@ -0,0 +1,131 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 + +//TESTED_FILES= + + +class tst_QMutex : public QObject +{ + Q_OBJECT + +public: + tst_QMutex(); + virtual ~tst_QMutex(); + +private slots: + void noThread_data(); + void noThread(); +}; + +tst_QMutex::tst_QMutex() +{ +} + +tst_QMutex::~tst_QMutex() +{ +} + +void tst_QMutex::noThread_data() +{ + QTest::addColumn("t"); + + QTest::newRow("noLock") << 1; + QTest::newRow("QMutexInline") << 2; + QTest::newRow("QMutex") << 3; + QTest::newRow("QMutexLocker") << 4; +} + +void tst_QMutex::noThread() +{ + volatile int count = 0; + const int N = 5000000; + QMutex mtx; + + QFETCH(int, t); + switch(t) { + case 1: + QBENCHMARK { + count = 0; + for (int i = 0; i < N; i++) { + count++; + } + } + break; + case 2: + QBENCHMARK { + count = 0; + for (int i = 0; i < N; i++) { + mtx.lockInline(); + count++; + mtx.unlockInline(); + } + } + break; + case 3: + QBENCHMARK { + count = 0; + for (int i = 0; i < N; i++) { + mtx.lock(); + count++; + mtx.unlock(); + } + } + break; + case 4: + QBENCHMARK { + count = 0; + for (int i = 0; i < N; i++) { + QMutexLocker locker(&mtx); + count++; + } + } + break; + } + QCOMPARE(int(count), N); +} + +QTEST_MAIN(tst_QMutex) +#include "tst_qmutex.moc" -- cgit v0.12 From e25b5101981dfedd7ceab309b434d0cc15724a27 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 23 Apr 2010 11:43:30 +0200 Subject: Only emit the destroyed() signal if connected Also remove dead code in the exception code Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f1262d6..0544a5a 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -840,22 +840,16 @@ QObject::~QObject() delete d->sharedRefcount; } - QT_TRY { - emit destroyed(this); - } QT_CATCH(...) { - // all the signal/slots connections are still in place - if we don't - // quit now, we will crash pretty soon. - qWarning("Detected an unexpected exception in ~QObject while emitting destroyed()."); -#if defined(Q_BUILD_INTERNAL) && !defined(QT_NO_EXCEPTIONS) - struct AutotestException : public std::exception - { - const char *what() const throw() { return "autotest swallow"; } - } autotestException; - // throw autotestException; -#else - QT_RETHROW; -#endif + if (d->isSignalConnected(0)) { + QT_TRY { + emit destroyed(this); + } QT_CATCH(...) { + // all the signal/slots connections are still in place - if we don't + // quit now, we will crash pretty soon. + qWarning("Detected an unexpected exception in ~QObject while emitting destroyed()."); + QT_RETHROW; + } } if (d->declarativeData) -- cgit v0.12 From 580d7f28ca93b053daa23250bdd404f0ddd7171e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 23 Apr 2010 13:44:00 +0200 Subject: QObjectPrivate::deleteWatch, and inEventHandler are only used by jambi so #ifdef them out. Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 17 ++++++++++++----- src/corelib/kernel/qobject.h | 2 +- src/corelib/kernel/qobject_p.h | 4 ++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0544a5a..ef1caef 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -149,9 +149,11 @@ QObjectPrivate::QObjectPrivate(int version) postedEvents = 0; extraData = 0; connectedSignals[0] = connectedSignals[1] = 0; - inEventHandler = false; inThreadChangeEvent = false; +#ifdef QT_JAMBI_BUILD + inEventHandler = false; deleteWatch = 0; +#endif metaObject = 0; hasGuards = false; } @@ -159,8 +161,10 @@ QObjectPrivate::QObjectPrivate(int version) QObjectPrivate::~QObjectPrivate() { delete static_cast(metaObject); +#ifdef QT_JAMBI_BUILD if (deleteWatch) *deleteWatch = 1; +#endif #ifndef QT_NO_USERDATA if (extraData) qDeleteAll(extraData->userData); @@ -169,6 +173,7 @@ QObjectPrivate::~QObjectPrivate() } +#ifdef QT_JAMBI_BUILD int *QObjectPrivate::setDeleteWatch(QObjectPrivate *d, int *w) { int *old = d->deleteWatch; d->deleteWatch = w; @@ -183,10 +188,7 @@ void QObjectPrivate::resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int dele if (oldWatch) *oldWatch = deleteWatch; } - - - - +#endif #ifdef QT3_SUPPORT void QObjectPrivate::sendPendingChildInsertedEvents() @@ -1192,7 +1194,9 @@ bool QObject::event(QEvent *e) case QEvent::MetaCall: { +#ifdef QT_JAMBI_BUILD d_func()->inEventHandler = false; +#endif QMetaCallEvent *mce = static_cast(e); QObjectPrivate::Sender currentSender; currentSender.sender = const_cast(mce->sender()); @@ -1510,11 +1514,14 @@ void QObjectPrivate::setThreadData_helper(QThreadData *currentData, QThreadData currentSender->ref = 0; currentSender = 0; +#ifdef QT_JAMBI_BUILD // the current event thread also shouldn't restore the delete watch inEventHandler = false; + if (deleteWatch) *deleteWatch = 1; deleteWatch = 0; +#endif // set new thread data targetData->ref(); diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 1b613a6..44e7ce5 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -109,7 +109,7 @@ public: uint ownObjectName : 1; uint sendChildEvents : 1; uint receiveChildEvents : 1; - uint inEventHandler : 1; + uint inEventHandler : 1; //only used if QT_JAMBI_BUILD uint inThreadChangeEvent : 1; uint hasGuards : 1; //true iff there is one or more QPointer attached to this object uint unused : 22; diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 4800e6a..35b4540 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -161,8 +161,10 @@ public: static inline void resetCurrentSender(QObject *receiver, Sender *currentSender, Sender *previousSender); +#ifdef QT_JAMBI_BUILD static int *setDeleteWatch(QObjectPrivate *d, int *newWatch); static void resetDeleteWatch(QObjectPrivate *d, int *oldWatch, int deleteWatch); +#endif static void clearGuards(QObject *); static QObjectPrivate *get(QObject *o) { @@ -200,7 +202,9 @@ public: // these objects are all used to indicate that a QObject was deleted // plus QPointer, which keeps a separate list QAtomicPointer sharedRefcount; +#ifdef QT_JAMBI_BUILD int *deleteWatch; +#endif }; -- cgit v0.12 From cc10df56ba56899e993cb6e83a1fdfee79f60734 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 23 Apr 2010 14:00:49 +0200 Subject: Do not clear lists in ~QObject The list are going to be destroyed anyway Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ef1caef..40add3f 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -933,12 +933,6 @@ QObject::~QObject() d->threadData->eventDispatcher->unregisterTimers(this); } -#ifdef QT3_SUPPORT - d->pendingChildInsertedEvents.clear(); -#endif - - d->eventFilters.clear(); - if (!d->children.isEmpty()) d->deleteChildren(); -- cgit v0.12 From 3f5aea3fa74f809a8ef2eb00c5c34233b7c5823b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 23 Apr 2010 11:10:43 +0200 Subject: Test hasGuard before calling clearGuards. So no need to test it inside clearGuards. Reviewed-by: Brad --- src/corelib/kernel/qobject.cpp | 7 +------ src/gui/kernel/qwidget.cpp | 3 ++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 40add3f..5dba965 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -478,11 +478,6 @@ void QMetaObject::changeGuard(QObject **ptr, QObject *o) */ void QObjectPrivate::clearGuards(QObject *object) { - QObjectPrivate *priv = QObjectPrivate::get(object); - - if (!priv->hasGuards) - return; - GuardHash *hash = 0; QMutex *mutex = 0; QT_TRY { @@ -824,7 +819,7 @@ QObject::~QObject() d->wasDeleted = true; d->blockSig = 0; // unblock signals so we always emit destroyed() - if (!d->isWidget) { + if (d->hasGuards && !d->isWidget) { // set all QPointers for this object to zero - note that // ~QWidget() does this for us, so we don't have to do it twice QObjectPrivate::clearGuards(this); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 6f4a20f..0b67a9c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1480,7 +1480,8 @@ QWidget::~QWidget() d->needsFlush = 0; // set all QPointers for this object to zero - QObjectPrivate::clearGuards(this); + if (d->hasGuards) + QObjectPrivate::clearGuards(this); if (d->declarativeData) { QAbstractDeclarativeData::destroyed(d->declarativeData, this); -- cgit v0.12 From 00ada3501d3b9fb9e40e217fef3ca0e9fb262e43 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 22 Apr 2010 17:20:54 +1000 Subject: Minor improvement to QObject constructor performance Reviewed-by: Olivier Goffart --- src/corelib/kernel/qobject.cpp | 52 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 5dba965..c01df66 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -729,13 +729,15 @@ QObject::QObject(QObject *parent) d_ptr->q_ptr = this; d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); d->threadData->ref(); - QT_TRY { - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) - parent = 0; - setParent(parent); - } QT_CATCH(...) { - d->threadData->deref(); - QT_RETHROW; + if (parent) { + QT_TRY { + if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) + parent = 0; + setParent(parent); + } QT_CATCH(...) { + d->threadData->deref(); + QT_RETHROW; + } } qt_addObject(this); } @@ -754,9 +756,11 @@ QObject::QObject(QObject *parent, const char *name) qt_addObject(d_ptr->q_ptr = this); d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); d->threadData->ref(); - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) - parent = 0; - setParent(parent); + if (parent) { + if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) + parent = 0; + setParent(parent); + } setObjectName(QString::fromAscii(name)); } #endif @@ -770,21 +774,23 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) d_ptr->q_ptr = this; d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); d->threadData->ref(); - QT_TRY { - if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) - parent = 0; - if (d->isWidget) { - if (parent) { - d->parent = parent; - d->parent->d_func()->children.append(this); + if (parent) { + QT_TRY { + if (!check_parent_thread(parent, parent ? parent->d_func()->threadData : 0, d->threadData)) + parent = 0; + if (d->isWidget) { + if (parent) { + d->parent = parent; + d->parent->d_func()->children.append(this); + } + // no events sent here, this is done at the end of the QWidget constructor + } else { + setParent(parent); } - // no events sent here, this is done at the end of the QWidget constructor - } else { - setParent(parent); + } QT_CATCH(...) { + d->threadData->deref(); + QT_RETHROW; } - } QT_CATCH(...) { - d->threadData->deref(); - QT_RETHROW; } qt_addObject(this); } -- 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 f274db8040546e54b1ef0e674d9733714c68d4d5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 19 May 2010 14:13:41 +0200 Subject: Add Qt5 comment Task-number: QTBUG-10807 --- src/corelib/tools/qcache.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h index 44477d7..debab7d 100644 --- a/src/corelib/tools/qcache.h +++ b/src/corelib/tools/qcache.h @@ -61,7 +61,7 @@ class QCache }; Node *f, *l; QHash hash; - void *unused; + void *unused; // ### Qt5: remove int mx, total; inline void unlink(Node &n) { -- cgit v0.12 From 59b0bce57a9f8e16c735a99463c208a6c11bb1ba Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 7 May 2010 13:46:23 +0200 Subject: Cocoa: Add support for native application event filter Support for adding application wide filters were never implemented for the cocoa port because of NSApplication singleton issues. This patch removes that problem by using introspection if needed. And the patch also makes qt_cocoaPostMessage more reliable. --- src/gui/dialogs/qnspanelproxy_mac.mm | 87 +++++++++--------------- src/gui/kernel/kernel.pri | 6 +- src/gui/kernel/qapplication.h | 1 + src/gui/kernel/qapplication_mac.mm | 42 ++++++++---- src/gui/kernel/qcocoaapplication_mac.mm | 72 +++++++++++++++++--- src/gui/kernel/qcocoaapplication_mac_p.h | 8 ++- src/gui/kernel/qcocoasharedwindowmethods_mac_p.h | 11 --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 30 ++------ src/gui/kernel/qt_cocoa_helpers_mac_p.h | 12 +++- src/gui/widgets/qmenu_mac.mm | 3 +- 10 files changed, 147 insertions(+), 125 deletions(-) diff --git a/src/gui/dialogs/qnspanelproxy_mac.mm b/src/gui/dialogs/qnspanelproxy_mac.mm index 3229a4d..f01c035 100644 --- a/src/gui/dialogs/qnspanelproxy_mac.mm +++ b/src/gui/dialogs/qnspanelproxy_mac.mm @@ -42,6 +42,7 @@ #include #if defined(Q_WS_MAC) #include +#include #import #import #import @@ -137,46 +138,6 @@ QT_USE_NAMESPACE QT_BEGIN_NAMESPACE -void macStartIntercept(SEL originalSel, SEL fakeSel, Class baseClass, Class proxyClass) -{ -#ifndef QT_MAC_USE_COCOA - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) -#endif - { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - // The following code replaces the _implementation_ for the selector we want to hack - // (originalSel) with the implementation found in proxyClass. Then it creates - // a new 'backup' method inside baseClass containing the old, original, - // implementation (fakeSel). You can let the proxy implementation of originalSel - // call fakeSel if needed (similar approach to calling a super class implementation). - // fakeSel must also be implemented in proxyClass, as the signature is used - // as template for the method one we add into baseClass. - // NB: You will typically never create any instances of proxyClass; we use it - // only for stealing its contents and put it into baseClass. - Method originalMethod = class_getInstanceMethod(baseClass, originalSel); - Method newMethod = class_getInstanceMethod(proxyClass, originalSel); - Method fakeMethod = class_getInstanceMethod(proxyClass, fakeSel); - - IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(newMethod)); - class_addMethod(baseClass, fakeSel, originalImp, method_getTypeEncoding(fakeMethod)); -#endif - } -} - -void macStopIntercept(SEL originalSel, SEL fakeSel, Class baseClass, Class /* proxyClass */) -{ -#ifndef QT_MAC_USE_COCOA - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) -#endif - { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - Method originalMethod = class_getInstanceMethod(baseClass, originalSel); - Method fakeMethodInBaseClass = class_getInstanceMethod(baseClass, fakeSel); - method_setImplementation(originalMethod, method_getImplementation(fakeMethodInBaseClass)); -#endif - } -} - /* Intercept the NSColorPanel constructor if the shared color panel doesn't exist yet. What's going on here is @@ -188,12 +149,18 @@ void macStopIntercept(SEL originalSel, SEL fakeSel, Class baseClass, Class /* pr */ void macStartInterceptNSPanelCtor() { - macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:), - @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:), - [NSPanel class], [QNSPanelProxy class]); - macStartIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:), - @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:), - [NSPanel class], [QNSPanelProxy class]); + qt_cocoa_change_implementation( + [NSPanel class], + @selector(initWithContentRect:styleMask:backing:defer:), + [QNSPanelProxy class], + @selector(initWithContentRect:styleMask:backing:defer:), + @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:)); + qt_cocoa_change_implementation( + [NSPanel class], + @selector(initWithContentRect:styleMask:backing:defer:screen:), + [QNSPanelProxy class], + @selector(initWithContentRect:styleMask:backing:defer:screen:), + @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:)); } /* @@ -201,12 +168,14 @@ void macStartInterceptNSPanelCtor() */ void macStopInterceptNSPanelCtor() { - macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:screen:), - @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:), - [NSPanel class], [QNSPanelProxy class]); - macStopIntercept(@selector(initWithContentRect:styleMask:backing:defer:), - @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:), - [NSPanel class], [QNSPanelProxy class]); + qt_cocoa_change_back_implementation( + [NSPanel class], + @selector(initWithContentRect:styleMask:backing:defer:screen:), + @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:screen:)); + qt_cocoa_change_back_implementation( + [NSPanel class], + @selector(initWithContentRect:styleMask:backing:defer:), + @selector(qt_fakeInitWithContentRect:styleMask:backing:defer:)); } /* @@ -216,8 +185,12 @@ void macStopInterceptNSPanelCtor() void macStartInterceptWindowTitle(QWidget *window) { currentWindow = window; - macStartIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:), - [NSWindow class], [QNSWindowProxy class]); + qt_cocoa_change_implementation( + [NSWindow class], + @selector(setTitle:), + [QNSWindowProxy class], + @selector(setTitle:), + @selector(qt_fakeSetTitle:)); } /* @@ -226,8 +199,10 @@ void macStartInterceptWindowTitle(QWidget *window) void macStopInterceptWindowTitle() { currentWindow = 0; - macStopIntercept(@selector(setTitle:), @selector(qt_fakeSetTitle:), - [NSWindow class], [QNSWindowProxy class]); + qt_cocoa_change_back_implementation( + [NSWindow class], + @selector(setTitle:), + @selector(qt_fakeSetTitle:)); } /* diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 6fd45ad..b6cc2ac 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -213,7 +213,8 @@ embedded { qcocoaapplicationdelegate_mac_p.h \ qmacgesturerecognizer_mac_p.h \ qmultitouch_mac_p.h \ - qcocoasharedwindowmethods_mac_p.h + qcocoasharedwindowmethods_mac_p.h \ + qcocoaintrospection_p.h OBJECTIVE_SOURCES += \ kernel/qcursor_mac.mm \ @@ -233,7 +234,8 @@ embedded { kernel/qeventdispatcher_mac.mm \ kernel/qcocoawindowcustomthemeframe_mac.mm \ kernel/qmacgesturerecognizer_mac.mm \ - kernel/qmultitouch_mac.mm + kernel/qmultitouch_mac.mm \ + kernel/qcocoaintrospection_mac.mm HEADERS += \ kernel/qt_cocoa_helpers_mac_p.h \ diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index c21b982..ebb329b 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -233,6 +233,7 @@ public: #if defined(Q_WS_MAC) virtual bool macEventFilter(EventHandlerCallRef, EventRef); + virtual bool macEventFilter(void *); #endif #if defined(Q_WS_X11) virtual bool x11EventFilter(XEvent *); diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 321492d..4cd14df 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -1246,6 +1246,8 @@ void qt_init(QApplicationPrivate *priv, int) // Cocoa application delegate #ifdef QT_MAC_USE_COCOA NSApplication *cocoaApp = [QNSApplication sharedApplication]; + qt_redirectNSApplicationSendEvent(); + QMacCocoaAutoReleasePool pool; NSObject *oldDelegate = [cocoaApp delegate]; QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) *newDelegate = [QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate]; @@ -2611,7 +2613,7 @@ OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, Ap /*! \fn bool QApplication::macEventFilter(EventHandlerCallRef caller, EventRef event) - \warning This virtual function is only implemented under Mac OS X when against Carbon. + \warning This virtual function is only used under Mac OS X when Qt is based on Carbon. If you create an application that inherits QApplication and reimplement this function, you get direct access to all Carbon Events that Qt registers @@ -2622,14 +2624,7 @@ OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, Ap Return false for normal event dispatching. The default implementation returns false. - Cocoa uses a different event system which means this function is NOT CALLED - when building Qt against Cocoa. If you want similar functionality subclass - NSApplication and reimplement the sendEvent: message to handle all the - NSEvents. You also will need to to instantiate your custom NSApplication - before creating a QApplication. See \l - {http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html}{Apple's - NSApplication Reference} for more information. - + \sa macEventFilter(void *nsevent) */ bool QApplication::macEventFilter(EventHandlerCallRef, EventRef) { @@ -2637,6 +2632,29 @@ bool QApplication::macEventFilter(EventHandlerCallRef, EventRef) } /*! + \fn bool QApplication::macEventFilter(void *nsevent) + + \warning This virtual function is only used under Mac OS X when Qt is based on Cocoa. + + If you create an application that inherits QApplication and reimplement + this function, you get direct access to all NSEvents that Qt receives + from Cocoa. + \a nsevent is of type NSEvent *: + + NSEvent *e = static_cast(nsevent); + + Return true if you want to stop the event from being processed. + Return false for normal event dispatching. The default + implementation returns false. + + \sa macEventFilter(EventHandlerCallRef caller, EventRef event) +*/ +bool QApplication::macEventFilter(void * /*NSEvent*/) +{ + return false; +} + +/*! \internal */ void QApplicationPrivate::openPopup(QWidget *popup) @@ -3110,11 +3128,7 @@ void onApplicationChangedActivation( bool activated ) } if (!app->activeWindow()) { -#if QT_MAC_USE_COCOA - OSWindowRef wp = [NSApp keyWindow]; -#else - OSWindowRef wp = ActiveNonFloatingWindow(); -#endif + OSWindowRef wp = [NSApp keyWindow]; if (QWidget *tmp_w = qt_mac_find_window(wp)) app->setActiveWindow(tmp_w); } diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm index 4962863..5cd32a1 100644 --- a/src/gui/kernel/qcocoaapplication_mac.mm +++ b/src/gui/kernel/qcocoaapplication_mac.mm @@ -78,6 +78,7 @@ #include #include #include +#include QT_USE_NAMESPACE @@ -116,12 +117,26 @@ QT_USE_NAMESPACE quint64 lower = [event data1]; quint64 upper = [event data2]; QCocoaPostMessageArgs *args = reinterpret_cast(lower | (upper << 32)); - [args->target performSelector:args->selector]; + switch (args->argCount) { + case 0: + [args->target performSelector:args->selector]; + break; + case 1: + [args->target performSelector:args->selector withObject:args->arg1]; + break; + case 3: + [args->target performSelector:args->selector withObject:args->arg1 withObject:args->arg2]; + break; + } + delete args; } -- (BOOL)qt_sendEvent:(NSEvent *)event +- (BOOL)qt_filterEvent:(NSEvent *)event { + if (qApp->macEventFilter(event)) + return true; + if ([event type] == NSApplicationDefined) { switch ([event subtype]) { case QtCocoaEventSubTypePostMessage: @@ -138,20 +153,55 @@ QT_USE_NAMESPACE @implementation QNSApplication -// WARNING: If Qt did not create NSApplication (this can e.g. -// happend if Qt is used as a plugin from a 3rd-party cocoa -// application), QNSApplication::sendEvent will never be called. -// SO DO NOT RELY ON THIS FUNCTION BEING AVAILABLE. -// Plugin developers that _do_ control the NSApplication sub-class -// implementation of the 3rd-party application can call qt_sendEvent -// from the sub-class event handler (like we do here) to work around -// any issues. +- (void)qt_sendEvent_original:(NSEvent *)event +{ + Q_UNUSED(event); + // This method will only be used as a signature + // template for the method we add into NSApplication + // containing the original [NSApplication sendEvent:] implementation +} + +- (void)qt_sendEvent_replacement:(NSEvent *)event +{ + // This method (or its implementation to be precise) will + // be called instead of sendEvent if redirection occurs. + // 'self' will then be an instance of NSApplication + // (and not QNSApplication) + if (![NSApp qt_filterEvent:event]) + [self qt_sendEvent_original:event]; +} + - (void)sendEvent:(NSEvent *)event { - if (![self qt_sendEvent:event]) + // This method will be called if + // no redirection occurs + if (![NSApp qt_filterEvent:event]) [super sendEvent:event]; } @end +QT_BEGIN_NAMESPACE + +void qt_redirectNSApplicationSendEvent() +{ + if ([NSApp isMemberOfClass:[QNSApplication class]]) { + // No need to change implementation since Qt + // already controls a subclass of NSApplication + return; + } + + // Change the implementation of [NSApplication sendEvent] to the + // implementation of qt_sendEvent_replacement found in QNSApplication. + // And keep the old implementation that gets overwritten inside a new + // method 'qt_sendEvent_original' that we add to NSApplication + qt_cocoa_change_implementation( + [NSApplication class], + @selector(sendEvent:), + [QNSApplication class], + @selector(qt_sendEvent_replacement:), + @selector(qt_sendEvent_original:)); + } + +QT_END_NAMESPACE #endif diff --git a/src/gui/kernel/qcocoaapplication_mac_p.h b/src/gui/kernel/qcocoaapplication_mac_p.h index 5569feb..c89ff36 100644 --- a/src/gui/kernel/qcocoaapplication_mac_p.h +++ b/src/gui/kernel/qcocoaapplication_mac_p.h @@ -101,11 +101,17 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate) - (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel; - (void)qt_sendPostedMessage:(NSEvent *)event; -- (BOOL)qt_sendEvent:(NSEvent *)event; +- (BOOL)qt_filterEvent:(NSEvent *)event; @end @interface QNSApplication : NSApplication { } @end +QT_BEGIN_NAMESPACE + +void qt_redirectNSApplicationSendEvent(); + +QT_END_NAMESPACE + #endif diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h index 8652816..717cfa5 100644 --- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h +++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h @@ -149,17 +149,6 @@ QT_END_NAMESPACE - (void)sendEvent:(NSEvent *)event { - if ([event type] == NSApplicationDefined) { - switch ([event subtype]) { - case QtCocoaEventSubTypePostMessage: - [NSApp qt_sendPostedMessage:event]; - return; - default: - break; - } - return; - } - QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self]; // Cocoa can hold onto the window after we've disavowed its knowledge. So, // if we get sent an event afterwards just have it go through the super's diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 8cef03c..cbfbf86 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1423,39 +1423,17 @@ void qt_cocoaChangeOverrideCursor(const QCursor &cursor) [static_cast(qt_mac_nsCursorForQCursor(cursor)) set]; } -// WARNING: If Qt did not create NSApplication (e.g. in case it is -// used as a plugin), and at the same time, there is no window on -// screen (or the window that the event is sendt to becomes hidden etc -// before the event gets delivered), the message will not be performed. -bool qt_cocoaPostMessage(id target, SEL selector) +void qt_cocoaPostMessage(id target, SEL selector, int argCount, id arg1, id arg2) { - if (!target) - return false; - - NSInteger windowNumber = 0; - if (![NSApp isMemberOfClass:[QNSApplication class]]) { - // INVARIANT: Cocoa is not using our NSApplication subclass. That means - // we don't control the main event handler either. So target the event - // for one of the windows on screen: - NSWindow *nswin = [NSApp mainWindow]; - if (!nswin) { - nswin = [NSApp keyWindow]; - if (!nswin) - return false; - } - windowNumber = [nswin windowNumber]; - } - - // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5! + // WARNING: data1 and data2 is truncated to from 64-bit to 32-bit on OS 10.5! // That is why we need to split the address in two parts: - QCocoaPostMessageArgs *args = new QCocoaPostMessageArgs(target, selector); + QCocoaPostMessageArgs *args = new QCocoaPostMessageArgs(target, selector, argCount, arg1, arg2); quint32 lower = quintptr(args); quint32 upper = quintptr(args) >> 32; NSEvent *e = [NSEvent otherEventWithType:NSApplicationDefined - location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:windowNumber + location:NSZeroPoint modifierFlags:0 timestamp:0 windowNumber:0 context:nil subtype:QtCocoaEventSubTypePostMessage data1:lower data2:upper]; [NSApp postEvent:e atStart:NO]; - return true; } #endif diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 5db121a..6b005ca 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -198,17 +198,25 @@ class QCocoaPostMessageArgs { public: id target; SEL selector; - QCocoaPostMessageArgs(id target, SEL selector) : target(target), selector(selector) + int argCount; + id arg1; + id arg2; + QCocoaPostMessageArgs(id target, SEL selector, int argCount=0, id arg1=0, id arg2=0) + : target(target), selector(selector), argCount(argCount), arg1(arg1), arg2(arg2) { [target retain]; + [arg1 retain]; + [arg2 retain]; } ~QCocoaPostMessageArgs() { + [arg2 release]; + [arg1 release]; [target release]; } }; -bool qt_cocoaPostMessage(id target, SEL selector); +void qt_cocoaPostMessage(id target, SEL selector, int argCount=0, id arg1=0, id arg2=0); #endif #endif diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index aaa113b..8016da9 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -2052,8 +2052,7 @@ bool QMenuBar::macUpdateMenuBar() { #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; - if (!qt_cocoaPostMessage(getMenuLoader(), @selector(qtUpdateMenubar))) - return QMenuBarPrivate::macUpdateMenuBarImmediatly(); + qt_cocoaPostMessage(getMenuLoader(), @selector(qtUpdateMenubar)); return true; #else return QMenuBarPrivate::macUpdateMenuBarImmediatly(); -- cgit v0.12 From 10946afd136ea5c31ed107663c5f99f326a2beb2 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 May 2010 13:59:27 +0200 Subject: Cocoa: QShortcut(Qt::Key_Enter) does not show in the menu bar The reason is that cocoa expects the unicode control character for "enter", rather than the glyph showing an arrow. So rather than using the glyph-table from QKeySequence, we should use a table containing a mapping from Qt::Key to Cocoa control key. Luckily, such a table exists allready in qt_cocoa_helpers, but reversed ( cocoa key to Qt::Key). So this patch creates a function that binds all this together. Reviewed-by: cduclos --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 161 ++++++++++++++++++++------------- src/gui/widgets/qmenu_mac.mm | 14 +-- 2 files changed, 104 insertions(+), 71 deletions(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index cbfbf86..e8b5149 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -469,7 +469,6 @@ void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec) qt_sendSpontaneousEvent(qApp, &qtabletProximity); } -#ifdef QT_MAC_USE_COCOA // Use this method to keep all the information in the TextSegment. As long as it is ordered // we are in OK shape, and we can influence that ourselves. struct KeyPair @@ -493,69 +492,107 @@ bool operator<(QChar qchar, const KeyPair &entry) return qchar < entry.cocoaKey; } +bool operator<(const Qt::Key &key, const KeyPair &entry) +{ + return key < entry.qtKey; +} + +bool operator<(const KeyPair &entry, const Qt::Key &key) +{ + return entry.qtKey < key; +} + +static bool qtKey2CocoaKeySortLessThan(const KeyPair &entry1, const KeyPair &entry2) +{ + return entry1.qtKey < entry2.qtKey; +} + +static const int NumEntries = 59; +static const KeyPair entries[NumEntries] = { + { NSEnterCharacter, Qt::Key_Enter }, + { NSBackspaceCharacter, Qt::Key_Backspace }, + { NSTabCharacter, Qt::Key_Tab }, + { NSNewlineCharacter, Qt::Key_Return }, + { NSCarriageReturnCharacter, Qt::Key_Return }, + { NSBackTabCharacter, Qt::Key_Backtab }, + { NSDeleteCharacter, Qt::Key_Delete }, + { kEscapeCharCode, Qt::Key_Escape }, + { NSUpArrowFunctionKey, Qt::Key_Up }, + { NSDownArrowFunctionKey, Qt::Key_Down }, + { NSLeftArrowFunctionKey, Qt::Key_Left }, + { NSRightArrowFunctionKey, Qt::Key_Right }, + { NSF1FunctionKey, Qt::Key_F1 }, + { NSF2FunctionKey, Qt::Key_F2 }, + { NSF3FunctionKey, Qt::Key_F3 }, + { NSF4FunctionKey, Qt::Key_F4 }, + { NSF5FunctionKey, Qt::Key_F5 }, + { NSF6FunctionKey, Qt::Key_F6 }, + { NSF7FunctionKey, Qt::Key_F7 }, + { NSF8FunctionKey, Qt::Key_F8 }, + { NSF9FunctionKey, Qt::Key_F8 }, + { NSF10FunctionKey, Qt::Key_F10 }, + { NSF11FunctionKey, Qt::Key_F11 }, + { NSF12FunctionKey, Qt::Key_F12 }, + { NSF13FunctionKey, Qt::Key_F13 }, + { NSF14FunctionKey, Qt::Key_F14 }, + { NSF15FunctionKey, Qt::Key_F15 }, + { NSF16FunctionKey, Qt::Key_F16 }, + { NSF17FunctionKey, Qt::Key_F17 }, + { NSF18FunctionKey, Qt::Key_F18 }, + { NSF19FunctionKey, Qt::Key_F19 }, + { NSF20FunctionKey, Qt::Key_F20 }, + { NSF21FunctionKey, Qt::Key_F21 }, + { NSF22FunctionKey, Qt::Key_F22 }, + { NSF23FunctionKey, Qt::Key_F23 }, + { NSF24FunctionKey, Qt::Key_F24 }, + { NSF25FunctionKey, Qt::Key_F25 }, + { NSF26FunctionKey, Qt::Key_F26 }, + { NSF27FunctionKey, Qt::Key_F27 }, + { NSF28FunctionKey, Qt::Key_F28 }, + { NSF29FunctionKey, Qt::Key_F29 }, + { NSF30FunctionKey, Qt::Key_F30 }, + { NSF31FunctionKey, Qt::Key_F31 }, + { NSF32FunctionKey, Qt::Key_F32 }, + { NSF33FunctionKey, Qt::Key_F33 }, + { NSF34FunctionKey, Qt::Key_F34 }, + { NSF35FunctionKey, Qt::Key_F35 }, + { NSInsertFunctionKey, Qt::Key_Insert }, + { NSDeleteFunctionKey, Qt::Key_Delete }, + { NSHomeFunctionKey, Qt::Key_Home }, + { NSEndFunctionKey, Qt::Key_End }, + { NSPageUpFunctionKey, Qt::Key_PageUp }, + { NSPageDownFunctionKey, Qt::Key_PageDown }, + { NSPrintScreenFunctionKey, Qt::Key_Print }, + { NSScrollLockFunctionKey, Qt::Key_ScrollLock }, + { NSPauseFunctionKey, Qt::Key_Pause }, + { NSSysReqFunctionKey, Qt::Key_SysReq }, + { NSMenuFunctionKey, Qt::Key_Menu }, + { NSHelpFunctionKey, Qt::Key_Help }, +}; +static const KeyPair * const end = entries + NumEntries; + +QChar qtKey2CocoaKey(Qt::Key key) +{ + // The first time this function is called, create a reverse + // looup table sorted on Qt Key rather than Cocoa key: + static QVector rev_entries(NumEntries); + static bool mustInit = true; + if (mustInit){ + mustInit = false; + for (int i=0; i::iterator i + = qBinaryFind(rev_entries.begin(), rev_entries.end(), key); + if (i == rev_entries.end()) + return QChar(); + return i->cocoaKey; +} + +#ifdef QT_MAC_USE_COCOA static Qt::Key cocoaKey2QtKey(QChar keyCode) { - static const int NumEntries = 57; - static const KeyPair entries[NumEntries] = { - { NSEnterCharacter, Qt::Key_Enter }, - { NSTabCharacter, Qt::Key_Tab }, - { NSCarriageReturnCharacter, Qt::Key_Return }, - { NSBackTabCharacter, Qt::Key_Backtab }, - { kEscapeCharCode, Qt::Key_Escape }, - { NSDeleteCharacter, Qt::Key_Backspace }, - { NSUpArrowFunctionKey, Qt::Key_Up }, - { NSDownArrowFunctionKey, Qt::Key_Down }, - { NSLeftArrowFunctionKey, Qt::Key_Left }, - { NSRightArrowFunctionKey, Qt::Key_Right }, - { NSF1FunctionKey, Qt::Key_F1 }, - { NSF2FunctionKey, Qt::Key_F2 }, - { NSF3FunctionKey, Qt::Key_F3 }, - { NSF4FunctionKey, Qt::Key_F4 }, - { NSF5FunctionKey, Qt::Key_F5 }, - { NSF6FunctionKey, Qt::Key_F6 }, - { NSF7FunctionKey, Qt::Key_F7 }, - { NSF8FunctionKey, Qt::Key_F8 }, - { NSF9FunctionKey, Qt::Key_F8 }, - { NSF10FunctionKey, Qt::Key_F10 }, - { NSF11FunctionKey, Qt::Key_F11 }, - { NSF12FunctionKey, Qt::Key_F12 }, - { NSF13FunctionKey, Qt::Key_F13 }, - { NSF14FunctionKey, Qt::Key_F14 }, - { NSF15FunctionKey, Qt::Key_F15 }, - { NSF16FunctionKey, Qt::Key_F16 }, - { NSF17FunctionKey, Qt::Key_F17 }, - { NSF18FunctionKey, Qt::Key_F18 }, - { NSF19FunctionKey, Qt::Key_F19 }, - { NSF20FunctionKey, Qt::Key_F20 }, - { NSF21FunctionKey, Qt::Key_F21 }, - { NSF22FunctionKey, Qt::Key_F22 }, - { NSF23FunctionKey, Qt::Key_F23 }, - { NSF24FunctionKey, Qt::Key_F24 }, - { NSF25FunctionKey, Qt::Key_F25 }, - { NSF26FunctionKey, Qt::Key_F26 }, - { NSF27FunctionKey, Qt::Key_F27 }, - { NSF28FunctionKey, Qt::Key_F28 }, - { NSF29FunctionKey, Qt::Key_F29 }, - { NSF30FunctionKey, Qt::Key_F30 }, - { NSF31FunctionKey, Qt::Key_F31 }, - { NSF32FunctionKey, Qt::Key_F32 }, - { NSF33FunctionKey, Qt::Key_F33 }, - { NSF34FunctionKey, Qt::Key_F34 }, - { NSF35FunctionKey, Qt::Key_F35 }, - { NSInsertFunctionKey, Qt::Key_Insert }, - { NSDeleteFunctionKey, Qt::Key_Delete }, - { NSHomeFunctionKey, Qt::Key_Home }, - { NSEndFunctionKey, Qt::Key_End }, - { NSPageUpFunctionKey, Qt::Key_PageUp }, - { NSPageDownFunctionKey, Qt::Key_PageDown }, - { NSPrintScreenFunctionKey, Qt::Key_Print }, - { NSScrollLockFunctionKey, Qt::Key_ScrollLock }, - { NSPauseFunctionKey, Qt::Key_Pause }, - { NSSysReqFunctionKey, Qt::Key_SysReq }, - { NSMenuFunctionKey, Qt::Key_Menu }, - { NSHelpFunctionKey, Qt::Key_Help }, - }; - static const KeyPair * const end = entries + NumEntries; const KeyPair *i = qBinaryFind(entries, end, keyCode); if (i == end) return Qt::Key(keyCode.unicode()); diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 8016da9..60023a8 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1254,15 +1254,11 @@ QMenuPrivate::QMacMenuPrivate::addAction(QMacMenuAction *action, QMacMenuAction NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) { quint32 accel_key = (accel[0] & ~(Qt::MODIFIER_MASK | Qt::UNICODE_ACCEL)); - extern QChar qt_macSymbolForQtKey(int key); // qkeysequence.cpp - QChar keyEquiv = qt_macSymbolForQtKey(accel_key); - if (keyEquiv.isNull()) { - if (accel_key >= Qt::Key_F1 && accel_key <= Qt::Key_F15) - keyEquiv = (accel_key - Qt::Key_F1) + NSF1FunctionKey; - else - keyEquiv = unichar(QChar(accel_key).toLower().unicode()); - } - return [NSString stringWithCharacters:&keyEquiv.unicode() length:1]; + extern QChar qtKey2CocoaKey(Qt::Key key); + QChar cocoa_key = qtKey2CocoaKey(Qt::Key(accel_key)); + if (cocoa_key.isNull()) + cocoa_key = QChar(accel_key).toLower().unicode(); + return [NSString stringWithCharacters:&cocoa_key.unicode() length:1]; } // return the cocoa modifier mask for the QKeySequence (currently only looks at the first one). -- cgit v0.12 From 0847b9b50987f2e11e3193e7eed4012e4240a492 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 May 2010 14:23:04 +0200 Subject: Cocoa: Glyph for "Enter" is wrong in QKeySequence It uses the same glyph for enter as for return. But just looking at the mac keyboard it can be seen that this is not correct. Reviewed-by: msorvig --- src/gui/kernel/qkeysequence.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index d9a0952..b038fde 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -76,7 +76,7 @@ static const MacSpecialKey entries[NumEntries] = { { Qt::Key_Backtab, 0x21E4 }, { Qt::Key_Backspace, 0x232B }, { Qt::Key_Return, 0x21B5 }, - { Qt::Key_Enter, 0x21B5 }, + { Qt::Key_Enter, 0x2324 }, { Qt::Key_Delete, 0x2326 }, { Qt::Key_Home, 0x2196 }, { Qt::Key_End, 0x2198 }, -- cgit v0.12 From 8b0c6e6d68053b62b3b38e9a2cf24e39b6df9086 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 7 May 2010 10:44:34 +0200 Subject: Autotest, Mac: added more native key event testing Added a couple of more tests that checks, among others, modifier flags. It turns out that there are some issues related to this: 1. When releasing a key while holding the command modifier, we do not key at key up event from cocoa. 2. The AA_MacDontSwapCtrlAndMeta attribute turns out to be half-way implemented. This test will not fail on any of this issues. --- tests/auto/macnativeevents/expectedeventlist.cpp | 29 ++++-- tests/auto/macnativeevents/expectedeventlist.h | 2 +- tests/auto/macnativeevents/nativeeventlist.cpp | 8 +- tests/auto/macnativeevents/nativeeventlist.h | 1 + tests/auto/macnativeevents/qnativeevents_mac.cpp | 8 +- tests/auto/macnativeevents/tst_macnativeevents.cpp | 107 +++++++++++++++++++++ 6 files changed, 139 insertions(+), 16 deletions(-) diff --git a/tests/auto/macnativeevents/expectedeventlist.cpp b/tests/auto/macnativeevents/expectedeventlist.cpp index 0679dcb..82a594b 100644 --- a/tests/auto/macnativeevents/expectedeventlist.cpp +++ b/tests/auto/macnativeevents/expectedeventlist.cpp @@ -49,7 +49,9 @@ ExpectedEventList::ExpectedEventList(QObject *target) : QObject(target), eventCount(0) { target->installEventFilter(this); - debug = !qgetenv("NATIVEDEBUG").isEmpty(); + debug = qgetenv("NATIVEDEBUG").toInt(); + if (debug > 0) + qDebug() << "Debug level sat to:" << debug; } ExpectedEventList::~ExpectedEventList() @@ -104,14 +106,17 @@ void ExpectedEventList::compareMouseEvents(QEvent *received, QEvent *expected) && (e1->globalPos() == e2->globalPos()) && (e1->button() == e2->button()) && (e1->buttons() == e2->buttons()) - && (e1->modifiers() == e2->modifiers())) + && (e1->modifiers() == e2->modifiers())) { + if (debug > 0) + qDebug() << " Received (OK):" << e1 << e1->globalPos(); return; // equal + } // INVARIANT: The two events are not equal. So we fail. Depending // on whether debug mode is no or not, we let QTest fail. Otherwise // we let the test continue for debugging puposes. int eventListNr = eventCount - eventList.size(); - if (!debug) { + if (debug == 0) { qWarning() << "Expected event" << eventListNr << "differs from received event:"; QCOMPARE(e1->pos(), e2->pos()); QCOMPARE(e1->globalPos(), e2->globalPos()); @@ -135,14 +140,17 @@ void ExpectedEventList::compareKeyEvents(QEvent *received, QEvent *expected) if (e1->key() == e2->key() && (e1->modifiers() == e2->modifiers()) && (e1->count() == e2->count()) - && (e1->isAutoRepeat() == e2->isAutoRepeat())) + && (e1->isAutoRepeat() == e2->isAutoRepeat())) { + if (debug > 0) + qDebug() << " Received (OK):" << e1 << QKeySequence(e1->key()).toString(QKeySequence::NativeText); return; // equal + } // INVARIANT: The two events are not equal. So we fail. Depending // on whether debug mode is no or not, we let QTest fail. Otherwise // we let the test continue for debugging puposes. int eventListNr = eventCount - eventList.size(); - if (!debug) { + if (debug == 0) { qWarning() << "Expected event" << eventListNr << "differs from received event:"; QCOMPARE(e1->key(), e2->key()); QCOMPARE(e1->modifiers(), e2->modifiers()); @@ -150,18 +158,19 @@ void ExpectedEventList::compareKeyEvents(QEvent *received, QEvent *expected) QCOMPARE(e1->isAutoRepeat(), e2->isAutoRepeat()); } else { qWarning() << "*** FAIL *** : Expected event" << eventListNr << "differs from received event:"; - qWarning() << "Received:" << e1 << e1->key(); - qWarning() << "Expected:" << e2 << e2->key(); + qWarning() << "Received:" << e1 << QKeySequence(e1->key()).toString(QKeySequence::NativeText); + qWarning() << "Expected:" << e2 << QKeySequence(e2->key()).toString(QKeySequence::NativeText); } } bool ExpectedEventList::eventFilter(QObject *, QEvent *received) { - if (debug) + if (debug > 1) qDebug() << received; if (eventList.isEmpty()) return false; + bool eat = false; QEvent *expected = eventList.first(); if (expected->type() == received->type()) { eventList.removeFirst(); @@ -175,11 +184,13 @@ bool ExpectedEventList::eventFilter(QObject *, QEvent *received) case QEvent::NonClientAreaMouseButtonDblClick: case QEvent::NonClientAreaMouseMove: { compareMouseEvents(received, expected); + eat = true; break; } case QEvent::KeyPress: case QEvent::KeyRelease: { compareKeyEvents(received, expected); + eat = true; break; } case QEvent::Resize: { @@ -198,6 +209,6 @@ bool ExpectedEventList::eventFilter(QObject *, QEvent *received) QAbstractEventDispatcher::instance()->interrupt(); } - return false; + return eat; } diff --git a/tests/auto/macnativeevents/expectedeventlist.h b/tests/auto/macnativeevents/expectedeventlist.h index bd9f358..21eb193 100644 --- a/tests/auto/macnativeevents/expectedeventlist.h +++ b/tests/auto/macnativeevents/expectedeventlist.h @@ -51,7 +51,7 @@ class ExpectedEventList : public QObject { QList eventList; QBasicTimer timer; - bool debug; + int debug; int eventCount; void timerEvent(QTimerEvent *); diff --git a/tests/auto/macnativeevents/nativeeventlist.cpp b/tests/auto/macnativeevents/nativeeventlist.cpp index 1a90ee0..f730377 100644 --- a/tests/auto/macnativeevents/nativeeventlist.cpp +++ b/tests/auto/macnativeevents/nativeeventlist.cpp @@ -47,7 +47,8 @@ NativeEventList::NativeEventList(int defaultWaitMs) , wait(false) , defaultWaitMs(defaultWaitMs) { - QString multiplier = qgetenv("NATIVEDEBUG"); + debug = qgetenv("NATIVEDEBUG").toInt(); + QString multiplier = qgetenv("NATIVEDEBUGSPEED"); if (!multiplier.isEmpty()) setTimeMultiplier(multiplier.toFloat()); } @@ -61,8 +62,11 @@ NativeEventList::~NativeEventList() void NativeEventList::sendNextEvent() { QNativeEvent *e = eventList.at(currIndex).second; - if (e) + if (e) { + if (debug > 0) + qDebug() << "Sending:" << *e; QNativeInput::sendNativeEvent(*e); + } waitNextEvent(); } diff --git a/tests/auto/macnativeevents/nativeeventlist.h b/tests/auto/macnativeevents/nativeeventlist.h index efcca43..9f9498d 100644 --- a/tests/auto/macnativeevents/nativeeventlist.h +++ b/tests/auto/macnativeevents/nativeeventlist.h @@ -76,6 +76,7 @@ private: int currIndex; bool wait; int defaultWaitMs; + int debug; }; #endif diff --git a/tests/auto/macnativeevents/qnativeevents_mac.cpp b/tests/auto/macnativeevents/qnativeevents_mac.cpp index 6c04bf3..cc12cc9 100644 --- a/tests/auto/macnativeevents/qnativeevents_mac.cpp +++ b/tests/auto/macnativeevents/qnativeevents_mac.cpp @@ -54,11 +54,11 @@ static Qt::KeyboardModifiers getModifiersFromQuartzEvent(CGEventRef inEvent) if (flags & kCGEventFlagMaskShift || flags & kCGEventFlagMaskAlphaShift) m |= Qt::ShiftModifier; if (flags & kCGEventFlagMaskControl) - m |= Qt::MetaModifier; + m |= Qt::ControlModifier; if (flags & kCGEventFlagMaskAlternate) m |= Qt::AltModifier; if (flags & kCGEventFlagMaskCommand) - m |= Qt::ControlModifier; + m |= Qt::MetaModifier; return m; } @@ -67,11 +67,11 @@ static void setModifiersFromQNativeEvent(CGEventRef inEvent, const QNativeEvent CGEventFlags flags = 0; if (event.modifiers.testFlag(Qt::ShiftModifier)) flags |= kCGEventFlagMaskShift; - if (event.modifiers.testFlag(Qt::MetaModifier)) + if (event.modifiers.testFlag(Qt::ControlModifier)) flags |= kCGEventFlagMaskControl; if (event.modifiers.testFlag(Qt::AltModifier)) flags |= kCGEventFlagMaskAlternate; - if (event.modifiers.testFlag(Qt::ControlModifier)) + if (event.modifiers.testFlag(Qt::MetaModifier)) flags |= kCGEventFlagMaskCommand; CGEventSetFlags(inEvent, flags); } diff --git a/tests/auto/macnativeevents/tst_macnativeevents.cpp b/tests/auto/macnativeevents/tst_macnativeevents.cpp index ffd0596..16638ce 100644 --- a/tests/auto/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/macnativeevents/tst_macnativeevents.cpp @@ -48,6 +48,7 @@ #include "qnativeevents.h" #include "nativeeventlist.h" #include "expectedeventlist.h" +#include #ifdef Q_OS_MAC @@ -68,6 +69,10 @@ private slots: void testMouseEnter(); void testChildDialogInFrontOfModalParent(); void testKeyPressOnToplevel(); + void testModifierShift(); + void testModifierAlt(); + void testModifierCtrl(); + void testModifierCtrlWithDontSwapCtrlAndMeta(); }; void tst_MacNativeEvents::testMouseMoveLocation() @@ -330,6 +335,108 @@ void tst_MacNativeEvents::testKeyPressOnToplevel() QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); } +void tst_MacNativeEvents::testModifierShift() +{ + QWidget w; + w.show(); + + NativeEventList native; + native.append(new QNativeModifierEvent(Qt::ShiftModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, true, Qt::ShiftModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, false, Qt::ShiftModifier)); + native.append(new QNativeModifierEvent(Qt::NoModifier)); + + ExpectedEventList expected(&w); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_Shift, Qt::NoModifier)); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::ShiftModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ShiftModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_Shift, Qt::ShiftModifier)); + + native.play(); + QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); +} + +void tst_MacNativeEvents::testModifierAlt() +{ + QWidget w; + w.show(); + + NativeEventList native; + native.append(new QNativeModifierEvent(Qt::AltModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, true, Qt::AltModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, false, Qt::AltModifier)); + native.append(new QNativeModifierEvent(Qt::NoModifier)); + + ExpectedEventList expected(&w); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_Alt, Qt::NoModifier)); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::AltModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::AltModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_Alt, Qt::AltModifier)); + + native.play(); + QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); +} + +void tst_MacNativeEvents::testModifierCtrl() +{ + // On Mac, we switch the Command and Control modifier by default, so that Command + // means Meta, and Control means Command. Lets check that this works: + QWidget w; + w.show(); + + QVERIFY(kControlUnicode == QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText)[0]); + QVERIFY(kCommandUnicode == QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText)[0]); + + NativeEventList native; + native.append(new QNativeModifierEvent(Qt::ControlModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, true, Qt::ControlModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, false, Qt::ControlModifier)); + native.append(new QNativeModifierEvent(Qt::NoModifier)); + + ExpectedEventList expected(&w); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_Meta, Qt::NoModifier)); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::MetaModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::MetaModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_Meta, Qt::MetaModifier)); + + native.play(); + QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); +} + +void tst_MacNativeEvents::testModifierCtrlWithDontSwapCtrlAndMeta() +{ + // On Mac, we switch the Command and Control modifier by default, so that Command + // means Meta, and Control means Command. Lets check that the flag to swith off + // this behaviour works. While working on this test I realised that we actually + // don't (and never have) respected this flag for raw key events. Only for + // menus, through QKeySequence. I don't want to change this behaviour now, at + // least not until someone complains. So I choose to let the test just stop + // any unintended regressions instead. If we decide to resepect the the flag at one + // point, fix the test. + QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta); + QWidget w; + w.show(); + + QVERIFY(kCommandUnicode == QKeySequence(Qt::Key_Meta).toString(QKeySequence::NativeText)[0]); + QVERIFY(kControlUnicode == QKeySequence(Qt::Key_Control).toString(QKeySequence::NativeText)[0]); + + NativeEventList native; + native.append(new QNativeModifierEvent(Qt::ControlModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, true, Qt::ControlModifier)); + native.append(new QNativeKeyEvent(QNativeKeyEvent::Key_A, false, Qt::ControlModifier)); + native.append(new QNativeModifierEvent(Qt::NoModifier)); + + ExpectedEventList expected(&w); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_Meta, Qt::NoModifier)); + expected.append(new QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_A, Qt::ControlModifier)); + expected.append(new QKeyEvent(QEvent::KeyRelease, Qt::Key_Meta, Qt::ControlModifier)); + + native.play(); + QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); + QCoreApplication::setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, false); +} + #include "tst_macnativeevents.moc" QTEST_MAIN(tst_MacNativeEvents) -- cgit v0.12 From a36e8ca7afd0c15e5ec73bf4ea21464ab89a3662 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 20 May 2010 15:21:08 +0200 Subject: Cocoa: remove warnings Rev-By: cduclos --- src/gui/kernel/qt_cocoa_helpers_mac.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e8b5149..de4e125 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1238,7 +1238,7 @@ void qt_mac_replaceDrawRect(void * /*OSWindowRef */window, QWidgetPrivate *widge // We have the original method here. Proceed and swap the methods. method_exchangeImplementations(m1, m0); widget->originalDrawMethod = false; - [window display]; + [theWindow display]; } } @@ -1261,7 +1261,7 @@ void qt_mac_replaceDrawRectOriginal(void * /*OSWindowRef */window, QWidgetPrivat } method_exchangeImplementations(m1, m0); widget->originalDrawMethod = true; - [window display]; + [theWindow display]; } #endif // QT_MAC_USE_COCOA @@ -1509,7 +1509,7 @@ void macDrawRectOnTop(void * /*OSWindowRef */window) NSRect contentRect = [contentView frame]; // Draw a line on top of the already drawn line. // We need to check if we are active or not to use the proper color. - if([window isKeyWindow] || [window isMainWindow]) { + if([theWindow isKeyWindow] || [theWindow isMainWindow]) { [[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0] set]; } else { [[NSColor colorWithCalibratedRed:1.0 green:1.0 blue:1.0 alpha:1.0] set]; @@ -1529,7 +1529,7 @@ void macSyncDrawingOnFirstInvocation(void * /*OSWindowRef */window) { OSWindowRef theWindow = static_cast(window); NSApplication *application = [NSApplication sharedApplication]; - NSToolbar *toolbar = [window toolbar]; + NSToolbar *toolbar = [theWindow toolbar]; if([application isActive]) { // Launched from finder [toolbar setShowsBaselineSeparator:NO]; -- cgit v0.12 From e5d3dcc188439321e129406cb14a51e60a19b727 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 7 May 2010 13:37:16 -0500 Subject: Qt3 Support headers: Avoid warnings from mingw g++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit q3textstream.h and q3cstring.h include some functions declared Q_COMPAT_EXPORT inline, which doesn’t make much sense. It probably makes sense to keep exporting them for backward compatibility, but there is no reason to import them, as gcc notices: q3cstring.h:164: warning: inline function 'bool operator==(const Q3CString&, const Q3CString&)' declared as dllimport: attribute ignored This is analogous to the case of Q_GUI_EXPORT_INLINE, which is already handled in qglobal.h. Reviewed-By: Thierry --- src/corelib/global/qglobal.h | 7 ++++++ src/qt3support/text/q3textstream.h | 6 ++--- src/qt3support/tools/q3cstring.h | 50 +++++++++++++++++++------------------- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index dd8e6ca..924142a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1361,15 +1361,22 @@ class QDataStream; # else # define Q_GUI_EXPORT_INLINE inline # endif +# if defined(QT_BUILD_COMPAT_LIB) +# define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline +# else +# define Q_COMPAT_EXPORT_INLINE inline +# endif #elif defined(Q_CC_RVCT) // we force RVCT not to export inlines by passing --visibility_inlines_hidden // so we need to just inline it, rather than exporting and inlining // note: this affects the contents of the DEF files (ie. these functions do not appear) # define Q_CORE_EXPORT_INLINE inline # define Q_GUI_EXPORT_INLINE inline +# define Q_COMPAT_EXPORT_INLINE inline #else # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline +# define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline #endif /* diff --git a/src/qt3support/text/q3textstream.h b/src/qt3support/text/q3textstream.h index d0c4f48..0e26e08 100644 --- a/src/qt3support/text/q3textstream.h +++ b/src/qt3support/text/q3textstream.h @@ -272,13 +272,13 @@ private: int arg; // member function argument }; -Q_COMPAT_EXPORT inline Q3TextStream &operator>>( Q3TextStream &s, Q3TSFUNC f ) +Q_COMPAT_EXPORT_INLINE Q3TextStream &operator>>( Q3TextStream &s, Q3TSFUNC f ) { return (*f)( s ); } -Q_COMPAT_EXPORT inline Q3TextStream &operator<<( Q3TextStream &s, Q3TSFUNC f ) +Q_COMPAT_EXPORT_INLINE Q3TextStream &operator<<( Q3TextStream &s, Q3TSFUNC f ) { return (*f)( s ); } -Q_COMPAT_EXPORT inline Q3TextStream &operator<<( Q3TextStream &s, Q3TSManip m ) +Q_COMPAT_EXPORT_INLINE Q3TextStream &operator<<( Q3TextStream &s, Q3TSManip m ) { m.exec(s); return s; } Q_COMPAT_EXPORT Q3TextStream &bin( Q3TextStream &s ); // set bin notation diff --git a/src/qt3support/tools/q3cstring.h b/src/qt3support/tools/q3cstring.h index b280ebc..86a31fa 100644 --- a/src/qt3support/tools/q3cstring.h +++ b/src/qt3support/tools/q3cstring.h @@ -161,75 +161,75 @@ inline Q3CString &Q3CString::setNum(float n, char f, int prec) Q3CString non-member operators *****************************************************************************/ -Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator==(const Q3CString &s1, const Q3CString &s2) { return qstrcmp(s1, s2) == 0; } -Q_COMPAT_EXPORT inline bool operator==(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE bool operator==(const Q3CString &s1, const char *s2) { return qstrcmp(s1, s2) == 0; } -Q_COMPAT_EXPORT inline bool operator==(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator==(const char *s1, const Q3CString &s2) { return qstrcmp(s1, s2) == 0; } -Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator!=(const Q3CString &s1, const Q3CString &s2) { return qstrcmp(s1, s2) != 0; } -Q_COMPAT_EXPORT inline bool operator!=(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE bool operator!=(const Q3CString &s1, const char *s2) { return qstrcmp(s1, s2) != 0; } -Q_COMPAT_EXPORT inline bool operator!=(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator!=(const char *s1, const Q3CString &s2) { return qstrcmp(s1, s2) != 0; } -Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const Q3CString& s2) +Q_COMPAT_EXPORT_INLINE bool operator<(const Q3CString &s1, const Q3CString& s2) { return qstrcmp(s1, s2) < 0; } -Q_COMPAT_EXPORT inline bool operator<(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE bool operator<(const Q3CString &s1, const char *s2) { return qstrcmp(s1, s2) < 0; } -Q_COMPAT_EXPORT inline bool operator<(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator<(const char *s1, const Q3CString &s2) { return qstrcmp(s1, s2) < 0; } -Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator<=(const Q3CString &s1, const Q3CString &s2) { return qstrcmp(s1, s2) <= 0; } -Q_COMPAT_EXPORT inline bool operator<=(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE bool operator<=(const Q3CString &s1, const char *s2) { return qstrcmp(s1, s2) <= 0; } -Q_COMPAT_EXPORT inline bool operator<=(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator<=(const char *s1, const Q3CString &s2) { return qstrcmp(s1, s2) <= 0; } -Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator>(const Q3CString &s1, const Q3CString &s2) { return qstrcmp(s1, s2) > 0; } -Q_COMPAT_EXPORT inline bool operator>(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE bool operator>(const Q3CString &s1, const char *s2) { return qstrcmp(s1, s2) > 0; } -Q_COMPAT_EXPORT inline bool operator>(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator>(const char *s1, const Q3CString &s2) { return qstrcmp(s1, s2) > 0; } -Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const Q3CString& s2) +Q_COMPAT_EXPORT_INLINE bool operator>=(const Q3CString &s1, const Q3CString& s2) { return qstrcmp(s1, s2) >= 0; } -Q_COMPAT_EXPORT inline bool operator>=(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE bool operator>=(const Q3CString &s1, const char *s2) { return qstrcmp(s1, s2) >= 0; } -Q_COMPAT_EXPORT inline bool operator>=(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE bool operator>=(const char *s1, const Q3CString &s2) { return qstrcmp(s1, s2) >= 0; } -Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1, const Q3CString &s2) { Q3CString tmp(s1); tmp += s2; return tmp; } -Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1, const QByteArray &s2) { QByteArray tmp(s1); tmp += s2; return tmp; } -Q_COMPAT_EXPORT inline const Q3CString operator+(const QByteArray &s1, +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const QByteArray &s1, const Q3CString &s2) { QByteArray tmp(s1); @@ -237,28 +237,28 @@ Q_COMPAT_EXPORT inline const Q3CString operator+(const QByteArray &s1, return tmp; } -Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, const char *s2) +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1, const char *s2) { Q3CString tmp(s1); tmp += s2; return tmp; } -Q_COMPAT_EXPORT inline const Q3CString operator+(const char *s1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const char *s1, const Q3CString &s2) { Q3CString tmp(s1); tmp += s2; return tmp; } -Q_COMPAT_EXPORT inline const Q3CString operator+(const Q3CString &s1, char c2) +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(const Q3CString &s1, char c2) { Q3CString tmp(s1); tmp += c2; return tmp; } -Q_COMPAT_EXPORT inline const Q3CString operator+(char c1, const Q3CString &s2) +Q_COMPAT_EXPORT_INLINE const Q3CString operator+(char c1, const Q3CString &s2) { Q3CString tmp; tmp += c1; -- cgit v0.12 From 58fc06e9fe538eb824a3ffef74137628e1742608 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 18:38:14 +0200 Subject: Revert "Revert "Improve QUrl handling of local file paths"" This reverts commit 98e935eed5549e479f6666680aed1711dc42111c. --- src/corelib/io/qurl.cpp | 73 +++++++++++++++++++++++++++++++------------- src/corelib/io/qurl.h | 1 + tests/auto/qurl/tst_qurl.cpp | 11 ++++++- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 79a8ce4..15bb0a6 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -5987,19 +5987,22 @@ bool QUrl::isDetached() const /*! - Returns a QUrl representation of \a localFile, interpreted as a - local file. + Returns a QUrl representation of \a localFile, interpreted as a local + file. This function accepts paths separated by slashes as well as the + native separator for this platform. - \sa toLocalFile() + This function also accepts paths with a doubled leading slash (or + backslash) to indicate a remote file, as in + "//servername/path/to/file.txt". Note that only certain platforms can + actually open this file using QFile::open(). + + \sa toLocalFile(), isLocalFile(), QDir::toNativeSeparators */ QUrl QUrl::fromLocalFile(const QString &localFile) { QUrl url; url.setScheme(QLatin1String("file")); - QString deslashified = localFile; - deslashified.replace(QLatin1Char('\\'), QLatin1Char('/')); - - + QString deslashified = QDir::toNativeSeparators(localFile); // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { @@ -6018,35 +6021,61 @@ QUrl QUrl::fromLocalFile(const QString &localFile) } /*! - Returns the path of this URL formatted as a local file path. + Returns the path of this URL formatted as a local file path. The path + returned will use forward slashes, even if it was originally created + from one with backslashes. - \sa fromLocalFile() + If this URL contains a non-empty hostname, it will be encoded in the + returned value in the form found on SMB networks (for example, + "//servername/path/to/file.txt"). + + \sa fromLocalFile(), isLocalFile() */ QString QUrl::toLocalFile() const { - if (!d) return QString(); - if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); + // the call to isLocalFile() also ensures that we're parsed + if (!isLocalFile()) + return QString(); QString tmp; QString ourPath = path(); - if (d->scheme.isEmpty() || QString::compare(d->scheme, QLatin1String("file"), Qt::CaseInsensitive) == 0) { - // magic for shared drive on windows - if (!d->host.isEmpty()) { - tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/') - ? QLatin1Char('/') + ourPath : ourPath); - } else { - tmp = ourPath; - // magic for drives on windows - if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) - tmp.remove(0, 1); - } + // magic for shared drive on windows + if (!d->host.isEmpty()) { + tmp = QLatin1String("//") + d->host + (ourPath.length() > 0 && ourPath.at(0) != QLatin1Char('/') + ? QLatin1Char('/') + ourPath : ourPath); + } else { + tmp = ourPath; + // magic for drives on windows + if (ourPath.length() > 2 && ourPath.at(0) == QLatin1Char('/') && ourPath.at(2) == QLatin1Char(':')) + tmp.remove(0, 1); } return tmp; } /*! + \since 4.7 + Returns true if this URL is pointing to a local file path. A URL is a + local file path if the scheme is "file". + + Note that this function considers URLs with hostnames to be local file + paths, even if the eventual file path cannot be opened with + QFile::open(). + + \sa fromLocalFile(), toLocalFile() +*/ +bool QUrl::isLocalFile() const +{ + if (!d) return false; + if (!QURL_HASFLAG(d->stateFlags, QUrlPrivate::Parsed)) d->parse(); + + if (d->scheme.compare(QLatin1String("file"), Qt::CaseInsensitive) != 0) + return false; // not file + return true; +} + +/*! Returns true if this URL is a parent of \a childUrl. \a childUrl is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of \a childUrl. diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 6f8331a..162aa7c 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -183,6 +183,7 @@ public: static QUrl fromLocalFile(const QString &localfile); QString toLocalFile() const; + bool isLocalFile() const; QString toString(FormattingOptions options = None) const; diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 820e32d..d055b6b 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -314,6 +314,7 @@ void tst_QUrl::constructing() QUrl buildUNC; + buildUNC.setScheme(QString::fromLatin1("file")); buildUNC.setHost(QString::fromLatin1("somehost")); buildUNC.setPath(QString::fromLatin1("somepath")); QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath")); @@ -1757,7 +1758,15 @@ void tst_QUrl::toLocalFile_data() QTest::newRow("data7") << QString::fromLatin1("file://somehost/") << QString::fromLatin1("//somehost/"); QTest::newRow("data8") << QString::fromLatin1("file://somehost") << QString::fromLatin1("//somehost"); QTest::newRow("data9") << QString::fromLatin1("file:////somehost/somedir/somefile") << QString::fromLatin1("//somehost/somedir/somefile"); - + QTest::newRow("data10") << QString::fromLatin1("FILE:/a.txt") << QString::fromLatin1("/a.txt"); + + // and some that result in empty (i.e., not local) + QTest::newRow("xdata0") << QString::fromLatin1("/a.txt") << QString(); + QTest::newRow("xdata1") << QString::fromLatin1("//a.txt") << QString(); + QTest::newRow("xdata2") << QString::fromLatin1("///a.txt") << QString(); + QTest::newRow("xdata3") << QString::fromLatin1("foo:/a.txt") << QString(); + QTest::newRow("xdata4") << QString::fromLatin1("foo://a.txt") << QString(); + QTest::newRow("xdata5") << QString::fromLatin1("foo:///a.txt") << QString(); } void tst_QUrl::toLocalFile() -- cgit v0.12 From 8ba973977973c4227e98cb0be6ecc53b66aa6e6e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 18:38:20 +0200 Subject: Revert "Revert "[QNAM FTP] Check for the "ftp" scheme case-insensitively"" This reverts commit cc422e939d671bba8d70a5d02abfb893627303cc. --- src/network/access/qnetworkaccessftpbackend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp index 1a59011..da336d0 100644 --- a/src/network/access/qnetworkaccessftpbackend.cpp +++ b/src/network/access/qnetworkaccessftpbackend.cpp @@ -77,7 +77,7 @@ QNetworkAccessFtpBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme() == QLatin1String("ftp")) + if (url.scheme().compare(QLatin1String("ftp"), Qt::CaseInsensitive) == 0) return new QNetworkAccessFtpBackend; return 0; } -- cgit v0.12 From f03dca5834ca9afbaa4a34a374ef30840fc29c9a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 18:38:26 +0200 Subject: Revert "Revert "QUrl::fromLocalFile: fix silly mistake: it's fromNativeSeparators, not to"" This reverts commit 82433177590490e6a69074c2d86adaa7741b4913. --- src/corelib/io/qurl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 15bb0a6..aac1f10 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -6002,7 +6002,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) { QUrl url; url.setScheme(QLatin1String("file")); - QString deslashified = QDir::toNativeSeparators(localFile); + QString deslashified = QDir::fromNativeSeparators(localFile); // magic for drives on windows if (deslashified.length() > 1 && deslashified.at(1) == QLatin1Char(':') && deslashified.at(0) != QLatin1Char('/')) { -- cgit v0.12 From 594b066246713e95bb27af765fdaca46e1d02d0c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 18:38:31 +0200 Subject: Revert "Revert "Use QUrl::isLocalFile and fix the scheme checking in local URLs."" This reverts commit 0828b63ce77846f14994f7c47468f0db8b42fbd4. --- src/network/access/qnetworkaccessfilebackend.cpp | 11 ++++++++--- src/network/access/qnetworkaccessmanager.cpp | 11 +++++------ tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 6 ++++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 4560153..710c258 100644 --- a/src/network/access/qnetworkaccessfilebackend.cpp +++ b/src/network/access/qnetworkaccessfilebackend.cpp @@ -65,10 +65,15 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op, } QUrl url = request.url(); - if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty()) + if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) { return new QNetworkAccessFileBackend; - else if (!url.isEmpty() && url.authority().isEmpty()) { - // check if QFile could, in theory, open this URL + } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) { + // check if QFile could, in theory, open this URL via the file engines + // it has to be in the format: + // prefix:path/to/file + // or prefix:/path/to/file + // + // this construct here must match the one below in open() QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery)); if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists())) return new QNetworkAccessFileBackend; diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 1c7661d..10fdc6f 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -907,21 +907,20 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera { Q_D(QNetworkAccessManager); + bool isLocalFile = req.url().isLocalFile(); + // fast path for GET on file:// URLs - // Also if the scheme is empty we consider it a file. // The QNetworkAccessFileBackend will right now only be used // for PUT or qrc:// if ((op == QNetworkAccessManager::GetOperation || op == QNetworkAccessManager::HeadOperation) - && (req.url().scheme() == QLatin1String("file") - || req.url().scheme().isEmpty())) { + && isLocalFile) { return new QFileNetworkReply(this, req, op); } #ifndef QT_NO_BEARERMANAGEMENT // Return a disabled network reply if network access is disabled. // Except if the scheme is empty or file://. - if (!d->networkAccessible && !(req.url().scheme() == QLatin1String("file") || - req.url().scheme().isEmpty())) { + if (!d->networkAccessible && !isLocalFile) { return new QDisabledNetworkReply(this, req, op); } @@ -963,7 +962,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera QUrl url = request.url(); QNetworkReplyImpl *reply = new QNetworkReplyImpl(this); #ifndef QT_NO_BEARERMANAGEMENT - if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty()) { + if (!isLocalFile) { connect(this, SIGNAL(networkSessionConnected()), reply, SLOT(_q_networkSessionConnected())); } diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 01d7783..5af8034 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1171,6 +1171,12 @@ void tst_QNetworkReply::getErrors_data() QTest::addColumn("httpStatusCode"); QTest::addColumn("dataIsEmpty"); + // empties + QTest::newRow("empty-url") << QString() << int(QNetworkReply::ProtocolUnknownError) << 0 << true; + QTest::newRow("empty-scheme-host") << SRCDIR "/rfc3252.txt" << int(QNetworkReply::ProtocolUnknownError) << 0 << true; + QTest::newRow("empty-scheme") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri" + << int(QNetworkReply::ProtocolUnknownError) << 0 << true; + // file: errors QTest::newRow("file-host") << "file://this-host-doesnt-exist.troll.no/foo.txt" #if !defined Q_OS_WIN -- cgit v0.12 From 1ae65ed7207711dc69bfa11fc184a8c2975eea9f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 14 May 2010 19:04:45 +0200 Subject: Allow QTextDocument to resolve URLs to the current working dir. --- src/gui/text/qtextdocument.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index c7a9756..6132d10 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -1970,6 +1970,8 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name) if (fi.exists()) { resourceUrl = QUrl::fromLocalFile(fi.absolutePath() + QDir::separator()).resolved(name); + } else if (currentURL.isEmpty()) { + resourceUrl.setScheme(QLatin1String("file")); } } -- cgit v0.12 From c82f61090b72b1eb819b5261105da069d98da557 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 21 May 2010 08:41:06 +0200 Subject: Mac: add missing header file --- src/gui/kernel/qcocoaintrospection_p.h | 84 ++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/gui/kernel/qcocoaintrospection_p.h diff --git a/src/gui/kernel/qcocoaintrospection_p.h b/src/gui/kernel/qcocoaintrospection_p.h new file mode 100644 index 0000000..b9422e8 --- /dev/null +++ b/src/gui/kernel/qcocoaintrospection_p.h @@ -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 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$ +** +****************************************************************************/ + +/**************************************************************************** +** +** Copyright (c) 2007-2008, Apple, Inc. +** +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** +** * Neither the name of Apple, Inc. nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#include +#import + +QT_BEGIN_NAMESPACE + +void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel = 0, SEL backupSel = 0); +void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel); + +QT_END_NAMESPACE -- cgit v0.12 From 24a9f3cbd499a161b99d975ee379d64e920e0449 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 21 May 2010 08:44:43 +0200 Subject: Mac: add missing .mm file --- src/gui/kernel/qcocoaintrospection_mac.mm | 125 ++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/gui/kernel/qcocoaintrospection_mac.mm diff --git a/src/gui/kernel/qcocoaintrospection_mac.mm b/src/gui/kernel/qcocoaintrospection_mac.mm new file mode 100644 index 0000000..9b536b7 --- /dev/null +++ b/src/gui/kernel/qcocoaintrospection_mac.mm @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/**************************************************************************** +** +** Copyright (c) 2007-2008, Apple, Inc. +** +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** +** * Neither the name of Apple, Inc. nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +** PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +** LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +** NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************/ + +#include + +QT_BEGIN_NAMESPACE + +void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel) +{ +#ifndef QT_MAC_USE_COCOA + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) +#endif + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + // The following code replaces the _implementation_ for the selector we want to hack + // (originalSel) with the implementation found in proxyClass. Then it creates + // a new 'backup' method inside baseClass containing the old, original, + // implementation (fakeSel). You can let the proxy implementation of originalSel + // call fakeSel if needed (similar approach to calling a super class implementation). + // fakeSel must also be implemented in proxyClass, as the signature is used + // as template for the method one we add into baseClass. + // NB: You will typically never create any instances of proxyClass; we use it + // only for stealing its contents and put it into baseClass. + if (!replacementSel) + replacementSel = originalSel; + + Method originalMethod = class_getInstanceMethod(baseClass, originalSel); + Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel); + IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod)); + + if (backupSel) { + Method backupMethod = class_getInstanceMethod(proxyClass, backupSel); + class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod)); + } +#endif + } +} + +void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel) +{ +#ifndef QT_MAC_USE_COCOA + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) +#endif + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + Method originalMethod = class_getInstanceMethod(baseClass, originalSel); + Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel); + method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass)); +#endif + } +} + +QT_END_NAMESPACE -- cgit v0.12 From f1dc8ed5d852a02dcacafb79195d8ca17d4a20ea Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 21 May 2010 13:28:38 +0200 Subject: QComboBox: Fix documentation and make auto-test pass. Reviewed-by: Olivier --- src/gui/widgets/qcombobox.cpp | 2 +- tests/auto/qcombobox/tst_qcombobox.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 1504066..6cf24a6 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -1293,7 +1293,7 @@ QComboBox::~QComboBox() By default, this property has a value of 10. \note This property is ignored for non-editable comboboxes in styles that returns - false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. + true for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. */ int QComboBox::maxVisibleItems() const { diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 1fcea9e..aa821c2 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2553,9 +2553,11 @@ void tst_QComboBox::maxVisibleItems() QAbstractItemView *v = comboBox.view(); int itemHeight = v->visualRect(v->model()->index(0,0)).height(); - if (v->style()->styleHint(QStyle::SH_ComboBox_Popup)) + QListView *lv = qobject_cast(v); + if (lv) + itemHeight += lv->spacing(); + if (!v->style()->styleHint(QStyle::SH_ComboBox_Popup)) QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); - // QCombobox without a popup does not work, see QTBUG-760 } -- cgit v0.12 From f65a036ff7c4023a0603d2887b29bfe7e182034a Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 21 May 2010 15:41:37 +0200 Subject: Mac: fix bic breakage --- src/gui/kernel/qapplication.h | 1 - src/gui/kernel/qapplication_mac.mm | 35 ++++++++++----------------------- src/gui/kernel/qcocoaapplication_mac.mm | 2 +- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index ebb329b..c21b982 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -233,7 +233,6 @@ public: #if defined(Q_WS_MAC) virtual bool macEventFilter(EventHandlerCallRef, EventRef); - virtual bool macEventFilter(void *); #endif #if defined(Q_WS_X11) virtual bool x11EventFilter(XEvent *); diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index 4cd14df..afd7c4b 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -2613,43 +2613,28 @@ OSStatus QApplicationPrivate::globalAppleEventProcessor(const AppleEvent *ae, Ap /*! \fn bool QApplication::macEventFilter(EventHandlerCallRef caller, EventRef event) - \warning This virtual function is only used under Mac OS X when Qt is based on Carbon. + \warning This virtual function is only used under Mac OS X, and behaves different + depending on if Qt is based on Carbon or Cocoa. - If you create an application that inherits QApplication and reimplement + For the Carbon port, If you create an application that inherits QApplication and reimplement this function, you get direct access to all Carbon Events that Qt registers for from Mac OS X with this function being called with the \a caller and the \a event. - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. - - \sa macEventFilter(void *nsevent) -*/ -bool QApplication::macEventFilter(EventHandlerCallRef, EventRef) -{ - return false; -} - -/*! - \fn bool QApplication::macEventFilter(void *nsevent) + For the Cocoa port, If you create an application that inherits QApplication and reimplement + this function, you get direct access to all Cocoa Events that Qt receives + from Mac OS X with this function being called with the \a caller being 0 and + the \a event being an NSEvent pointer: - \warning This virtual function is only used under Mac OS X when Qt is based on Cocoa. - - If you create an application that inherits QApplication and reimplement - this function, you get direct access to all NSEvents that Qt receives - from Cocoa. - \a nsevent is of type NSEvent *: - - NSEvent *e = static_cast(nsevent); + NSEvent *e = reinterpret_cast(event); Return true if you want to stop the event from being processed. Return false for normal event dispatching. The default implementation returns false. - \sa macEventFilter(EventHandlerCallRef caller, EventRef event) + \sa macEventFilter(void *nsevent) */ -bool QApplication::macEventFilter(void * /*NSEvent*/) +bool QApplication::macEventFilter(EventHandlerCallRef, EventRef) { return false; } diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm index 5cd32a1..238b96b 100644 --- a/src/gui/kernel/qcocoaapplication_mac.mm +++ b/src/gui/kernel/qcocoaapplication_mac.mm @@ -134,7 +134,7 @@ QT_USE_NAMESPACE - (BOOL)qt_filterEvent:(NSEvent *)event { - if (qApp->macEventFilter(event)) + if (qApp->macEventFilter(0, reinterpret_cast(event))) return true; if ([event type] == NSApplicationDefined) { -- cgit v0.12 From c9607f069f0fb98021daf0af9f1d1b2981018e0c Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 19 May 2010 07:18:27 +0200 Subject: Use binarysort to find items. Task: http://bugreports.qt.nokia.com/browse/QTBUG-231 Reviwed-by: Eskil --- src/gui/text/qtextengine.cpp | 19 ++++++++++++------- src/gui/text/qtextlayout.cpp | 24 +++++++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d34553f..dc099fc 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1518,14 +1518,19 @@ void QTextEngine::itemize() const int QTextEngine::findItem(int strPos) const { itemize(); - - // ##### use binary search - int item; - for (item = layoutData->items.size()-1; item > 0; --item) { - if (layoutData->items[item].position <= strPos) - break; + int left = 0; + int right = layoutData->items.size()-1; + while(left <= right) { + int middle = ((right-left)/2)+left; + if (strPos > layoutData->items[middle].position) + left = middle+1; + else if(strPos < layoutData->items[middle].position) + right = middle-1; + else { + return middle; + } } - return item; + return right; } QFixed QTextEngine::width(int from, int len) const diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index ce7915d..94d9d67 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1208,7 +1208,7 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorlayoutData->items.size()-1; newItem > 0; --newItem) { - if (eng->layoutData->items[newItem].position <= line.from) + int newItem = -1; + int left = 0; + int right = eng->layoutData->items.size()-1; + while(left <= right) { + int middle = ((right-left)/2)+left; + if (line.from > eng->layoutData->items[middle].position) + left = middle+1; + else if(line.from < eng->layoutData->items[middle].position) + right = middle-1; + else { + newItem = middle; break; + } } + if (newItem == -1) + newItem = right; LB_DEBUG("from: %d: item=%d, total %d, width available %f", line.from, newItem, eng->layoutData->items.size(), line.width.toReal()); @@ -1939,7 +1949,7 @@ void QTextLine::layout_helper(int maxGlyphs) } LB_DEBUG("reached end of line"); lbh.checkFullOtherwiseExtend(line); -found: +found: if (lbh.rightBearing > 0) // If right bearing has not yet been adjusted lbh.adjustRightBearing(); line.textAdvance = line.textWidth; -- cgit v0.12 From 2e0ac76a76f02e22f101b24ba222f8251d0c2580 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 25 May 2010 14:20:31 +0200 Subject: Fix tst_QComboBox::maxVisibleItems() auto-test on Mac Reviewed-by: Olivier --- tests/auto/qcombobox/tst_qcombobox.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index aa821c2..fb6c741 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -2556,7 +2556,9 @@ void tst_QComboBox::maxVisibleItems() QListView *lv = qobject_cast(v); if (lv) itemHeight += lv->spacing(); - if (!v->style()->styleHint(QStyle::SH_ComboBox_Popup)) + QStyleOptionComboBox opt; + opt.initFrom(&comboBox); + if (!comboBox.style()->styleHint(QStyle::SH_ComboBox_Popup, &opt)) QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); } -- cgit v0.12 From 00edad4373d394ed9f828b1fa887003f87c5fa6f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 25 May 2010 20:09:00 +0200 Subject: QComboBox::modelColumn was not respected when selecting an item Auto-test included Reviewed-by: Olivier Task-number: QTBUG-10491 --- src/gui/widgets/qcombobox.cpp | 13 ++++++++++--- src/gui/widgets/qcombobox_p.h | 2 +- tests/auto/qcombobox/tst_qcombobox.cpp | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 6cf24a6..213ca95 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -2003,11 +2003,18 @@ void QComboBox::setCurrentIndex(int index) void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) { Q_Q(QComboBox); - bool indexChanged = (mi != currentIndex); + + QModelIndex normalized; + if (mi.column() != modelColumn) + normalized = model->index(mi.row(), modelColumn, mi.parent()); + if (!normalized.isValid()) + normalized = mi; // Fallback to passed index. + + bool indexChanged = (normalized != currentIndex); if (indexChanged) - currentIndex = QPersistentModelIndex(mi); + currentIndex = QPersistentModelIndex(normalized); if (lineEdit) { - QString newText = q->itemText(currentIndex.row()); + QString newText = q->itemText(normalized.row()); if (lineEdit->text() != newText) lineEdit->setText(newText); updateLineEditGeometry(); diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h index 29a628c..c0727ed 100644 --- a/src/gui/widgets/qcombobox_p.h +++ b/src/gui/widgets/qcombobox_p.h @@ -337,7 +337,7 @@ private: QComboBox *mCombo; }; -class QComboBoxPrivate : public QWidgetPrivate +class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate { Q_DECLARE_PUBLIC(QComboBox) public: diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index fb6c741..f00f3ef 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -157,6 +157,7 @@ private slots: void keyBoardNavigationWithMouse(); void task_QTBUG_1071_changingFocusEmitsActivated(); void maxVisibleItems(); + void task_QTBUG_10491_currentIndexAndModelColumn(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2562,6 +2563,24 @@ void tst_QComboBox::maxVisibleItems() QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems()); } +void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn() +{ + QComboBox comboBox; + + QStandardItemModel model(4, 4, &comboBox); + for (int i = 0; i < 4; i++){ + model.setItem(i, 0, new QStandardItem(QString("Employee Nr %1").arg(i))); + model.setItem(i, 1, new QStandardItem(QString("Street Nr %1").arg(i))); + model.setItem(i, 2, new QStandardItem(QString("Town Nr %1").arg(i))); + model.setItem(i, 3, new QStandardItem(QString("Phone Nr %1").arg(i))); + } + comboBox.setModel(&model); + comboBox.setModelColumn(0); + + QComboBoxPrivate *d = static_cast(QComboBoxPrivate::get(&comboBox)); + d->setCurrentIndex(model.index(2, 2)); + QCOMPARE(QModelIndex(d->currentIndex), model.index(2, comboBox.modelColumn())); +} QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" -- cgit v0.12 From 0218fb14f3f05df746d7730f45a6137b33029dad Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Wed, 26 May 2010 10:35:52 +0200 Subject: Add support of high unicodes in QUrl. Fix some typos in the test data (all 3 typos are already fixed in the original testsuite). Add incorrect utf-8 data (sub)test from nameprep testsuite. Reviewed-by: Andreas Merge-Request: 605 Merge-request: 605 Reviewed-by: Andreas Aardal Hanssen --- src/corelib/io/qurl.cpp | 287 +++++++++++++++++++++++++------------------ tests/auto/qurl/tst_qurl.cpp | 64 ++++++++-- tests/auto/utf8/tst_utf8.cpp | 4 +- 3 files changed, 222 insertions(+), 133 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index aac1f10..20ec995 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -966,14 +966,14 @@ static void QT_FASTCALL _fragment(const char **ptr, QUrlParseData *parseData) } struct NameprepCaseFoldingEntry { - int uc; + uint uc; ushort mapping[4]; }; -inline bool operator<(int one, const NameprepCaseFoldingEntry &other) +inline bool operator<(uint one, const NameprepCaseFoldingEntry &other) { return one < other.uc; } -inline bool operator<(const NameprepCaseFoldingEntry &one, int other) +inline bool operator<(const NameprepCaseFoldingEntry &one, uint other) { return one.uc < other; } static const NameprepCaseFoldingEntry NameprepCaseFolding[] = { @@ -1862,45 +1862,44 @@ static const NameprepCaseFoldingEntry NameprepCaseFolding[] = { { 0xFF38, { 0xFF58, 0x0000, 0x0000, 0x0000 } }, { 0xFF39, { 0xFF59, 0x0000, 0x0000, 0x0000 } }, { 0xFF3A, { 0xFF5A, 0x0000, 0x0000, 0x0000 } }, - // ##### -/* { 0x10400, { 0x10428, 0x0000, 0x0000, 0x0000 } }, - { 0x10401, { 0x10429, 0x0000, 0x0000, 0x0000 } }, - { 0x10402, { 0x1042A, 0x0000, 0x0000, 0x0000 } }, - { 0x10403, { 0x1042B, 0x0000, 0x0000, 0x0000 } }, - { 0x10404, { 0x1042C, 0x0000, 0x0000, 0x0000 } }, - { 0x10405, { 0x1042D, 0x0000, 0x0000, 0x0000 } }, - { 0x10406, { 0x1042E, 0x0000, 0x0000, 0x0000 } }, - { 0x10407, { 0x1042F, 0x0000, 0x0000, 0x0000 } }, - { 0x10408, { 0x10430, 0x0000, 0x0000, 0x0000 } }, - { 0x10409, { 0x10431, 0x0000, 0x0000, 0x0000 } }, - { 0x1040A, { 0x10432, 0x0000, 0x0000, 0x0000 } }, - { 0x1040B, { 0x10433, 0x0000, 0x0000, 0x0000 } }, - { 0x1040C, { 0x10434, 0x0000, 0x0000, 0x0000 } }, - { 0x1040D, { 0x10435, 0x0000, 0x0000, 0x0000 } }, - { 0x1040E, { 0x10436, 0x0000, 0x0000, 0x0000 } }, - { 0x1040F, { 0x10437, 0x0000, 0x0000, 0x0000 } }, - { 0x10410, { 0x10438, 0x0000, 0x0000, 0x0000 } }, - { 0x10411, { 0x10439, 0x0000, 0x0000, 0x0000 } }, - { 0x10412, { 0x1043A, 0x0000, 0x0000, 0x0000 } }, - { 0x10413, { 0x1043B, 0x0000, 0x0000, 0x0000 } }, - { 0x10414, { 0x1043C, 0x0000, 0x0000, 0x0000 } }, - { 0x10415, { 0x1043D, 0x0000, 0x0000, 0x0000 } }, - { 0x10416, { 0x1043E, 0x0000, 0x0000, 0x0000 } }, - { 0x10417, { 0x1043F, 0x0000, 0x0000, 0x0000 } }, - { 0x10418, { 0x10440, 0x0000, 0x0000, 0x0000 } }, - { 0x10419, { 0x10441, 0x0000, 0x0000, 0x0000 } }, - { 0x1041A, { 0x10442, 0x0000, 0x0000, 0x0000 } }, - { 0x1041B, { 0x10443, 0x0000, 0x0000, 0x0000 } }, - { 0x1041C, { 0x10444, 0x0000, 0x0000, 0x0000 } }, - { 0x1041D, { 0x10445, 0x0000, 0x0000, 0x0000 } }, - { 0x1041E, { 0x10446, 0x0000, 0x0000, 0x0000 } }, - { 0x1041F, { 0x10447, 0x0000, 0x0000, 0x0000 } }, - { 0x10420, { 0x10448, 0x0000, 0x0000, 0x0000 } }, - { 0x10421, { 0x10449, 0x0000, 0x0000, 0x0000 } }, - { 0x10422, { 0x1044A, 0x0000, 0x0000, 0x0000 } }, - { 0x10423, { 0x1044B, 0x0000, 0x0000, 0x0000 } }, - { 0x10424, { 0x1044C, 0x0000, 0x0000, 0x0000 } }, - { 0x10425, { 0x1044D, 0x0000, 0x0000, 0x0000 } },*/ + { 0x10400, { 0xd801, 0xdc28, 0x0000, 0x0000 } }, + { 0x10401, { 0xd801, 0xdc29, 0x0000, 0x0000 } }, + { 0x10402, { 0xd801, 0xdc2A, 0x0000, 0x0000 } }, + { 0x10403, { 0xd801, 0xdc2B, 0x0000, 0x0000 } }, + { 0x10404, { 0xd801, 0xdc2C, 0x0000, 0x0000 } }, + { 0x10405, { 0xd801, 0xdc2D, 0x0000, 0x0000 } }, + { 0x10406, { 0xd801, 0xdc2E, 0x0000, 0x0000 } }, + { 0x10407, { 0xd801, 0xdc2F, 0x0000, 0x0000 } }, + { 0x10408, { 0xd801, 0xdc30, 0x0000, 0x0000 } }, + { 0x10409, { 0xd801, 0xdc31, 0x0000, 0x0000 } }, + { 0x1040A, { 0xd801, 0xdc32, 0x0000, 0x0000 } }, + { 0x1040B, { 0xd801, 0xdc33, 0x0000, 0x0000 } }, + { 0x1040C, { 0xd801, 0xdc34, 0x0000, 0x0000 } }, + { 0x1040D, { 0xd801, 0xdc35, 0x0000, 0x0000 } }, + { 0x1040E, { 0xd801, 0xdc36, 0x0000, 0x0000 } }, + { 0x1040F, { 0xd801, 0xdc37, 0x0000, 0x0000 } }, + { 0x10410, { 0xd801, 0xdc38, 0x0000, 0x0000 } }, + { 0x10411, { 0xd801, 0xdc39, 0x0000, 0x0000 } }, + { 0x10412, { 0xd801, 0xdc3A, 0x0000, 0x0000 } }, + { 0x10413, { 0xd801, 0xdc3B, 0x0000, 0x0000 } }, + { 0x10414, { 0xd801, 0xdc3C, 0x0000, 0x0000 } }, + { 0x10415, { 0xd801, 0xdc3D, 0x0000, 0x0000 } }, + { 0x10416, { 0xd801, 0xdc3E, 0x0000, 0x0000 } }, + { 0x10417, { 0xd801, 0xdc3F, 0x0000, 0x0000 } }, + { 0x10418, { 0xd801, 0xdc40, 0x0000, 0x0000 } }, + { 0x10419, { 0xd801, 0xdc41, 0x0000, 0x0000 } }, + { 0x1041A, { 0xd801, 0xdc42, 0x0000, 0x0000 } }, + { 0x1041B, { 0xd801, 0xdc43, 0x0000, 0x0000 } }, + { 0x1041C, { 0xd801, 0xdc44, 0x0000, 0x0000 } }, + { 0x1041D, { 0xd801, 0xdc45, 0x0000, 0x0000 } }, + { 0x1041E, { 0xd801, 0xdc46, 0x0000, 0x0000 } }, + { 0x1041F, { 0xd801, 0xdc47, 0x0000, 0x0000 } }, + { 0x10420, { 0xd801, 0xdc48, 0x0000, 0x0000 } }, + { 0x10421, { 0xd801, 0xdc49, 0x0000, 0x0000 } }, + { 0x10422, { 0xd801, 0xdc4A, 0x0000, 0x0000 } }, + { 0x10423, { 0xd801, 0xdc4B, 0x0000, 0x0000 } }, + { 0x10424, { 0xd801, 0xdc4C, 0x0000, 0x0000 } }, + { 0x10425, { 0xd801, 0xdc4D, 0x0000, 0x0000 } }, { 0x1D400, { 0x0061, 0x0000, 0x0000, 0x0000 } }, { 0x1D401, { 0x0062, 0x0000, 0x0000, 0x0000 } }, { 0x1D402, { 0x0063, 0x0000, 0x0000, 0x0000 } }, @@ -2355,17 +2354,23 @@ static void mapToLowerCase(QString *str, int from) { int N = sizeof(NameprepCaseFolding) / sizeof(NameprepCaseFolding[0]); - QChar *d = 0; + ushort *d = 0; for (int i = from; i < str->size(); ++i) { - int uc = str->at(i).unicode(); + uint uc = str->at(i).unicode(); if (uc < 0x80) { if (uc <= 'Z' && uc >= 'A') { - uc |= 0x20; if (!d) - d = str->data(); - d[i] = QChar(uc); + d = reinterpret_cast(str->data()); + d[i] = (uc | 0x20); } } else { + if (QChar(uc).isHighSurrogate() && i < str->size() - 1) { + ushort low = str->at(i + 1).unicode(); + if (QChar(low).isLowSurrogate()) { + uc = QChar::surrogateToUcs4(uc, low); + ++i; + } + } const NameprepCaseFoldingEntry *entry = qBinaryFind(NameprepCaseFolding, NameprepCaseFolding + N, uc); @@ -2374,23 +2379,26 @@ static void mapToLowerCase(QString *str, int from) while (l < 4 && entry->mapping[l]) ++l; if (l > 1) { - str->replace(i, 1, (const QChar *)&entry->mapping[0], l); + if (uc <= 0xffff) + str->replace(i, 1, reinterpret_cast(&entry->mapping[0]), l); + else + str->replace(i-1, 2, reinterpret_cast(&entry->mapping[0]), l); d = 0; } else { if (!d) - d = str->data(); - d[i] = QChar(entry->mapping[0]); + d = reinterpret_cast(str->data()); + d[i] = entry->mapping[0]; } } } } } -static bool isMappedToNothing(const QChar &ch) +static bool isMappedToNothing(uint uc) { - if (ch.unicode() < 0xad) + if (uc < 0xad) return false; - switch (ch.unicode()) { + switch (uc) { case 0x00AD: case 0x034F: case 0x1806: case 0x180B: case 0x180C: case 0x180D: case 0x200B: case 0x200C: case 0x200D: case 0x2060: case 0xFE00: case 0xFE01: case 0xFE02: case 0xFE03: case 0xFE04: case 0xFE05: case 0xFE06: case 0xFE07: @@ -2409,66 +2417,72 @@ static void stripProhibitedOutput(QString *str, int from) const ushort *in = out; const ushort *end = (ushort *)str->data() + str->size(); while (in < end) { - ushort uc = *in; - if (uc < 0x80 || - !(uc <= 0x009F - || uc == 0x00A0 - || uc == 0x0340 - || uc == 0x0341 - || uc == 0x06DD - || uc == 0x070F - || uc == 0x1680 - || uc == 0x180E - || (uc >= 0x2000 && uc <= 0x200B) - || uc == 0x200C - || uc == 0x200D - || uc == 0x200E - || uc == 0x200F - || (uc >= 0x2028 && uc <= 0x202F) - || uc == 0x205F - || (uc >= 0x2060 && uc <= 0x2063) - || uc == 0x206A - || (uc >= 0x206A && uc <= 0x206F) - || (uc >= 0x2FF0 && uc <= 0x2FFB) - || uc == 0x3000 - || (uc >= 0xD800 && uc <= 0xDFFF) - || (uc >= 0xE000 && uc <= 0xF8FF) - || (uc >= 0xFDD0 && uc <= 0xFDEF) - || uc == 0xFEFF - || (uc >= 0xFFF9 && uc <= 0xFFFC) - || (uc >= 0xFFFA && (uc <= 0xFFFE || uc == 0xFFFF)) - /* ### Add NAMEPREP support for surrogates - || uc == 0xE0001 - || (uc >= 0x2FFFE && uc <= 0x2FFFF) - || (uc >= 0x1D173 && uc <= 0x1D17A) - || (uc >= 0x1FFFE && uc <= 0x1FFFF) - || (uc >= 0x3FFFE && uc <= 0x3FFFF) - || (uc >= 0x4FFFE && uc <= 0x4FFFF) - || (uc >= 0x5FFFE && uc <= 0x5FFFF) - || (uc >= 0x6FFFE && uc <= 0x6FFFF) - || (uc >= 0x7FFFE && uc <= 0x7FFFF) - || (uc >= 0x8FFFE && uc <= 0x8FFFF) - || (uc >= 0x9FFFE && uc <= 0x9FFFF) - || (uc >= 0xAFFFE && uc <= 0xAFFFF) - || (uc >= 0xBFFFE && uc <= 0xBFFFF) - || (uc >= 0xCFFFE && uc <= 0xCFFFF) - || (uc >= 0xDFFFE && uc <= 0xDFFFF) - || (uc >= 0xE0020 && uc <= 0xE007F) - || (uc >= 0xEFFFE && uc <= 0xEFFFF) - || (uc >= 0xF0000 && uc <= 0xFFFFD) - || (uc >= 0xFFFFE && uc <= 0xFFFFF) - || (uc >= 0x100000 && uc <= 0x10FFFD) - || (uc >= 0x10FFFE && uc <= 0x10FFFF)*/)) - *out++ = *in; + uint uc = *in; + if (QChar(uc).isHighSurrogate() && in < end - 1) { + ushort low = *(in + 1); + if (QChar(low).isLowSurrogate()) { + ++in; + uc = QChar::surrogateToUcs4(uc, low); + } + } + if (uc <= 0xFFFF) { + if (uc < 0x80 || + !(uc <= 0x009F + || uc == 0x00A0 + || uc == 0x0340 + || uc == 0x0341 + || uc == 0x06DD + || uc == 0x070F + || uc == 0x1680 + || uc == 0x180E + || (uc >= 0x2000 && uc <= 0x200F) + || (uc >= 0x2028 && uc <= 0x202F) + || uc == 0x205F + || (uc >= 0x2060 && uc <= 0x2063) + || (uc >= 0x206A && uc <= 0x206F) + || (uc >= 0x2FF0 && uc <= 0x2FFB) + || uc == 0x3000 + || (uc >= 0xD800 && uc <= 0xDFFF) + || (uc >= 0xE000 && uc <= 0xF8FF) + || (uc >= 0xFDD0 && uc <= 0xFDEF) + || uc == 0xFEFF + || (uc >= 0xFFF9 && uc <= 0xFFFF))) { + *out++ = *in; + } + } else { + if (!((uc >= 0x1D173 && uc <= 0x1D17A) + || (uc >= 0x1FFFE && uc <= 0x1FFFF) + || (uc >= 0x2FFFE && uc <= 0x2FFFF) + || (uc >= 0x3FFFE && uc <= 0x3FFFF) + || (uc >= 0x4FFFE && uc <= 0x4FFFF) + || (uc >= 0x5FFFE && uc <= 0x5FFFF) + || (uc >= 0x6FFFE && uc <= 0x6FFFF) + || (uc >= 0x7FFFE && uc <= 0x7FFFF) + || (uc >= 0x8FFFE && uc <= 0x8FFFF) + || (uc >= 0x9FFFE && uc <= 0x9FFFF) + || (uc >= 0xAFFFE && uc <= 0xAFFFF) + || (uc >= 0xBFFFE && uc <= 0xBFFFF) + || (uc >= 0xCFFFE && uc <= 0xCFFFF) + || (uc >= 0xDFFFE && uc <= 0xDFFFF) + || uc == 0xE0001 + || (uc >= 0xE0020 && uc <= 0xE007F) + || (uc >= 0xEFFFE && uc <= 0xEFFFF) + || (uc >= 0xF0000 && uc <= 0xFFFFD) + || (uc >= 0xFFFFE && uc <= 0xFFFFF) + || (uc >= 0x100000 && uc <= 0x10FFFD) + || (uc >= 0x10FFFE && uc <= 0x10FFFF))) { + *out++ = QChar::highSurrogate(uc); + *out++ = QChar::lowSurrogate(uc); + } + } ++in; } if (in != out) str->truncate(out - str->utf16()); } -static bool isBidirectionalRorAL(const QChar &c) +static bool isBidirectionalRorAL(uint uc) { - ushort uc = c.unicode(); if (uc < 0x5b0) return false; return uc == 0x05BE @@ -2507,9 +2521,8 @@ static bool isBidirectionalRorAL(const QChar &c) || (uc >= 0xFE76 && uc <= 0xFEFC); } -static bool isBidirectionalL(const QChar &ch) +static bool isBidirectionalL(uint uc) { - ushort uc = ch.unicode(); if (uc < 0xaa) return (uc >= 0x0041 && uc <= 0x005A) || (uc >= 0x0061 && uc <= 0x007A); @@ -2874,8 +2887,7 @@ static bool isBidirectionalL(const QChar &ch) return true; } - /* ### Add NAMEPREP support for surrogates - || (uc >= 0x10300 && uc <= 0x1031E) + if ((uc >= 0x10300 && uc <= 0x1031E) || (uc >= 0x10320 && uc <= 0x10323) || (uc >= 0x10330 && uc <= 0x1034A) || (uc >= 0x10400 && uc <= 0x10425) @@ -2911,7 +2923,9 @@ static bool isBidirectionalL(const QChar &ch) || (uc >= 0x20000 && uc <= 0x2A6D6) || (uc >= 0x2F800 && uc <= 0x2FA1D) || (uc >= 0xF0000 && uc <= 0xFFFFD) - || (uc >= 0x100000 && uc <= 0x10FFFD)*/ + || (uc >= 0x100000 && uc <= 0x10FFFD)) { + return true; + } return false; } @@ -2944,13 +2958,37 @@ void qt_nameprep(QString *source, int from) return; // everything was mapped easily (lowercased, actually) int firstNonAscii = out - src; + // Characters unassigned in Unicode 3.2 are not allowed in "stored string" scheme + // but allowed in "query" scheme + // (Table A.1) + const bool isUnassignedAllowed = false; // ### // Characters commonly mapped to nothing are simply removed // (Table B.1) const QChar *in = out; - while (in < e) { - if (!isMappedToNothing(*in)) - *out++ = *in; - ++in; + for ( ; in < e; ++in) { + uint uc = in->unicode(); + if (QChar(uc).isHighSurrogate() && in < e - 1) { + ushort low = in[1].unicode(); + if (QChar(low).isLowSurrogate()) { + ++in; + uc = QChar::surrogateToUcs4(uc, low); + } + } + if (!isUnassignedAllowed) { + QChar::UnicodeVersion version = QChar::unicodeVersion(uc); + if (version == QChar::Unicode_Unassigned || version > QChar::Unicode_3_2) { + source->resize(from); // not allowed, clear the label + return; + } + } + if (!isMappedToNothing(uc)) { + if (uc <= 0xFFFF) { + *out++ = *in; + } else { + *out++ = QChar::highSurrogate(uc); + *out++ = QChar::lowSurrogate(uc); + } + } } if (out != in) source->truncate(out - src); @@ -2961,7 +2999,8 @@ void qt_nameprep(QString *source, int from) // Normalize to Unicode 3.2 form KC extern void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::UnicodeVersion version, int from); - qt_string_normalize(source, QString::NormalizationForm_KC, QChar::Unicode_3_2, firstNonAscii); + qt_string_normalize(source, QString::NormalizationForm_KC, QChar::Unicode_3_2, + firstNonAscii > from ? firstNonAscii - 1 : from); // Strip prohibited output stripProhibitedOutput(source, firstNonAscii); @@ -2972,14 +3011,22 @@ void qt_nameprep(QString *source, int from) src = source->data(); e = src + source->size(); for (in = src + from; in < e && (!containsLCat || !containsRandALCat); ++in) { - if (isBidirectionalL(*in)) + uint uc = in->unicode(); + if (QChar(uc).isHighSurrogate() && in < e - 1) { + ushort low = in[1].unicode(); + if (QChar(low).isLowSurrogate()) { + ++in; + uc = QChar::surrogateToUcs4(uc, low); + } + } + if (isBidirectionalL(uc)) containsLCat = true; - else if (isBidirectionalRorAL(*in)) + else if (isBidirectionalRorAL(uc)) containsRandALCat = true; } if (containsRandALCat) { - if (containsLCat || (!isBidirectionalRorAL(src[from]) - || !isBidirectionalRorAL(e[-1]))) + if (containsLCat || (!isBidirectionalRorAL(src[from].unicode()) + || !isBidirectionalRorAL(e[-1].unicode()))) source->resize(from); // not allowed, clear the label } } diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index d055b6b..b2b28bd 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -161,6 +161,8 @@ private slots: void idna_testsuite(); void nameprep_testsuite_data(); void nameprep_testsuite(); + void nameprep_highcodes_data(); + void nameprep_highcodes(); void ace_testsuite_data(); void ace_testsuite(); void std3violations_data(); @@ -2912,7 +2914,6 @@ void tst_QUrl::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Case folding 8bit U+00DF (german sharp s)") -// << QString::fromUtf8("\xC3\xDF") ### typo in the original testsuite << QString::fromUtf8("\xC3\x9F") << QString("ss") << QString() << 0 << 0; @@ -2943,7 +2944,8 @@ void tst_QUrl::nameprep_testsuite_data() << QString() << 0 << 0; QTest::newRow("Self-reverting case folding U+01F0 and normalization") - << QString::fromUtf8("\xC7\xF0") +// << QString::fromUtf8("\xC7\xF0") ### typo in the original testsuite + << QString::fromUtf8("\xC7\xB0") << QString::fromUtf8("\xC7\xB0") << QString() << 0 << 0; @@ -3118,13 +3120,13 @@ void tst_QUrl::nameprep_testsuite_data() << QString("Nameprep") << STRINGPREP_NO_UNASSIGNED << STRINGPREP_CONTAINS_UNASSIGNED; QTest::newRow("Larger test (shrinking)") - << QString::fromUtf8("X\xC2\xAD\xC3\xDF\xC4\xB0\xE2\x84\xA1\x6a\xcc\x8c\xc2\xa0\xc2" + << QString::fromUtf8("X\xC2\xAD\xC3\x9F\xC4\xB0\xE2\x84\xA1\x6a\xcc\x8c\xc2\xa0\xc2" "\xaa\xce\xb0\xe2\x80\x80") << QString::fromUtf8("xssi\xcc\x87""tel\xc7\xb0 a\xce\xb0 ") << QString("Nameprep") << 0 << 0; QTest::newRow("Larger test (expanding)") - << QString::fromUtf8("X\xC3\xDF\xe3\x8c\x96\xC4\xB0\xE2\x84\xA1\xE2\x92\x9F\xE3\x8c\x80") + << QString::fromUtf8("X\xC3\x9F\xe3\x8c\x96\xC4\xB0\xE2\x84\xA1\xE2\x92\x9F\xE3\x8c\x80") << QString::fromUtf8("xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3\x83\x88" "\xe3\x83\xab""i\xcc\x87""tel\x28""d\x29\xe3\x82\xa2\xe3\x83\x91" "\xe3\x83\xbc\xe3\x83\x88") @@ -3145,20 +3147,58 @@ void tst_QUrl::nameprep_testsuite() QFETCH(QString, out); QFETCH(QString, profile); - QEXPECT_FAIL("Case folding U+2121 U+33C6 U+1D7BB", - ">0xffff unicode points are not supported", Continue); - QEXPECT_FAIL("Self-reverting case folding U+01F0 and normalization", - "Investigate further", Continue); QEXPECT_FAIL("Left-to-right mark U+200E", "Investigate further", Continue); QEXPECT_FAIL("Deprecated U+202A", "Investigate further", Continue); QEXPECT_FAIL("Language tagging character U+E0001", "Investigate further", Continue); - QEXPECT_FAIL("Larger test (shrinking)", - "Investigate further", Continue); - QEXPECT_FAIL("Larger test (expanding)", - "Investigate further", Continue); + qt_nameprep(&in, 0); + QCOMPARE(in, out); +#endif +} + +void tst_QUrl::nameprep_highcodes_data() +{ + QTest::addColumn("in"); + QTest::addColumn("out"); + QTest::addColumn("profile"); + QTest::addColumn("flags"); + QTest::addColumn("rc"); + + { + QChar st[] = { '-', 0xd801, 0xdc1d, 'a' }; + QChar se[] = { '-', 0xd801, 0xdc45, 'a' }; + QTest::newRow("highcodes (U+1041D)") + << QString(st, sizeof(st)/sizeof(st[0])) + << QString(se, sizeof(se)/sizeof(se[0])) + << QString() << 0 << 0; + } + { + QChar st[] = { 0x011C, 0xd835, 0xdf6e, 0x0110 }; + QChar se[] = { 0x011D, 0x03C9, 0x0111 }; + QTest::newRow("highcodes (U+1D76E)") + << QString(st, sizeof(st)/sizeof(st[0])) + << QString(se, sizeof(se)/sizeof(se[0])) + << QString() << 0 << 0; + } + { + QChar st[] = { 'D', 0xdb40, 0xdc20, 'o', 0xd834, 0xdd7a, '\'', 0x2060, 'h' }; + QChar se[] = { 'd', 'o', '\'', 'h' }; + QTest::newRow("highcodes (D, U+E0020, o, U+1D17A, ', U+2060, h)") + << QString(st, sizeof(st)/sizeof(st[0])) + << QString(se, sizeof(se)/sizeof(se[0])) + << QString() << 0 << 0; + } +} + +void tst_QUrl::nameprep_highcodes() +{ +#ifdef QT_BUILD_INTERNAL + QFETCH(QString, in); + QFETCH(QString, out); + QFETCH(QString, profile); + qt_nameprep(&in, 0); QCOMPARE(in, out); #endif diff --git a/tests/auto/utf8/tst_utf8.cpp b/tests/auto/utf8/tst_utf8.cpp index 7bbbfab..9b6b8c1 100644 --- a/tests/auto/utf8/tst_utf8.cpp +++ b/tests/auto/utf8/tst_utf8.cpp @@ -210,7 +210,9 @@ void tst_Utf8::invalidUtf8_data() QTest::addColumn("utf8"); QTest::newRow("1char") << QByteArray("\x80"); - QTest::newRow("2chars") << QByteArray("\xC2\xC0"); + QTest::newRow("2chars-1") << QByteArray("\xC2\xC0"); + QTest::newRow("2chars-2") << QByteArray("\xC3\xDF"); + QTest::newRow("2chars-3") << QByteArray("\xC7\xF0"); QTest::newRow("3chars-1") << QByteArray("\xE0\xA0\xC0"); QTest::newRow("3chars-2") << QByteArray("\xE0\xC0\xA0"); QTest::newRow("4chars-1") << QByteArray("\xF0\x90\x80\xC0"); -- cgit v0.12 From 497cd2c5dfda11fff9233fc951813d6b84c78eed Mon Sep 17 00:00:00 2001 From: Thomas Sondergaard Date: Wed, 26 May 2010 10:52:19 +0200 Subject: Added QThreadPool::waitForDone(int msecs) Merge-request: 641 Reviewed-by: Olivier Goffart Reviewed-by: Morten Sorvig Task-number: QTBUG-2695 --- src/corelib/concurrent/qthreadpool.cpp | 34 +++++++++++++++++++++++++++--- src/corelib/concurrent/qthreadpool.h | 1 + src/corelib/concurrent/qthreadpool_p.h | 2 +- tests/auto/qthreadpool/tst_qthreadpool.cpp | 27 ++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/corelib/concurrent/qthreadpool.cpp b/src/corelib/concurrent/qthreadpool.cpp index 9e4189e..f25a494 100644 --- a/src/corelib/concurrent/qthreadpool.cpp +++ b/src/corelib/concurrent/qthreadpool.cpp @@ -41,6 +41,7 @@ #include "qthreadpool.h" #include "qthreadpool_p.h" +#include "qelapsedtimer.h" #ifndef QT_NO_THREAD @@ -288,11 +289,21 @@ void QThreadPoolPrivate::reset() isExiting = false; } -void QThreadPoolPrivate::waitForDone() +bool QThreadPoolPrivate::waitForDone(int msecs) { QMutexLocker locker(&mutex); - while (!(queue.isEmpty() && activeThreads == 0)) - noActiveThreads.wait(locker.mutex()); + if (msecs < 0) { + while (!(queue.isEmpty() && activeThreads == 0)) + noActiveThreads.wait(locker.mutex()); + } else { + QElapsedTimer timer; + timer.start(); + int t; + while (!(queue.isEmpty() && activeThreads == 0) && + ((t = msecs - timer.elapsed()) > 0)) + noActiveThreads.wait(locker.mutex(), t); + } + return queue.isEmpty() && activeThreads == 0; } /*! \internal @@ -617,6 +628,23 @@ void QThreadPool::waitForDone() d->reset(); } +/*! + \overload waitForDone() + \since 4.8 + + Waits up to \a msecs milliseconds for all threads to exit and removes all + threads from the thread pool. Returns true if all threads were removed; + otherwise it returns false. +*/ +bool QThreadPool::waitForDone(int msecs) +{ + Q_D(QThreadPool); + bool rc = d->waitForDone(msecs); + if (rc) + d->reset(); + return rc; +} + QT_END_NAMESPACE #endif diff --git a/src/corelib/concurrent/qthreadpool.h b/src/corelib/concurrent/qthreadpool.h index cc1e059..0bd1884 100644 --- a/src/corelib/concurrent/qthreadpool.h +++ b/src/corelib/concurrent/qthreadpool.h @@ -85,6 +85,7 @@ public: void releaseThread(); void waitForDone(); + bool waitForDone(int msecs); }; QT_END_NAMESPACE diff --git a/src/corelib/concurrent/qthreadpool_p.h b/src/corelib/concurrent/qthreadpool_p.h index 8a2cf98..3d2d6be 100644 --- a/src/corelib/concurrent/qthreadpool_p.h +++ b/src/corelib/concurrent/qthreadpool_p.h @@ -82,7 +82,7 @@ public: void startThread(QRunnable *runnable = 0); void reset(); - void waitForDone(); + bool waitForDone(int msecs = -1); bool startFrontRunnable(); void stealRunnable(QRunnable *); diff --git a/tests/auto/qthreadpool/tst_qthreadpool.cpp b/tests/auto/qthreadpool/tst_qthreadpool.cpp index 7c8b410..cd6070f 100644 --- a/tests/auto/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/qthreadpool/tst_qthreadpool.cpp @@ -89,6 +89,7 @@ private slots: void tryStartPeakThreadCount(); void tryStartCount(); void waitForDone(); + void waitForDoneTimeout(); void destroyingWaitsForTasksToFinish(); void stressTest(); }; @@ -774,6 +775,32 @@ void tst_QThreadPool::waitForDone() } } +void tst_QThreadPool::waitForDoneTimeout() +{ + class BlockedTask : public QRunnable + { + public: + QMutex mutex; + BlockedTask() { setAutoDelete(false); } + + void run() + { + mutex.lock(); + mutex.unlock(); + QTest::qSleep(50); + } + }; + + QThreadPool threadPool; + + BlockedTask *task = new BlockedTask; + task->mutex.lock(); + threadPool.start(task); + QVERIFY(!threadPool.waitForDone(100)); + task->mutex.unlock(); + QVERIFY(threadPool.waitForDone(400)); +} + void tst_QThreadPool::destroyingWaitsForTasksToFinish() { QTime total, pass; -- cgit v0.12 From 1f5c11e9789573baf7de157a82c124b8a79545a7 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 26 May 2010 13:09:49 +0200 Subject: Make test work with shadow builds again. Broken by 0cdf33e9acb00b8f3654e8268253a3fb7c5db92c, which assumes the binary and sources are in the same directory. The fix reverts the code back to how it was in 4.5 (where it still works with shadow builds). Reviewed-by: Denis Dzyubenko --- tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index dac631b..1f65ae7 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -56,7 +56,7 @@ #elif defined(Q_OS_WINCE) #define LACKEYDIR SRCDIR #else -#define LACKEYDIR SRCDIR "../lackey" +#define LACKEYDIR "../lackey" #endif Q_DECLARE_METATYPE(QSharedMemory::SharedMemoryError) @@ -421,7 +421,7 @@ void tst_QSharedMemory::readOnly() QString program = LACKEYDIR "/lackey"; QStringList arguments; rememberKey("readonly_segfault"); - arguments << LACKEYDIR "/scripts/readonly_segfault.js"; + arguments << SRCDIR "../lackey/scripts/readonly_segfault.js"; // ### on windows disable the popup somehow QProcess p; @@ -734,7 +734,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() rememberKey("market"); - QStringList arguments = QStringList() << LACKEYDIR "/scripts/producer.js"; + QStringList arguments = QStringList() << SRCDIR "../lackey/scripts/producer.js"; QProcess producer; producer.setProcessChannelMode(QProcess::ForwardedChannels); producer.start( LACKEYDIR "/lackey", arguments); @@ -744,7 +744,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() QList consumers; unsigned int failedProcesses = 0; for (int i = 0; i < processes; ++i) { - QStringList arguments = QStringList() << LACKEYDIR "/scripts/consumer.js"; + QStringList arguments = QStringList() << SRCDIR "../lackey/scripts/consumer.js"; QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); #ifdef Q_OS_WINCE -- cgit v0.12 From 97a092bd8f5e66fcb0212c0e9afcbd4447b6644d Mon Sep 17 00:00:00 2001 From: Mirko Damiani Date: Mon, 8 Feb 2010 16:09:24 +0100 Subject: Added native key support to QSharedMemory API. Methods setNativeKey() and nativeKey() were added to QSharedMemory API. Shared memory's native key is returned by nativeKey() and it is set with either setKey() or setNativeKey(). setKey() leads to a native key that is platform independent while setNativeKey() directly sets the native key without any mangling. When using setNativeKey(), key() returns a null string and shared memory's system semaphore is not set. This means that is up to the user to define a such protection mechanism (i.e. lock() can't be used on native keys). QSharedMemory tests were updated. Merge-request: 1497 Reviewed-by: Benjamin Poulain Reviewed-by: Andreas Aardal Hanssen --- src/corelib/kernel/qsharedmemory.cpp | 120 +++++++++++++++------ src/corelib/kernel/qsharedmemory.h | 2 + src/corelib/kernel/qsharedmemory_p.h | 1 + src/corelib/kernel/qsharedmemory_symbian.cpp | 11 +- src/corelib/kernel/qsharedmemory_unix.cpp | 15 ++- src/corelib/kernel/qsharedmemory_win.cpp | 13 +-- .../auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp | 26 +++-- 7 files changed, 123 insertions(+), 65 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index fe93ebc..d5f4052 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -142,9 +142,12 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, remain. Do not mix using QtSharedMemory and QSharedMemory. Port everything to QSharedMemory. - \warning QSharedMemory changes the key in a Qt-specific way. - It is therefore currently not possible to use the shared memory of - non-Qt applications with QSharedMemory. + \warning QSharedMemory changes the key in a Qt-specific way, unless otherwise + specified. Interoperation with non-Qt applications is achieved by first creating + a default shared memory with QSharedMemory() and then setting a native key with + setNativeKey(). When using native keys, shared memory is not protected against + multiple accesses on it (e.g. unable to lock()) and a user-defined mechanism + should be used to achieve a such protection. */ /*! @@ -153,8 +156,8 @@ QSharedMemoryPrivate::makePlatformSafeKey(const QString &key, Constructs a shared memory object with the given \a parent. The shared memory object's key is not set by the constructor, so the shared memory object does not have an underlying shared memory - segment attached. The key must be set with setKey() before create() - or attach() can be used. + segment attached. The key must be set with setKey() or setNativeKey() + before create() or attach() can be used. \sa setKey() */ @@ -191,24 +194,52 @@ QSharedMemory::~QSharedMemory() } /*! - Sets a new \a key for this shared memory object. If \a key and the - current key are the same, the function returns without doing - anything. If the shared memory object is attached to an underlying - shared memory segment, it will \l {detach()} {detach} from it before - setting the new key. This function does not do an attach(). - - \sa key() isAttached() - */ + Sets a new \a key for this shared memory object. + The \a key is first converted to a unicode string accepted by all supported platforms, + (see nativeKey()). If \a key and the current key are the same, the function returns + without doing anything. If the shared memory object is attached to an underlying + shared memory segment, it will \l {detach()} {detach} from it before setting the new key. + This function does not do an attach(). + + \sa key() nativeKey() isAttached() +*/ void QSharedMemory::setKey(const QString &key) { Q_D(QSharedMemory); - if (key == d->key) + if (key == d->key && d->makePlatformSafeKey(key) == d->nativeKey) return; if (isAttached()) detach(); d->cleanHandle(); d->key = key; + d->nativeKey = d->makePlatformSafeKey(key); +} + +/*! + \since 4.7 + Sets a new native \a key for this shared memory object. + The specified \a key is used as-is, without any conversion. The \a key has to be + in a valid format for the current operating system (e.g. under Unix a valid \a key + corresponds to a filename). Be aware that the application might not be portable. + This function returns without doing anything if the \a key equals the current + native key. If the shared memory object is attached to an underlying shared memory + segment, it will \l {detach()} {detach} from it before setting the new key. + This function does not do an attach(). + + \sa nativeKey() key() isAttached() +*/ +void QSharedMemory::setNativeKey(const QString &key) +{ + Q_D(QSharedMemory); + if (key == d->nativeKey && d->key.isNull()) + return; + + if (isAttached()) + detach(); + d->cleanHandle(); + d->key = QString(); + d->nativeKey = key; } bool QSharedMemoryPrivate::initKey() @@ -251,13 +282,14 @@ bool QSharedMemoryPrivate::initKey() } /*! - Returns the key assigned to this shared memory. The key is the - identifier used by the operating system to identify the shared - memory segment. When QSharedMemory is used for interprocess - communication, the key is how each process attaches to the shared - memory segment through which the IPC occurs. - - \sa setKey() + Returns the key assigned with setKey() to this shared memory. + The key is the identifier used by Qt applications to identify the shared + memory segment. The actual native key used by the operating system is returned + by nativeKey(). A null string is returned if the key was specified using setNativeKey(). + When QSharedMemory is used for interprocess communication, the key is how each + process attaches to the shared memory segment through which the IPC occurs. + + \sa setKey() setNativeKey() */ QString QSharedMemory::key() const { @@ -266,13 +298,31 @@ QString QSharedMemory::key() const } /*! - Creates a shared memory segment of \a size bytes with the key passed - to the constructor or set with setKey(), attaches to the new shared - memory segment with the given access \a mode, and returns \tt true. - If a shared memory segment identified by the key already exists, the - attach operation is not performed, and \tt false is returned. When - the return value is \tt false, call error() to determine which error - occurred. + \since 4.7 + Returns the native key assigned with setKey() or setNativeKey() to this shared memory. + The native key is the identifier used by the operating system to identify the + shared memory segment. When using setKey(), the native key is obtained by + converting the specified key into a format accepted by all supported platforms. + When using setNativeKey(), the native key actually corresponds to the specified key + without any conversion. When QSharedMemory is used for interprocess communication, + the key is how each process attaches to the shared memory segment through which + the IPC occurs. + + \sa setKey() setNativeKey() +*/ +QString QSharedMemory::nativeKey() const +{ + Q_D(const QSharedMemory); + return d->nativeKey; +} + +/*! + Creates a shared memory segment of \a size bytes with the key passed to the + constructor, set with setKey() or set with setNativeKey(), then attaches to + the new shared memory segment with the given access \a mode and returns + \tt true. If a shared memory segment identified by the key already exists, + the attach operation is not performed and \tt false is returned. When the + return value is \tt false, call error() to determine which error occurred. \sa error() */ @@ -294,7 +344,7 @@ bool QSharedMemory::create(int size, AccessMode mode) QString function = QLatin1String("QSharedMemory::create"); #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->tryLocker(&lock, function)) + if (!d->key.isNull() && !d->tryLocker(&lock, function)) return false; #endif @@ -338,7 +388,7 @@ int QSharedMemory::size() const /*! Attempts to attach the process to the shared memory segment identified by the key that was passed to the constructor or to a - call to setKey(). The access \a mode is \l {QSharedMemory::} + call to setKey() or setNativeKey(). The access \a mode is \l {QSharedMemory::} {ReadWrite} by default. It can also be \l {QSharedMemory::} {ReadOnly}. Returns true if the attach operation is successful. If false is returned, call error() to determine which error occurred. @@ -355,7 +405,7 @@ bool QSharedMemory::attach(AccessMode mode) return false; #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::attach"))) + if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::attach"))) return false; #endif @@ -395,7 +445,7 @@ bool QSharedMemory::detach() #ifndef QT_NO_SYSTEMSEMAPHORE QSharedMemoryLocker lock(this); - if (!d->tryLocker(&lock, QLatin1String("QSharedMemory::detach"))) + if (!d->key.isNull() && !d->tryLocker(&lock, QLatin1String("QSharedMemory::detach"))) return false; #endif @@ -451,9 +501,9 @@ const void *QSharedMemory::data() const by this process and returns true. If another process has locked the segment, this function blocks until the lock is released. Then it acquires the lock and returns true. If this function returns false, - it means either that you have ignored a false return from create() - or attach(), or that QSystemSemaphore::acquire() failed due to an - unknown system error. + it means that you have ignored a false return from create() or attach(), + that you have set the key with setNativeKey() or that + QSystemSemaphore::acquire() failed due to an unknown system error. \sa unlock(), data(), QSystemSemaphore::acquire() */ diff --git a/src/corelib/kernel/qsharedmemory.h b/src/corelib/kernel/qsharedmemory.h index fba939c..5673f43 100644 --- a/src/corelib/kernel/qsharedmemory.h +++ b/src/corelib/kernel/qsharedmemory.h @@ -85,6 +85,8 @@ public: void setKey(const QString &key); QString key() const; + void setNativeKey(const QString &key); + QString nativeKey() const; bool create(int size, AccessMode mode = ReadWrite); int size() const; diff --git a/src/corelib/kernel/qsharedmemory_p.h b/src/corelib/kernel/qsharedmemory_p.h index a52f8b3..632a6e9 100644 --- a/src/corelib/kernel/qsharedmemory_p.h +++ b/src/corelib/kernel/qsharedmemory_p.h @@ -122,6 +122,7 @@ public: void *memory; int size; QString key; + QString nativeKey; QSharedMemory::SharedMemoryError error; QString errorString; #ifndef QT_NO_SYSTEMSEMAPHORE diff --git a/src/corelib/kernel/qsharedmemory_symbian.cpp b/src/corelib/kernel/qsharedmemory_symbian.cpp index 9b84eb56..091c2b5 100644 --- a/src/corelib/kernel/qsharedmemory_symbian.cpp +++ b/src/corelib/kernel/qsharedmemory_symbian.cpp @@ -107,16 +107,14 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { - // Get a windows acceptable key - QString safeKey = makePlatformSafeKey(key); QString function = QLatin1String("QSharedMemory::create"); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); return false; } - TPtrC ptr(qt_QString2TPtrC(safeKey)); + TPtrC ptr(qt_QString2TPtrC(nativeKey)); TInt err = chunk.CreateGlobal(ptr, size, size); @@ -136,14 +134,13 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode /* mode */) // Grab a pointer to the memory block if (!chunk.Handle()) { QString function = QLatin1String("QSharedMemory::handle"); - QString safeKey = makePlatformSafeKey(key); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return false; } - TPtrC ptr(qt_QString2TPtrC(safeKey)); + TPtrC ptr(qt_QString2TPtrC(nativeKey)); TInt err = KErrNoMemory; diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp index a5f79c2..064979b 100644 --- a/src/corelib/kernel/qsharedmemory_unix.cpp +++ b/src/corelib/kernel/qsharedmemory_unix.cpp @@ -116,21 +116,20 @@ key_t QSharedMemoryPrivate::handle() return unix_key; // don't allow making handles on empty keys - if (key.isEmpty()) { + if (nativeKey.isEmpty()) { errorString = QSharedMemory::tr("%1: key is empty").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; return 0; } // ftok requires that an actual file exists somewhere - QString fileName = makePlatformSafeKey(key); - if (!QFile::exists(fileName)) { + if (!QFile::exists(nativeKey)) { errorString = QSharedMemory::tr("%1: UNIX key file doesn't exist").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::NotFound; return 0; } - unix_key = ftok(QFile::encodeName(fileName).constData(), 'Q'); + unix_key = ftok(QFile::encodeName(nativeKey).constData(), 'Q'); if (-1 == unix_key) { errorString = QSharedMemory::tr("%1: ftok failed").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; @@ -181,7 +180,7 @@ bool QSharedMemoryPrivate::create(int size) { // build file if needed bool createdFile = false; - int built = createUnixKeyFile(makePlatformSafeKey(key)); + int built = createUnixKeyFile(nativeKey); if (built == -1) { errorString = QSharedMemory::tr("%1: unable to make key").arg(QLatin1String("QSharedMemory::handle:")); error = QSharedMemory::KeyError; @@ -194,7 +193,7 @@ bool QSharedMemoryPrivate::create(int size) // get handle if (!handle()) { if (createdFile) - QFile::remove(makePlatformSafeKey(key)); + QFile::remove(nativeKey); return false; } @@ -210,7 +209,7 @@ bool QSharedMemoryPrivate::create(int size) setErrorString(function); } if (createdFile && error != QSharedMemory::AlreadyExists) - QFile::remove(makePlatformSafeKey(key)); + QFile::remove(nativeKey); return false; } @@ -295,7 +294,7 @@ bool QSharedMemoryPrivate::detach() } // remove file - if (!QFile::remove(makePlatformSafeKey(key))) + if (!QFile::remove(nativeKey)) return false; } return true; diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 0f5fdc7..0cdb123 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -99,18 +99,17 @@ HANDLE QSharedMemoryPrivate::handle() { if (!hand) { QString function = QLatin1String("QSharedMemory::handle"); - QString safeKey = makePlatformSafeKey(key); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: unable to make key").arg(function); return false; } #ifndef Q_OS_WINCE - hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)safeKey.utf16()); + hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16()); #else // This works for opening a mapping too, but always opens it with read/write access in // attach as it seems. - hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)safeKey.utf16()); + hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16()); #endif if (!hand) { setErrorString(function); @@ -133,17 +132,15 @@ bool QSharedMemoryPrivate::cleanHandle() bool QSharedMemoryPrivate::create(int size) { - // Get a windows acceptable key - QString safeKey = makePlatformSafeKey(key); QString function = QLatin1String("QSharedMemory::create"); - if (safeKey.isEmpty()) { + if (nativeKey.isEmpty()) { error = QSharedMemory::KeyError; errorString = QSharedMemory::tr("%1: key error").arg(function); return false; } // Create the file mapping. - hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)safeKey.utf16()); + hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16()); setErrorString(function); // hand is valid when it already exists unlike unix so explicitly check diff --git a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp index 1f65ae7..dc071ab 100644 --- a/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp +++ b/tests/auto/qtipc/qsharedmemory/tst_qsharedmemory.cpp @@ -225,11 +225,17 @@ void tst_QSharedMemory::key_data() { QTest::addColumn("constructorKey"); QTest::addColumn("setKey"); - - QTest::newRow("null, null") << QString() << QString(); - QTest::newRow("null, one") << QString() << QString("one"); - QTest::newRow("one, two") << QString("one") << QString("two"); - QTest::newRow("invalid") << QString("o/e") << QString("t/o"); + QTest::addColumn("setNativeKey"); + + QTest::newRow("null, null, null") << QString() << QString() << QString(); + QTest::newRow("one, null, null") << QString("one") << QString() << QString(); + QTest::newRow("null, one, null") << QString() << QString("one") << QString(); + QTest::newRow("null, null, one") << QString() << QString() << QString("one"); + QTest::newRow("one, two, null") << QString("one") << QString("two") << QString(); + QTest::newRow("one, null, two") << QString("one") << QString() << QString("two"); + QTest::newRow("null, one, two") << QString() << QString("one") << QString("two"); + QTest::newRow("one, two, three") << QString("one") << QString("two") << QString("three"); + QTest::newRow("invalid") << QString("o/e") << QString("t/o") << QString("|x"); } /*! @@ -239,11 +245,17 @@ void tst_QSharedMemory::key() { QFETCH(QString, constructorKey); QFETCH(QString, setKey); + QFETCH(QString, setNativeKey); QSharedMemory sm(constructorKey); QCOMPARE(sm.key(), constructorKey); + QCOMPARE(sm.nativeKey().isEmpty(), constructorKey.isEmpty()); sm.setKey(setKey); QCOMPARE(sm.key(), setKey); + QCOMPARE(sm.nativeKey().isEmpty(), setKey.isEmpty()); + sm.setNativeKey(setNativeKey); + QVERIFY(sm.key().isNull()); + QCOMPARE(sm.nativeKey(), setNativeKey); QCOMPARE(sm.isAttached(), false); QCOMPARE(sm.error(), QSharedMemory::NoError); @@ -262,7 +274,7 @@ void tst_QSharedMemory::create_data() QTest::addColumn("error"); QTest::newRow("null key") << QString() << 1024 - << false << QSharedMemory::LockError; + << false << QSharedMemory::KeyError; QTest::newRow("-1 size") << QString("negsize") << -1 << false << QSharedMemory::InvalidSize; QTest::newRow("nor size") << QString("norsize") << 1024 @@ -302,7 +314,7 @@ void tst_QSharedMemory::attach_data() QTest::addColumn("exists"); QTest::addColumn("error"); - QTest::newRow("null key") << QString() << false << QSharedMemory::LockError; + QTest::newRow("null key") << QString() << false << QSharedMemory::KeyError; QTest::newRow("doesn't exists") << QString("doesntexists") << false << QSharedMemory::NotFound; QTest::newRow("already exists") << QString(EXISTING_SHARE) << true << QSharedMemory::NoError; } -- cgit v0.12 From 8d267e8d7a1e3374558ed302cfa415788ca74e02 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Wed, 26 May 2010 14:00:15 +0200 Subject: Improved documentation for QSharedMemory's key/setKey functions. --- src/corelib/kernel/qsharedmemory.cpp | 64 +++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/corelib/kernel/qsharedmemory.cpp b/src/corelib/kernel/qsharedmemory.cpp index d5f4052..0782ffe 100644 --- a/src/corelib/kernel/qsharedmemory.cpp +++ b/src/corelib/kernel/qsharedmemory.cpp @@ -194,11 +194,15 @@ QSharedMemory::~QSharedMemory() } /*! - Sets a new \a key for this shared memory object. - The \a key is first converted to a unicode string accepted by all supported platforms, - (see nativeKey()). If \a key and the current key are the same, the function returns - without doing anything. If the shared memory object is attached to an underlying - shared memory segment, it will \l {detach()} {detach} from it before setting the new key. + Sets the platform independent \a key for this shared memory object. If \a key + is the same as the current key, the function returns without doing anything. + + You can call key() to retrieve the platform independent key. Internally, + QSharedMemory converts this key into a platform specific key. If you instead + call nativeKey(), you will get the platform specific, converted key. + + If the shared memory object is attached to an underlying shared memory + segment, it will \l {detach()} {detach} from it before setting the new key. This function does not do an attach(). \sa key() nativeKey() isAttached() @@ -217,16 +221,22 @@ void QSharedMemory::setKey(const QString &key) } /*! - \since 4.7 - Sets a new native \a key for this shared memory object. - The specified \a key is used as-is, without any conversion. The \a key has to be - in a valid format for the current operating system (e.g. under Unix a valid \a key - corresponds to a filename). Be aware that the application might not be portable. - This function returns without doing anything if the \a key equals the current - native key. If the shared memory object is attached to an underlying shared memory + \since 4.8 + + Sets the native, platform specific, \a key for this shared memory object. If + \a key is the same as the current native key, the function returns without + doing anything. If all you want is to assign a key to a segment, you should + call setKey() instead. + + You can call nativeKey() to retrieve the native key. If a native key has been + assigned, calling key() will return a null string. + + If the shared memory object is attached to an underlying shared memory segment, it will \l {detach()} {detach} from it before setting the new key. This function does not do an attach(). + The application will not be portable if you set a native key. + \sa nativeKey() key() isAttached() */ void QSharedMemory::setNativeKey(const QString &key) @@ -282,12 +292,13 @@ bool QSharedMemoryPrivate::initKey() } /*! - Returns the key assigned with setKey() to this shared memory. - The key is the identifier used by Qt applications to identify the shared - memory segment. The actual native key used by the operating system is returned - by nativeKey(). A null string is returned if the key was specified using setNativeKey(). - When QSharedMemory is used for interprocess communication, the key is how each - process attaches to the shared memory segment through which the IPC occurs. + Returns the key assigned with setKey() to this shared memory, or a null key + if no key has been assigned, or if the segment is using a nativeKey(). The + key is the identifier used by Qt applications to identify the shared memory + segment. + + You can find the native, platform specific, key used by the operating system + by calling nativeKey(). \sa setKey() setNativeKey() */ @@ -298,15 +309,14 @@ QString QSharedMemory::key() const } /*! - \since 4.7 - Returns the native key assigned with setKey() or setNativeKey() to this shared memory. - The native key is the identifier used by the operating system to identify the - shared memory segment. When using setKey(), the native key is obtained by - converting the specified key into a format accepted by all supported platforms. - When using setNativeKey(), the native key actually corresponds to the specified key - without any conversion. When QSharedMemory is used for interprocess communication, - the key is how each process attaches to the shared memory segment through which - the IPC occurs. + \since 4.8 + + Returns the native, platform specific, key for this shared memory object. The + native key is the identifier used by the operating system to identify the + shared memory segment. + + You can use the native key to access shared memory segments that have not + been created by Qt, or to grant shared memory access to non-Qt applications. \sa setKey() setNativeKey() */ -- 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 fa46fa236b5f4a9a5677da2e7464a6b9f8b7b5f3 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 12 May 2010 14:41:49 +0200 Subject: make QFileSystemModel distinguish C: from C:\ Since QFileSystemModel just uses a C: to represent C:\ for esthetics, we now need to append a slash to make sure we do not accidently point to the current working directory on C:\. Reviewed-by: Joao Task-number: QTBUG-8241 --- src/gui/dialogs/qfilesystemmodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 8a6190f..e5a8445 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1290,6 +1290,10 @@ QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const if ((fullPath.length() > 2) && fullPath[0] == QLatin1Char('/') && fullPath[1] == QLatin1Char('/')) fullPath = fullPath.mid(1); #endif +#if defined(Q_OS_WIN) + if (fullPath.length() == 2 && fullPath.endsWith(QLatin1Char(':'))) + fullPath.append(QLatin1Char('/')); +#endif return fullPath; } -- cgit v0.12 From 5658fac923b419df1f9a95f01b2a5c76737004b2 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 26 May 2010 13:15:41 +0200 Subject: make QFileSystemWatcher_win distinguish C: from C:\ Since we now support this in QFileInfo, we also need to support this in QFileSystemWatcher. Otherwise the changes in a watched root folder would not get detected. Reviewed-by: Joao Task-number: QTBUG-8241 --- src/corelib/io/qfilesystemwatcher_win.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 249ce0f..71df3c2 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -86,7 +86,8 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, while (it.hasNext()) { QString path = it.next(); QString normalPath = path; - if ((normalPath.endsWith(QLatin1Char('/')) || normalPath.endsWith(QLatin1Char('\\'))) + if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/"))) + || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\"))) #ifdef Q_OS_WINCE && normalPath.size() > 1) #else -- cgit v0.12 From 83ad5ebb033799352723a9d968b31a9cef61396c Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Wed, 12 May 2010 14:41:49 +0200 Subject: make QFileSystemModel::rmdir(dir) remove dir from fileInfoGatherer Otherwise directories cannot be deleted as long as they are watched, since the fileInfoGatherer keeps a QFileInfo object with open file handles. Reviewed-by: Joao Task-number: QTBUG-8241 --- src/gui/dialogs/qfilesystemmodel.cpp | 8 ++++++++ src/gui/dialogs/qfilesystemmodel.h | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index e5a8445..b8aafe3 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1612,6 +1612,14 @@ bool QFileSystemModel::event(QEvent *event) return QAbstractItemModel::event(event); } +bool QFileSystemModel::rmdir(const QModelIndex &aindex) const +{ + QString path = filePath(aindex); + QFileSystemModelPrivate * d = const_cast(d_func()); + d->fileInfoGatherer.removePath(path); + return QDir().rmdir(path); +} + /*! \internal diff --git a/src/gui/dialogs/qfilesystemmodel.h b/src/gui/dialogs/qfilesystemmodel.h index d8178c7..741f22b 100644 --- a/src/gui/dialogs/qfilesystemmodel.h +++ b/src/gui/dialogs/qfilesystemmodel.h @@ -139,7 +139,7 @@ public: QDateTime lastModified(const QModelIndex &index) const; QModelIndex mkdir(const QModelIndex &parent, const QString &name); - inline bool rmdir(const QModelIndex &index) const; + bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const inline QString fileName(const QModelIndex &index) const; inline QIcon fileIcon(const QModelIndex &index) const; QFile::Permissions permissions(const QModelIndex &index) const; @@ -163,8 +163,6 @@ private: friend class QFileDialogPrivate; }; -inline bool QFileSystemModel::rmdir(const QModelIndex &aindex) const -{ QDir dir; return dir.rmdir(filePath(aindex)); } inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const { return aindex.data(Qt::DisplayRole).toString(); } inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const -- 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 66d68138c6b21d249daad27c904c688b78d21af6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 26 May 2010 10:05:14 +0200 Subject: Speedup destruction of QObject if the eventloop is not entered. QObjectPrivate::removePendingChildInsertedEvents intoduce O(n^2) complexity. Remove this function and instead check the object has not been removed/reparented Known side effects: if the object would be parented multiple times to the same object, multiple QEvent::ChildInserted will be sends This would also create the QWeakPointer external refcount for almost each objects. Task-number: QTBUG-6546 Reviewed-by: Brad --- src/corelib/kernel/qcoreapplication.cpp | 7 +------ src/corelib/kernel/qobject.cpp | 24 ++---------------------- src/corelib/kernel/qobject_p.h | 4 ++-- src/gui/kernel/qapplication.cpp | 5 ----- 4 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 4e6e6b9..a354498 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -805,11 +805,6 @@ bool QCoreApplication::notify(QObject *receiver, QEvent *event) d->checkReceiverThread(receiver); #endif -#ifdef QT3_SUPPORT - if (event->type() == QEvent::ChildRemoved && !receiver->d_func()->pendingChildInsertedEvents.isEmpty()) - receiver->d_func()->removePendingChildInsertedEvents(static_cast(event)->child()); -#endif // QT3_SUPPORT - return receiver->isWidgetType() ? false : d->notify_helper(receiver, event); } @@ -1475,7 +1470,7 @@ void QCoreApplication::removePostedEvents(QObject *receiver, int eventType) --pe.receiver->d_func()->postedEvents; #ifdef QT3_SUPPORT if (pe.event->type() == QEvent::ChildInsertedRequest) - pe.receiver->d_func()->removePendingChildInsertedEvents(0); + pe.receiver->d_func()->pendingChildInsertedEvents.clear(); #endif pe.event->posted = false; events.append(pe.event); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 2648e6e..946c8d4 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -195,8 +195,8 @@ void QObjectPrivate::sendPendingChildInsertedEvents() { Q_Q(QObject); for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) { - QObject *c = pendingChildInsertedEvents.at(i); - if (!c) + QObject *c = pendingChildInsertedEvents.at(i).data(); + if (!c || c->parent() != q) continue; QChildEvent childEvent(QEvent::ChildInserted, c); QCoreApplication::sendEvent(q, &childEvent); @@ -204,26 +204,6 @@ void QObjectPrivate::sendPendingChildInsertedEvents() pendingChildInsertedEvents.clear(); } -void QObjectPrivate::removePendingChildInsertedEvents(QObject *child) -{ - if (!child) { - pendingChildInsertedEvents.clear(); - return; - } - - // the QObject destructor calls QObject::removeChild, which calls - // QCoreApplication::sendEvent() directly. this can happen while the event - // loop is in the middle of posting events, and when we get here, we may - // not have any more posted events for this object. - - // if this is a child remove event and the child insert hasn't - // been dispatched yet, kill that insert - for (int i = 0; i < pendingChildInsertedEvents.size(); ++i) { - QObject *&c = pendingChildInsertedEvents[i]; - if (c == child) - c = 0; - } -} #endif diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 35b4540..82023d4 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -55,6 +55,7 @@ #include "QtCore/qobject.h" #include "QtCore/qpointer.h" +#include "QtCore/qsharedpointer.h" #include "QtCore/qcoreevent.h" #include "QtCore/qlist.h" #include "QtCore/qvector.h" @@ -153,7 +154,6 @@ public: #ifdef QT3_SUPPORT void sendPendingChildInsertedEvents(); - void removePendingChildInsertedEvents(QObject *child); #endif static inline Sender *setCurrentSender(QObject *receiver, @@ -186,7 +186,7 @@ public: mutable quint32 connectedSignals[2]; #ifdef QT3_SUPPORT - QList pendingChildInsertedEvents; + QVector< QWeakPointer > pendingChildInsertedEvents; #else // preserve binary compatibility with code compiled without Qt 3 support // keeping the binary layout stable helps the Qt Creator debugger diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 7b62de1..88d81da 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -3655,11 +3655,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) d->checkReceiverThread(receiver); #endif -#ifdef QT3_SUPPORT - if (e->type() == QEvent::ChildRemoved && !receiver->d_func()->pendingChildInsertedEvents.isEmpty()) - receiver->d_func()->removePendingChildInsertedEvents(static_cast(e)->child()); -#endif // QT3_SUPPORT - // capture the current mouse/keyboard state if(e->spontaneous()) { if (e->type() == QEvent::KeyPress -- cgit v0.12 From 89dfa8d7a46c992b066e5335d64089bf796e2f83 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 26 May 2010 10:46:39 +0200 Subject: Make QWeakPointer and QSharedPointer movable For making QVector of them faster. Reviewed-by: Thiago --- src/corelib/global/qglobal.h | 8 ++++++-- src/corelib/tools/qsharedpointer_impl.h | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7093dee..808ff44 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2041,8 +2041,8 @@ enum { /* TYPEINFO flags */ Q_DUMMY_TYPE = 0x4 }; -#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \ -template <> \ +#define Q_DECLARE_TYPEINFO_TEMPLATE(TYPE, FLAGS, TEMPLATE_ARG) \ +template \ class QTypeInfo \ { \ public: \ @@ -2056,6 +2056,10 @@ public: \ static inline const char *name() { return #TYPE; } \ } +#define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \ +Q_DECLARE_TYPEINFO_TEMPLATE(TYPE, FLAGS, ) + + template inline void qSwap(T &value1, T &value2) { diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 550ff58..9e40bd5 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -841,9 +841,13 @@ qobject_cast(const QWeakPointer &src) { return qSharedPointerObjectCast::Type, T>(src); } - #endif + +Q_DECLARE_TYPEINFO_TEMPLATE(QWeakPointer, Q_MOVABLE_TYPE, typename T); +Q_DECLARE_TYPEINFO_TEMPLATE(QSharedPointer, Q_MOVABLE_TYPE, typename T); + + QT_END_NAMESPACE QT_END_HEADER -- cgit v0.12 From 0b61f3e8b7656b3295c959ea8e54c3321167c7fa Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 27 May 2010 14:17:28 +0200 Subject: Avoid sending deprecated Qt3Support events if the application was built without Qt3Support - Detect if the application was built using Qt3Support using the QApplication's constructor internal flags. - Move that from QApplication to QCoreApplication. - Do not send the event if the application was not built with Qt3Support Reviewed-by: Brad --- src/corelib/kernel/qcoreapplication.cpp | 33 +++++++++++++++++++++++++++++++-- src/corelib/kernel/qcoreapplication.h | 18 +++++++++++++++++- src/corelib/kernel/qcoreapplication_p.h | 6 +++++- src/corelib/kernel/qobject.cpp | 12 +++++++----- src/gui/kernel/qapplication.cpp | 32 +++++++++++++++----------------- src/gui/kernel/qapplication.h | 12 ++++++------ src/gui/kernel/qapplication_p.h | 4 +--- src/gui/kernel/qapplication_s60.cpp | 4 ++-- 8 files changed, 84 insertions(+), 37 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index a354498..179158f 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -122,6 +122,11 @@ static SystemDriveFunc PtrGetSystemDrive=0; extern QString qAppFileName(); #endif +int QCoreApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 +#if defined(QT3_SUPPORT) +bool QCoreApplicationPrivate::useQt3Support = true; +#endif + #if !defined(Q_OS_WIN) #ifdef Q_OS_MAC QString QCoreApplicationPrivate::macMenuBarName() @@ -263,10 +268,14 @@ struct QCoreApplicationData { Q_GLOBAL_STATIC(QCoreApplicationData, coreappdata) -QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv) +QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint flags) : QObjectPrivate(), argc(aargc), argv(aargv), application_type(0), eventFilter(0), in_exec(false), aboutToQuitEmitted(false) { + app_compile_version = flags & 0xffffff; +#if defined(QT3_SUPPORT) + useQt3Support = !(flags & 0x01000000); +#endif static const char *const empty = ""; if (argc == 0 || argv == 0) { argc = 0; @@ -511,7 +520,7 @@ void QCoreApplication::flush() one valid character string. */ QCoreApplication::QCoreApplication(int &argc, char **argv) - : QObject(*new QCoreApplicationPrivate(argc, argv)) + : QObject(*new QCoreApplicationPrivate(argc, argv, 0x040000)) { init(); QCoreApplicationPrivate::eventDispatcher->startingUp(); @@ -527,6 +536,25 @@ QCoreApplication::QCoreApplication(int &argc, char **argv) #endif } +QCoreApplication::QCoreApplication(int &argc, char **argv, int _internal) +: QObject(*new QCoreApplicationPrivate(argc, argv, _internal)) +{ + init(); + QCoreApplicationPrivate::eventDispatcher->startingUp(); +#if defined(Q_OS_SYMBIAN) +#ifndef QT_NO_LIBRARY + // Refresh factoryloader, as text codecs are requested during lib path + // resolving process and won't be therefore properly loaded. + // Unknown if this is symbian specific issue. + QFactoryLoader::refreshAll(); +#endif +#ifndef QT_NO_SYSTEMLOCALE + d_func()->symbianInit(); +#endif +#endif //Q_OS_SYMBIAN +} + + // ### move to QCoreApplicationPrivate constructor? void QCoreApplication::init() { @@ -1014,6 +1042,7 @@ int QCoreApplication::exec() return returnCode; } + /*! Tells the application to exit with a return code. diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h index d87103e..f1c7c26 100644 --- a/src/corelib/kernel/qcoreapplication.h +++ b/src/corelib/kernel/qcoreapplication.h @@ -78,7 +78,23 @@ class Q_CORE_EXPORT QCoreApplication : public QObject Q_DECLARE_PRIVATE(QCoreApplication) public: - QCoreApplication(int &argc, char **argv); + enum { ApplicationFlags = QT_VERSION +#if !defined(QT3_SUPPORT) + | 0x01000000 +#endif + }; + +#if defined(QT_BUILD_CORE_LIB) || defined(qdoc) + QCoreApplication(int &argc, char **argv); // ### Qt5 remove +#endif +#if !defined(qdoc) + QCoreApplication(int &argc, char **argv, int +#if !defined(QT_BUILD_CORE_LIB) + = ApplicationFlags +#endif + ); +#endif + ~QCoreApplication(); #ifdef QT_DEPRECATED diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index e066137..2355c37 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -75,7 +75,7 @@ class Q_CORE_EXPORT QCoreApplicationPrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QCoreApplication) public: - QCoreApplicationPrivate(int &aargc, char **aargv); + QCoreApplicationPrivate(int &aargc, char **aargv, uint flags); ~QCoreApplicationPrivate(); bool sendThroughApplicationEventFilters(QObject *, QEvent *); @@ -129,6 +129,10 @@ public: static uint attribs; static inline bool testAttribute(uint flag) { return attribs & (1 << flag); } + static int app_compile_version; +#if defined(QT3_SUPPORT) + static bool useQt3Support; +#endif }; QT_END_NAMESPACE diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 946c8d4..6187633 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1969,12 +1969,14 @@ void QObjectPrivate::setParent_helper(QObject *o) QChildEvent e(QEvent::ChildAdded, q); QCoreApplication::sendEvent(parent, &e); #ifdef QT3_SUPPORT - if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) { - QCoreApplication::postEvent(parent, - new QEvent(QEvent::ChildInsertedRequest), - Qt::HighEventPriority); + if (QCoreApplicationPrivate::useQt3Support) { + if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) { + QCoreApplication::postEvent(parent, + new QEvent(QEvent::ChildInsertedRequest), + Qt::HighEventPriority); + } + parent->d_func()->pendingChildInsertedEvents.append(q); } - parent->d_func()->pendingChildInsertedEvents.append(q); #endif } } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 88d81da..920000e 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -144,8 +144,6 @@ QT_BEGIN_NAMESPACE Q_DECL_IMPORT extern void qt_call_post_routines(); -int QApplicationPrivate::app_compile_version = 0x040000; //we don't know exactly, but it's at least 4.0.0 - QApplication::Type qt_appType=QApplication::Tty; QApplicationPrivate *QApplicationPrivate::self = 0; @@ -160,8 +158,8 @@ bool QApplicationPrivate::autoSipEnabled = false; bool QApplicationPrivate::autoSipEnabled = true; #endif -QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type) - : QCoreApplicationPrivate(argc, argv) +QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags) + : QCoreApplicationPrivate(argc, argv, flags) { application_type = type; qt_appType = type; @@ -696,12 +694,12 @@ void QApplicationPrivate::process_cmdline() */ QApplication::QApplication(int &argc, char **argv) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) { Q_D(QApplication); d->construct(); } QApplication::QApplication(int &argc, char **argv, int _internal) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) -{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) +{ Q_D(QApplication); d->construct(); } /*! @@ -730,12 +728,12 @@ QApplication::QApplication(int &argc, char **argv, int _internal) */ QApplication::QApplication(int &argc, char **argv, bool GUIenabled ) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000)) { Q_D(QApplication); d->construct(); } QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty)) -{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} + : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal)) +{ Q_D(QApplication); d->construct();} @@ -753,12 +751,12 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern \c -qws option). */ QApplication::QApplication(int &argc, char **argv, Type type) - : QCoreApplication(*new QApplicationPrivate(argc, argv, type)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, type, 0x040000)) { Q_D(QApplication); d->construct(); } QApplication::QApplication(int &argc, char **argv, Type type , int _internal) - : QCoreApplication(*new QApplicationPrivate(argc, argv, type)) -{ Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} + : QCoreApplication(*new QApplicationPrivate(argc, argv, type, _internal)) +{ Q_D(QApplication); d->construct(); } /*! @@ -835,7 +833,7 @@ static char *aargv[] = { (char*)"unknown", 0 }; This function is only available on X11. */ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) - : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000)) { if (! dpy) qWarning("QApplication: Invalid Display* argument"); @@ -844,7 +842,7 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) } QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal)) { if (! dpy) qWarning("QApplication: Invalid Display* argument"); @@ -869,7 +867,7 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, */ QApplication::QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE colormap) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) { if (! dpy) qWarning("QApplication: Invalid Display* argument"); @@ -879,7 +877,7 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv, QApplication::QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) { if (! dpy) qWarning("QApplication: Invalid Display* argument"); diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index c21b982..f93f24a 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -123,15 +123,15 @@ public: #endif #ifndef qdoc - QApplication(int &argc, char **argv, int = QT_VERSION); - QApplication(int &argc, char **argv, bool GUIenabled, int = QT_VERSION); - QApplication(int &argc, char **argv, Type, int = QT_VERSION); + QApplication(int &argc, char **argv, int = ApplicationFlags); + QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); + QApplication(int &argc, char **argv, Type, int = ApplicationFlags); #if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = QT_VERSION); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = QT_VERSION); + QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags); + QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags); #endif #if defined(Q_WS_S60) - QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = QT_VERSION); + QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = ApplicationFlags); #endif #endif virtual ~QApplication(); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 01abe54..25dea1f 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -286,7 +286,7 @@ class Q_GUI_EXPORT QApplicationPrivate : public QCoreApplicationPrivate { Q_DECLARE_PUBLIC(QApplication) public: - QApplicationPrivate(int &argc, char **argv, QApplication::Type type); + QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags); ~QApplicationPrivate(); #if defined(Q_WS_X11) @@ -483,8 +483,6 @@ public: static QString styleOverride; - static int app_compile_version; - #ifdef QT_KEYPAD_NAVIGATION static QWidget *oldEditFocus; static Qt::NavigationMode navigationMode; diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index fa07b1a..0058ff5 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1186,7 +1186,7 @@ void QSymbianControl::setFocusSafely(bool focus) This function is only available on S60. */ QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) { Q_D(QApplication); S60->s60ApplicationFactory = factory; @@ -1194,7 +1194,7 @@ QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int } QApplication::QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int _internal) - : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient)) + : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) { Q_D(QApplication); S60->s60ApplicationFactory = factory; -- cgit v0.12 From 3ce123a89cf9b8dfcf4ecb1a4e3f8c2ff5121c45 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 28 May 2010 13:01:59 +0200 Subject: fix for tst_qfiledialog2 to distinguish between C: and C:/ This fix is needed because the qfiledialog uses just "C:" to display the drive entry. But "C:" in fact does not point to the drive root necessarily. Therfor qfiledialog now appends a slash, but the unit test did not expect that. Reviewed-by: TrustMe --- tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index eee495f..9a96130 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -547,7 +547,7 @@ void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() QTest::qWait(200); QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); QTest::qWait(200); - QCOMPARE(edit->text(), QString("C:")); + QCOMPARE(edit->text(), QString("C:/")); QTest::qWait(2000); //i clear my previous selection in the completer QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); @@ -555,7 +555,7 @@ void tst_QFileDialog2::task226366_lowerCaseHardDriveWindows() QTest::keyClick(edit, (char)(Qt::Key_C | Qt::SHIFT)); QTest::qWait(200); QTest::keyClick(edit->completer()->popup(), Qt::Key_Down); - QCOMPARE(edit->text(), QString("C:")); + QCOMPARE(edit->text(), QString("C:/")); } #endif -- cgit v0.12 From f21d6799385e10f3ecf9d1b5af050ec83c6031b4 Mon Sep 17 00:00:00 2001 From: Mike FABIAN Date: Mon, 31 May 2010 08:57:39 +0200 Subject: Changes: add patch for artificial emboldening Details: Fixes http://bugreports.qt.nokia.com/browse/QTBUG-10596 Patch taken from https://bugzilla.novell.com/show_bug.cgi?id=374066 https://bugzillafiles.novell.org/attachment.cgi?id=232442 and http://code.google.com/p/gentoo-taiwan/source/browse/trunk/x11-libs/qt-gui/files/synthetic-bold-4.5.diff?spec=svn298&r=298 and slightly edited. Moving the two lines concerning the underlining is unrelated to the emboldening but seems to make sense anyway, the comment "//underline metrics" seems to be misplaced before the "if (FT_IS_SCALABLE(face)) {| The hunk: @@ -789,6 +794,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph } FT_GlyphSlot slot = face->glyph; + if (embolden) FT_GlyphSlot_Embolden(slot); int left = slot->metrics.horiBearingX; int right = slot->metrics.horiBearingX + slot->metrics.width; int top = slot->metrics.horiBearingY; seems to be logical but it is apparently not used when running my test program, i.e. synthetic emboldening in my test program works even without this hunk. Task-number: QTBUG-10596 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 15 ++++++++++++--- src/gui/text/qfontengine_ft_p.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 449dffd..9056012 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -58,6 +58,7 @@ #include #include FT_FREETYPE_H #include FT_OUTLINE_H +#include FT_SYNTHESIS_H #include FT_TRUETYPE_TABLES_H #include FT_TYPE1_TABLES_H #include FT_GLYPH_H @@ -617,6 +618,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd) cache_cost = 100; kerning_pairs_loaded = false; transform = false; + embolden = false; antialias = true; freetype = 0; default_load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; @@ -679,10 +681,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) FT_Face face = lockFace(); - //underline metrics if (FT_IS_SCALABLE(face)) { - line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); - underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); if (fake_oblique) matrix.xy = 0x10000*3/10; @@ -690,6 +689,12 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) freetype->matrix = matrix; if (fake_oblique) transform = true; + // fake bold + if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD)) + embolden = true; + // underline metrics + line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); + underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); } else { // copied from QFontEngineQPF // ad hoc algorithm @@ -789,6 +794,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph } FT_GlyphSlot slot = face->glyph; + if (embolden) FT_GlyphSlot_Embolden(slot); int left = slot->metrics.horiBearingX; int right = slot->metrics.horiBearingX + slot->metrics.width; int top = slot->metrics.horiBearingY; @@ -934,6 +940,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph return 0; FT_GlyphSlot slot = face->glyph; + if (embolden) FT_GlyphSlot_Embolden(slot); FT_Library library = qt_getFreetype(); info.xOff = TRUNC(ROUND(slot->advance.x)); @@ -1209,6 +1216,8 @@ int QFontEngineFT::synthesized() const int s = 0; if ((fontDef.style != QFont::StyleNormal) && !(freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)) s = SynthesizedItalic; + if ((fontDef.weight == QFont::Bold) && !(freetype->face->style_flags & FT_STYLE_FLAG_BOLD)) + s |= SynthesizedBold; if (fontDef.stretch != 100 && FT_IS_SCALABLE(freetype->face)) s |= SynthesizedStretch; return s; diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 12b7da8..2f05a8b 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -304,6 +304,7 @@ protected: bool antialias; bool transform; + bool embolden; SubpixelAntialiasingType subpixelType; int lcdFilterType; bool canUploadGlyphsToServer; -- cgit v0.12 From af1b64cec8ed74602fafadade936b1768daa9ff2 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 31 May 2010 11:03:24 +0200 Subject: Revert the change in applicationShouldTerminate(). It used to fix an issue during logout but it seems to be fine now. Related issue: QTBUG-6296 Task-number: QTBUG-10993 Reviewed-by: Morten Sorvig --- src/gui/kernel/qcocoaapplicationdelegate_mac.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm index 5dcf613..7a9dc70 100644 --- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm +++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm @@ -196,7 +196,6 @@ static void cleanupCocoaApplicationDelegate() qAppInstance()->quit(); startedQuit = false; } - return NSTerminateNow; } if (qtPrivate->threadData->eventLoops.size() == 0) { -- cgit v0.12 From 5cdafc956f6f2e18012b31d68851150d89d7e577 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 28 May 2010 12:45:30 +0200 Subject: Cocoa: remove 'double' content view from window Up til now, we always used to create a new NSView for a top level widget, and make it a child of the windows content view. This is/should be unnecessary, as NSWindow has a method for setting the content view directly, thereby allowing for reducing the stacking level with one view. Not the biggest gain if the year, but it seems effortless to implement. And I do it as a part of Alien preparation. Rev-By: msorvig --- src/gui/kernel/qwidget_mac.mm | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index f12c956..40c5dad 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -237,6 +237,8 @@ static NSDrawer *qt_mac_drawer_for(const QWidget *widget) static void qt_mac_destructView(OSViewRef view) { #ifdef QT_MAC_USE_COCOA + if ([[view window] contentView] == view) + [[view window] setContentView:0]; [view removeFromSuperview]; [view release]; #else @@ -2285,28 +2287,23 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin Q_UNUSED(dialog); data.fstrut_dirty = true; // when we create a toplevel widget, the frame strut should be dirty + OSViewRef nsview = (OSViewRef)data.winid; - OSViewRef window_contentview = qt_mac_get_contentview_for(windowRef); if (!nsview) { - nsview = qt_mac_create_widget(q, this, window_contentview); + nsview = qt_mac_create_widget(q, this, 0); setWinId(WId(nsview)); - } else { - [window_contentview addSubview:nsview]; - } - if (nsview) { - NSRect bounds = [window_contentview bounds]; - [nsview setFrame:bounds]; - [nsview setHidden:NO]; - if (q->testAttribute(Qt::WA_DropSiteRegistered)) - registerDropSite(true); - transferChildren(); - - // Tell Cocoa explicit that we wan't the view to receive key events - // (regardless of focus policy) because this is how it works on other - // platforms (and in the carbon port): - if (!qApp->focusWidget()) - [windowRef makeFirstResponder:nsview]; } + [windowRef setContentView:nsview]; + [nsview setHidden:NO]; + if (q->testAttribute(Qt::WA_DropSiteRegistered)) + registerDropSite(true); + transferChildren(); + + // Tell Cocoa explicit that we wan't the view to receive key events + // (regardless of focus policy) because this is how it works on other + // platforms (and in the carbon port): + if (!qApp->focusWidget()) + [windowRef makeFirstResponder:nsview]; if (topExtra->posFromMove) { updateFrameStrut(); -- cgit v0.12 From 1b687d41ecf6b129982318632398526525f882b0 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Mon, 31 May 2010 14:03:00 +0200 Subject: Add some convenience functions for QStringRef QStringRef was hard to use for a lot of real-world tasks since it lacked methods similar to the ones in QString for indexOf/lastIndexOf/contains/startsWith/endsWith This patch adds that functionality. I also copied the relevant test cases from QString for the new APIs and introduced a QStringRef test. Merge-request: 625 Reviewed-by: Olivier Goffart Reviewed-by: ossi --- src/corelib/tools/qstring.cpp | 869 ++++++++++++++++++++---- src/corelib/tools/qstring.h | 46 ++ tests/auto/corelib.pro | 1 + tests/auto/qstring/tst_qstring.cpp | 74 ++- tests/auto/qstringref/qstringref.pro | 4 + tests/auto/qstringref/tst_qstringref.cpp | 1058 ++++++++++++++++++++++++++++++ 6 files changed, 1931 insertions(+), 121 deletions(-) create mode 100644 tests/auto/qstringref/qstringref.pro create mode 100644 tests/auto/qstringref/tst_qstringref.cpp diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 6acbcec..e1167fa 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -107,7 +107,23 @@ int qFindString(const QChar *haystack, int haystackLen, int from, const QChar *needle, int needleLen, Qt::CaseSensitivity cs); int qFindStringBoyerMoore(const QChar *haystack, int haystackLen, int from, const QChar *needle, int needleLen, Qt::CaseSensitivity cs); - +static inline int qt_last_index_of(const QChar *haystack, int haystackLen, const QChar &needle, + int from, Qt::CaseSensitivity cs); +static inline int qt_string_count(const QChar *haystack, int haystackLen, + const QChar *needle, int needleLen, + Qt::CaseSensitivity cs); +static inline int qt_string_count(const QChar *haystack, int haystackLen, + const QChar &needle, Qt::CaseSensitivity cs); +static inline int qt_find_latin1_string(const QChar *hay, int size, const QLatin1String &needle, + int from, Qt::CaseSensitivity cs); +static inline bool qt_starts_with(const QChar *haystack, int haystackLen, + const QChar *needle, int needleLen, Qt::CaseSensitivity cs); +static inline bool qt_starts_with(const QChar *haystack, int haystackLen, + const QLatin1String &needle, Qt::CaseSensitivity cs); +static inline bool qt_ends_with(const QChar *haystack, int haystackLen, + const QChar *needle, int needleLen, Qt::CaseSensitivity cs); +static inline bool qt_ends_with(const QChar *haystack, int haystackLen, + const QLatin1String &needle, Qt::CaseSensitivity cs); // Unicode case-insensitive comparison static int ucstricmp(const ushort *a, const ushort *ae, const ushort *b, const ushort *be) @@ -2446,14 +2462,10 @@ int QString::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const \sa lastIndexOf(), contains(), count() */ + int QString::indexOf(const QLatin1String &str, int from, Qt::CaseSensitivity cs) const { - int len = qstrlen(str.latin1()); - QVarLengthArray s(len); - for (int i = 0; i < len; ++i) - s[i] = str.latin1()[i]; - - return qFindString(unicode(), length(), from, (const QChar *)s.data(), len, cs); + return qt_find_latin1_string(unicode(), size(), str, from, cs); } int qFindString( @@ -2543,6 +2555,23 @@ int QString::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const return findChar(unicode(), length(), ch, from, cs); } +/*! + \since 4.8 + + \overload indexOf() + + Returns the index position of the first occurrence of the string + reference \a str in this string, searching forward from index + position \a from. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. +*/ +int QString::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const +{ + return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); +} + static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *needle, int sl, Qt::CaseSensitivity cs) { /* @@ -2622,12 +2651,13 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c if (from > delta) from = delta; - return lastIndexOfHelper(d->data, from, str.d->data, str.d->size, cs); } /*! \since 4.5 + \overload lastIndexOf() + Returns the index position of the last occurrence of the string \a str in this string, searching backward from index position \a from. If \a from is -1 (default), the search starts at the last @@ -2675,26 +2705,43 @@ int QString::lastIndexOf(const QLatin1String &str, int from, Qt::CaseSensitivity */ int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const { - ushort c = ch.unicode(); - if (from < 0) - from += d->size; - if (from < 0 || from >= d->size) - return -1; - if (from >= 0) { - const ushort *n = d->data + from; - const ushort *b = d->data; - if (cs == Qt::CaseSensitive) { - for (; n >= b; --n) - if (*n == c) - return n - b; - } else { - c = foldCase(c); - for (; n >= b; --n) - if (foldCase(*n) == c) - return n - b; - } + return qt_last_index_of(unicode(), size(), ch, from, cs); } + +/*! + \since 4.8 + \overload lastIndexOf() + + Returns the index position of the last occurrence of the string + reference \a str in this string, searching backward from index + position \a from. If \a from is -1 (default), the search starts at + the last character; if \a from is -2, at the next to last character + and so on. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa indexOf(), contains(), count() +*/ +int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const +{ + const int sl = str.size(); + if (sl == 1) + return lastIndexOf(str.at(0), from, cs); + + const int l = d->size; + if (from < 0) + from += l; + int delta = l - sl; + if (from == l && sl == 0) + return from; + if (from < 0 || from >= l || delta < 0) return -1; + if (from > delta) + from = delta; + + return lastIndexOfHelper(d->data, from, reinterpret_cast(str.unicode()), + str.size(), cs); } #ifndef QT_NO_REGEXP @@ -2869,19 +2916,10 @@ QString& QString::replace(const QRegExp &rx, const QString &after) \sa contains(), indexOf() */ + int QString::count(const QString &str, Qt::CaseSensitivity cs) const { - int num = 0; - int i = -1; - if (d->size > 500 && str.d->size > 5) { - QStringMatcher matcher(str, cs); - while ((i = matcher.indexIn(*this, i + 1)) != -1) - ++num; - } else { - while ((i = indexOf(str, i + 1, cs)) != -1) - ++num; - } - return num; + return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); } /*! @@ -2889,25 +2927,29 @@ int QString::count(const QString &str, Qt::CaseSensitivity cs) const Returns the number of occurrences of character \a ch in the string. */ + int QString::count(QChar ch, Qt::CaseSensitivity cs) const { - ushort c = ch.unicode(); - int num = 0; - const ushort *i = d->data + d->size; - const ushort *b = d->data; - if (cs == Qt::CaseSensitive) { - while (i != b) - if (*--i == c) - ++num; - } else { - c = foldCase(c); - while (i != b) - if (foldCase(*(--i)) == c) - ++num; + return qt_string_count(unicode(), size(), ch, cs); } - return num; + +/*! + \since 4.8 + \overload count() + Returns the number of (potentially overlapping) occurrences of the + string reference \a str in this string. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa contains(), indexOf() +*/ +int QString::count(const QStringRef &str, Qt::CaseSensitivity cs) const +{ + return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); } + /*! \fn bool QString::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Returns true if this string contains an occurrence of the string @@ -2930,6 +2972,18 @@ int QString::count(QChar ch, Qt::CaseSensitivity cs) const character \a ch; otherwise returns false. */ +/*! \fn bool QString::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const + \since 4.8 + + Returns true if this string contains an occurrence of the string + reference \a str; otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa indexOf(), count() +*/ + /*! \fn bool QString::contains(const QRegExp &rx) const \overload contains() @@ -3331,22 +3385,8 @@ QString QString::mid(int position, int n) const */ bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const { - if (d == &shared_null) - return (s.d == &shared_null); - if (d->size == 0) - return s.d->size == 0; - if (s.d->size > d->size) - return false; - if (cs == Qt::CaseSensitive) { - return qMemEquals(d->data, s.d->data, s.d->size); - } else { - uint last = 0; - uint olast = 0; - for (int i = 0; i < s.d->size; ++i) - if (foldCase(d->data[i], last) != foldCase(s.d->data[i], olast)) - return false; - } - return true; + return qt_starts_with(isNull() ? 0 : unicode(), size(), + s.isNull() ? 0 : s.unicode(), s.size(), cs); } /*! @@ -3354,24 +3394,7 @@ bool QString::startsWith(const QString& s, Qt::CaseSensitivity cs) const */ bool QString::startsWith(const QLatin1String& s, Qt::CaseSensitivity cs) const { - if (d == &shared_null) - return (s.latin1() == 0); - if (d->size == 0) - return !s.latin1() || *s.latin1() == 0; - int slen = qstrlen(s.latin1()); - if (slen > d->size) - return false; - const uchar *latin = (const uchar *)s.latin1(); - if (cs == Qt::CaseSensitive) { - for (int i = 0; i < slen; ++i) - if (d->data[i] != latin[i]) - return false; - } else { - for (int i = 0; i < slen; ++i) - if (foldCase(d->data[i]) != foldCase((ushort)latin[i])) - return false; - } - return true; + return qt_starts_with(isNull() ? 0 : unicode(), size(), s, cs); } /*! @@ -3389,6 +3412,23 @@ bool QString::startsWith(const QChar &c, Qt::CaseSensitivity cs) const } /*! + \since 4.8 + \overload + Returns true if the string starts with the string reference \a s; + otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa endsWith() +*/ +bool QString::startsWith(const QStringRef &s, Qt::CaseSensitivity cs) const +{ + return qt_starts_with(isNull() ? 0 : unicode(), size(), + s.isNull() ? 0 : s.unicode(), s.size(), cs); +} + +/*! Returns true if the string ends with \a s; otherwise returns false. @@ -3401,49 +3441,34 @@ bool QString::startsWith(const QChar &c, Qt::CaseSensitivity cs) const */ bool QString::endsWith(const QString& s, Qt::CaseSensitivity cs) const { - if (d == &shared_null) - return (s.d == &shared_null); - if (d->size == 0) - return s.d->size == 0; - int pos = d->size - s.d->size; - if (pos < 0) - return false; - if (cs == Qt::CaseSensitive) { - return qMemEquals(d->data + pos, s.d->data, s.d->size); - } else { - uint last = 0; - uint olast = 0; - for (int i = 0; i < s.length(); i++) - if (foldCase(d->data[pos+i], last) != foldCase(s.d->data[i], olast)) - return false; + return qt_ends_with(isNull() ? 0 : unicode(), size(), + s.isNull() ? 0 : s.unicode(), s.size(), cs); } - return true; + +/*! + \since 4.8 + \overload endsWith() + Returns true if the string ends with the string reference \a s; + otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa startsWith() +*/ +bool QString::endsWith(const QStringRef &s, Qt::CaseSensitivity cs) const +{ + return qt_ends_with(isNull() ? 0 : unicode(), size(), + s.isNull() ? 0 : s.unicode(), s.size(), cs); } + /*! \overload endsWith() */ bool QString::endsWith(const QLatin1String& s, Qt::CaseSensitivity cs) const { - if (d == &shared_null) - return (s.latin1() == 0); - if (d->size == 0) - return !s.latin1() || *s.latin1() == 0; - int slen = qstrlen(s.latin1()); - int pos = d->size - slen; - const uchar *latin = (const uchar *)s.latin1(); - if (pos < 0) - return false; - if (cs == Qt::CaseSensitive) { - for (int i = 0; i < slen; i++) - if (d->data[pos+i] != latin[i]) - return false; - } else { - for (int i = 0; i < slen; i++) - if (foldCase(d->data[pos+i]) != foldCase((ushort)latin[i])) - return false; - } - return true; + return qt_ends_with(isNull() ? 0 : unicode(), size(), s, cs); } /*! @@ -7613,6 +7638,7 @@ QDataStream &operator>>(QDataStream &in, QString &str) Use the startsWith(QString, Qt::CaseSensitive) overload instead. */ + /*! \fn bool QString::endsWith(const QString &s, bool cs) const @@ -8318,4 +8344,607 @@ QStringRef QString::midRef(int position, int n) const return QStringRef(this, position, n); } +/*! + \since 4.8 + + Returns the index position of the first occurrence of the string \a + str in this string reference, searching forward from index position + \a from. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + If \a from is -1, the search starts at the last character; if it is + -2, at the next to last character and so on. + + \sa QString::indexOf(), lastIndexOf(), contains(), count() +*/ +int QStringRef::indexOf(const QString &str, int from, Qt::CaseSensitivity cs) const +{ + return qFindString(unicode(), length(), from, str.unicode(), str.length(), cs); +} + +/*! + \since 4.8 + \overload indexOf() + + Returns the index position of the first occurrence of the + character \a ch in the string reference, searching forward from + index position \a from. Returns -1 if \a ch could not be found. + + \sa QString::indexOf(), lastIndexOf(), contains(), count() +*/ +int QStringRef::indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const +{ + return findChar(unicode(), length(), ch, from, cs); +} + +/*! + \since 4.8 + + Returns the index position of the first occurrence of the string \a + str in this string reference, searching forward from index position + \a from. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + If \a from is -1, the search starts at the last character; if it is + -2, at the next to last character and so on. + + \sa QString::indexOf(), lastIndexOf(), contains(), count() +*/ +int QStringRef::indexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const +{ + return qt_find_latin1_string(unicode(), size(), str, from, cs); +} + +/*! + \since 4.8 + + \overload indexOf() + + Returns the index position of the first occurrence of the string + reference \a str in this string reference, searching forward from + index position \a from. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::indexOf(), lastIndexOf(), contains(), count() +*/ +int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const +{ + return qFindString(unicode(), size(), from, str.unicode(), str.size(), cs); +} + +/*! + \since 4.8 + + Returns the index position of the last occurrence of the string \a + str in this string reference, searching backward from index position + \a from. If \a from is -1 (default), the search starts at the last + character; if \a from is -2, at the next to last character and so + on. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::lastIndexOf(), indexOf(), contains(), count() +*/ +int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const +{ + const int sl = str.size(); + if (sl == 1) + return lastIndexOf(str.at(0), from, cs); + + const int l = size();; + if (from < 0) + from += l; + int delta = l - sl; + if (from == l && sl == 0) + return from; + if (from < 0 || from >= l || delta < 0) + return -1; + if (from > delta) + from = delta; + + return lastIndexOfHelper(reinterpret_cast(unicode()), from, + reinterpret_cast(str.unicode()), str.size(), cs); +} + +/*! + \since 4.8 + \overload lastIndexOf() + + Returns the index position of the last occurrence of the character + \a ch, searching backward from position \a from. + + \sa QString::lastIndexOf(), indexOf(), contains(), count() +*/ +int QStringRef::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const +{ + return qt_last_index_of(unicode(), size(), ch, from, cs); +} + +/*! + \since 4.8 + \overload lastIndexOf() + + Returns the index position of the last occurrence of the string \a + str in this string reference, searching backward from index position + \a from. If \a from is -1 (default), the search starts at the last + character; if \a from is -2, at the next to last character and so + on. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::lastIndexOf(), indexOf(), contains(), count() +*/ +int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const +{ + const int sl = qstrlen(str.latin1()); + if (sl == 1) + return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs); + + const int l = size(); + if (from < 0) + from += l; + int delta = l - sl; + if (from == l && sl == 0) + return from; + if (from < 0 || from >= l || delta < 0) + return -1; + if (from > delta) + from = delta; + + QVarLengthArray s(sl); + for (int i = 0; i < sl; ++i) + s[i] = str.latin1()[i]; + + return lastIndexOfHelper(reinterpret_cast(unicode()), from, s.data(), sl, cs); +} + +/*! + \since 4.8 + \overload lastIndexOf() + + Returns the index position of the last occurrence of the string + reference \a str in this string reference, searching backward from + index position \a from. If \a from is -1 (default), the search + starts at the last character; if \a from is -2, at the next to last + character and so on. Returns -1 if \a str is not found. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::lastIndexOf(), indexOf(), contains(), count() +*/ +int QStringRef::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const +{ + const int sl = str.size(); + if (sl == 1) + return lastIndexOf(str.at(0), from, cs); + + const int l = size(); + if (from < 0) + from += l; + int delta = l - sl; + if (from == l && sl == 0) + return from; + if (from < 0 || from >= l || delta < 0) + return -1; + if (from > delta) + from = delta; + + return lastIndexOfHelper(reinterpret_cast(unicode()), from, + reinterpret_cast(str.unicode()), + str.size(), cs); +} + +/*! + \since 4.8 + Returns the number of (potentially overlapping) occurrences of + the string \a str in this string reference. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa QString::count(), contains(), indexOf() +*/ +int QStringRef::count(const QString &str, Qt::CaseSensitivity cs) const +{ + return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); +} + +/*! + \since 4.8 + \overload count() + + Returns the number of occurrences of the character \a ch in the + string reference. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa QString::count(), contains(), indexOf() +*/ +int QStringRef::count(QChar ch, Qt::CaseSensitivity cs) const +{ + return qt_string_count(unicode(), size(), ch, cs); +} + +/*! + \since 4.8 + \overload count() + + Returns the number of (potentially overlapping) occurrences of the + string reference \a str in this string reference. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa QString::count(), contains(), indexOf() +*/ +int QStringRef::count(const QStringRef &str, Qt::CaseSensitivity cs) const +{ + return qt_string_count(unicode(), size(), str.unicode(), str.size(), cs); +} + +/*! + \since 4.8 + + Returns true if the string reference starts with \a str; otherwise + returns false. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa QString::startsWith(), endsWith() +*/ +bool QStringRef::startsWith(const QString &str, Qt::CaseSensitivity cs) const +{ + return qt_starts_with(isNull() ? 0 : unicode(), size(), + str.isNull() ? 0 : str.unicode(), str.size(), cs); +} + +/*! + \since 4.8 + \overload startsWith() + \sa QString::startsWith(), endsWith() +*/ +bool QStringRef::startsWith(QLatin1String str, Qt::CaseSensitivity cs) const +{ + return qt_starts_with(isNull() ? 0 : unicode(), size(), str, cs); +} + +/*! + \since 4.8 + \overload startsWith() + \sa QString::startsWith(), endsWith() +*/ +bool QStringRef::startsWith(const QStringRef &str, Qt::CaseSensitivity cs) const +{ + return qt_starts_with(isNull() ? 0 : unicode(), size(), + str.isNull() ? 0 : str.unicode(), str.size(), cs); +} + +/*! + \since 4.8 + \overload startsWith() + + Returns true if the string reference starts with \a ch; otherwise + returns false. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::startsWith(), endsWith() +*/ +bool QStringRef::startsWith(QChar ch, Qt::CaseSensitivity cs) const +{ + if (!isEmpty()) { + const ushort *data = reinterpret_cast(unicode()); + return (cs == Qt::CaseSensitive + ? data[0] == ch + : foldCase(data[0]) == foldCase(ch.unicode())); + } else { + return false; + } +} + +/*! + \since 4.8 + Returns true if the string reference ends with \a str; otherwise + returns false. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::endsWith(), startsWith() +*/ +bool QStringRef::endsWith(const QString &str, Qt::CaseSensitivity cs) const +{ + return qt_ends_with(isNull() ? 0 : unicode(), size(), + str.isNull() ? 0 : str.unicode(), str.size(), cs); +} + +/*! + \since 4.8 + \overload endsWith() + + Returns true if the string reference ends with \a ch; otherwise + returns false. + + If \a cs is Qt::CaseSensitive (default), the search is case + sensitive; otherwise the search is case insensitive. + + \sa QString::endsWith(), endsWith() +*/ +bool QStringRef::endsWith(QChar ch, Qt::CaseSensitivity cs) const +{ + if (!isEmpty()) { + const ushort *data = reinterpret_cast(unicode()); + const int size = length(); + return (cs == Qt::CaseSensitive + ? data[size - 1] == ch + : foldCase(data[size - 1]) == foldCase(ch.unicode())); + } else { + return false; + } +} + +/*! + \since 4.8 + \overload endsWith() + \sa QString::endsWith(), endsWith() +*/ +bool QStringRef::endsWith(QLatin1String str, Qt::CaseSensitivity cs) const +{ + return qt_ends_with(isNull() ? 0 : unicode(), size(), str, cs); +} + +/*! + \since 4.8 + \overload endsWith() + \sa QString::endsWith(), endsWith() +*/ +bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs) const +{ + return qt_ends_with(isNull() ? 0 : unicode(), size(), + str.isNull() ? 0 : str.unicode(), str.size(), cs); +} + + +/*! \fn bool QStringRef::contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const + + \since 4.8 + Returns true if this string reference contains an occurrence of + the string \a str; otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa indexOf(), count() +*/ + +/*! \fn bool QStringRef::contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const + + \overload contains() + \since 4.8 + + Returns true if this string contains an occurrence of the + character \a ch; otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + +*/ + +/*! \fn bool QStringRef::contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const + \overload contains() + \since 4.8 + + Returns true if this string reference contains an occurrence of + the string reference \a str; otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa indexOf(), count() +*/ + +/*! \fn bool QStringRef::contains(QLatin1String str, Qt::CaseSensitivity cs) const + \since 4,8 + \overload contains() + + Returns true if this string reference contains an occurrence of + the string \a str; otherwise returns false. + + If \a cs is Qt::CaseSensitive (default), the search is + case sensitive; otherwise the search is case insensitive. + + \sa indexOf(), count() +*/ + +static inline int qt_last_index_of(const QChar *haystack, int haystackLen, const QChar &needle, + int from, Qt::CaseSensitivity cs) +{ + ushort c = needle.unicode(); + if (from < 0) + from += haystackLen; + if (from < 0 || from >= haystackLen) + return -1; + if (from >= 0) { + const ushort *b = reinterpret_cast(haystack); + const ushort *n = b + from; + if (cs == Qt::CaseSensitive) { + for (; n >= b; --n) + if (*n == c) + return n - b; + } else { + c = foldCase(c); + for (; n >= b; --n) + if (foldCase(*n) == c) + return n - b; + } + } + return -1; + + +} + +static inline int qt_string_count(const QChar *haystack, int haystackLen, + const QChar *needle, int needleLen, + Qt::CaseSensitivity cs) +{ + int num = 0; + int i = -1; + if (haystackLen > 500 && needleLen > 5) { + QStringMatcher matcher(needle, needleLen, cs); + while ((i = matcher.indexIn(haystack, haystackLen, i + 1)) != -1) + ++num; + } else { + while ((i = qFindString(haystack, haystackLen, i + 1, needle, needleLen, cs)) != -1) + ++num; + } + return num; +} + +static inline int qt_string_count(const QChar *unicode, int size, const QChar &ch, + Qt::CaseSensitivity cs) +{ + ushort c = ch.unicode(); + int num = 0; + const ushort *b = reinterpret_cast(unicode); + const ushort *i = b + size; + if (cs == Qt::CaseSensitive) { + while (i != b) + if (*--i == c) + ++num; + } else { + c = foldCase(c); + while (i != b) + if (foldCase(*(--i)) == c) + ++num; + } + return num; +} + +static inline int qt_find_latin1_string(const QChar *haystack, int size, + const QLatin1String &needle, + int from, Qt::CaseSensitivity cs) +{ + const char *latin1 = needle.latin1(); + int len = qstrlen(latin1); + QVarLengthArray s(len); + for (int i = 0; i < len; ++i) + s[i] = latin1[i]; + + return qFindString(haystack, size, from, + reinterpret_cast(s.constData()), len, cs); +} + +static inline bool qt_starts_with(const QChar *haystack, int haystackLen, + const QChar *needle, int needleLen, Qt::CaseSensitivity cs) +{ + if (!haystack) + return !needle; + if (haystackLen == 0) + return needleLen == 0; + if (needleLen > haystackLen) + return false; + + const ushort *h = reinterpret_cast(haystack); + const ushort *n = reinterpret_cast(needle); + + if (cs == Qt::CaseSensitive) { + return qMemEquals(h, n, needleLen); + } else { + uint last = 0; + uint olast = 0; + for (int i = 0; i < needleLen; ++i) + if (foldCase(h[i], last) != foldCase(n[i], olast)) + return false; + } + return true; +} + +static inline bool qt_starts_with(const QChar *haystack, int haystackLen, + const QLatin1String &needle, Qt::CaseSensitivity cs) +{ + if (!haystack) + return !needle.latin1(); + if (haystackLen == 0) + return !needle.latin1() || *needle.latin1() == 0; + const int slen = qstrlen(needle.latin1()); + if (slen > haystackLen) + return false; + const ushort *data = reinterpret_cast(haystack); + const uchar *latin = reinterpret_cast(needle.latin1()); + if (cs == Qt::CaseSensitive) { + for (int i = 0; i < slen; ++i) + if (data[i] != latin[i]) + return false; + } else { + for (int i = 0; i < slen; ++i) + if (foldCase(data[i]) != foldCase((ushort)latin[i])) + return false; + } + return true; +} + +static inline bool qt_ends_with(const QChar *haystack, int haystackLen, + const QChar *needle, int needleLen, Qt::CaseSensitivity cs) +{ + if (!haystack) + return !needle; + if (haystackLen == 0) + return needleLen == 0; + const int pos = haystackLen - needleLen; + if (pos < 0) + return false; + + const ushort *h = reinterpret_cast(haystack); + const ushort *n = reinterpret_cast(needle); + + if (cs == Qt::CaseSensitive) { + return qMemEquals(h + pos, n, needleLen); + } else { + uint last = 0; + uint olast = 0; + for (int i = 0; i < needleLen; i++) + if (foldCase(h[pos+i], last) != foldCase(n[i], olast)) + return false; + } + return true; +} + + +static inline bool qt_ends_with(const QChar *haystack, int haystackLen, + const QLatin1String &needle, Qt::CaseSensitivity cs) +{ + if (!haystack) + return !needle.latin1(); + if (haystackLen == 0) + return !needle.latin1() || *needle.latin1() == 0; + const int slen = qstrlen(needle.latin1()); + int pos = haystackLen - slen; + if (pos < 0) + return false; + const uchar *latin = reinterpret_cast(needle.latin1()); + const ushort *data = reinterpret_cast(haystack); + if (cs == Qt::CaseSensitive) { + for (int i = 0; i < slen; i++) + if (data[pos+i] != latin[i]) + return false; + } else { + for (int i = 0; i < slen; i++) + if (foldCase(data[pos+i]) != foldCase((ushort)latin[i])) + return false; + } + return true; +} + QT_END_NAMESPACE diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index a1c4e77..ed87acf 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -198,14 +198,18 @@ public: int indexOf(QChar c, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int indexOf(const QString &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int indexOf(const QLatin1String &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int indexOf(const QStringRef &s, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int lastIndexOf(QChar c, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int lastIndexOf(const QString &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int lastIndexOf(const QLatin1String &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int lastIndexOf(const QStringRef &s, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; inline QBool contains(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; inline QBool contains(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline QBool contains(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; #ifndef QT_NO_REGEXP int indexOf(const QRegExp &, int from = 0) const; @@ -241,9 +245,11 @@ public: QStringRef midRef(int position, int n = -1) const Q_REQUIRED_RESULT; bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool startsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool startsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool endsWith(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(const QLatin1String &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; bool endsWith(const QChar &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; @@ -901,6 +907,8 @@ inline QString::const_iterator QString::constEnd() const { return reinterpret_cast(d->data + d->size); } inline QBool QString::contains(const QString &s, Qt::CaseSensitivity cs) const { return QBool(indexOf(s, 0, cs) != -1); } +inline QBool QString::contains(const QStringRef &s, Qt::CaseSensitivity cs) const +{ return QBool(indexOf(s, 0, cs) != -1); } inline QBool QString::contains(QChar c, Qt::CaseSensitivity cs) const { return QBool(indexOf(c, 0, cs) != -1); } @@ -1122,6 +1130,34 @@ public: m_size = other.m_size; return *this; } + int indexOf(const QString &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int indexOf(QChar ch, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int indexOf(QLatin1String str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int indexOf(const QStringRef &str, int from = 0, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int lastIndexOf(const QString &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int lastIndexOf(QChar ch, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int lastIndexOf(QLatin1String str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int lastIndexOf(const QStringRef &str, int from = -1, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + + inline QBool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline QBool contains(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline QBool contains(QLatin1String str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline QBool contains(const QStringRef &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + + int count(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + + bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool startsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + + bool endsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool endsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool endsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + bool endsWith(const QStringRef &c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const; + inline QStringRef &operator=(const QString *string); inline const QChar *unicode() const { @@ -1240,6 +1276,16 @@ inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QString &s inline int QStringRef::localeAwareCompare(const QStringRef &s1, const QStringRef &s2) { return QString::localeAwareCompare_helper(s1.constData(), s1.length(), s2.constData(), s2.length()); } +inline QBool QStringRef::contains(const QString &s, Qt::CaseSensitivity cs) const +{ return QBool(indexOf(s, 0, cs) != -1); } +inline QBool QStringRef::contains(QLatin1String s, Qt::CaseSensitivity cs) const +{ return QBool(indexOf(s, 0, cs) != -1); } +inline QBool QStringRef::contains(QChar c, Qt::CaseSensitivity cs) const +{ return QBool(indexOf(c, 0, cs) != -1); } +inline QBool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) const +{ return QBool(indexOf(s, 0, cs) != -1); } + + QT_END_NAMESPACE diff --git a/tests/auto/corelib.pro b/tests/auto/corelib.pro index 259be4c..a7ab54d 100644 --- a/tests/auto/corelib.pro +++ b/tests/auto/corelib.pro @@ -75,6 +75,7 @@ SUBDIRS=\ qstringbuilder4 \ qstringlist \ qstringmatcher \ + qstringref \ qtconcurrentfilter \ qtconcurrentiteratekernel \ qtconcurrentmap \ diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index 1bea4b7..eb2d5f1 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -57,6 +57,10 @@ Q_DECLARE_METATYPE(qlonglong) //TESTED_CLASS= //TESTED_FILES= +#define CREATE_REF(string) \ + const QString padded = QString::fromLatin1(" %1 ").arg(string); \ + QStringRef ref = padded.midRef(1, padded.size() - 2); + class tst_QString : public QObject { Q_OBJECT @@ -135,6 +139,7 @@ private slots: void leftRef(); void stringRef(); void contains(); + void count(); void lastIndexOf_data(); void lastIndexOf(); void indexOf_data(); @@ -1063,12 +1068,14 @@ void tst_QString::indexOf() QFETCH( int, startpos ); QFETCH( bool, bcs ); QFETCH( int, resultpos ); + CREATE_REF(needle); Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive; bool needleIsLatin = (QString::fromLatin1(needle.toLatin1()) == needle); QCOMPARE( haystack.indexOf(needle, startpos, cs), resultpos ); + QCOMPARE( haystack.indexOf(ref, startpos, cs), resultpos ); if (needleIsLatin) { QCOMPARE( haystack.indexOf(needle.toLatin1(), startpos, cs), resultpos ); QCOMPARE( haystack.indexOf(needle.toLatin1().data(), startpos, cs), resultpos ); @@ -1096,12 +1103,14 @@ void tst_QString::indexOf() if (cs == Qt::CaseSensitive) { QCOMPARE( haystack.indexOf(needle, startpos), resultpos ); + QCOMPARE( haystack.indexOf(ref, startpos), resultpos ); if (needleIsLatin) { QCOMPARE( haystack.indexOf(needle.toLatin1(), startpos), resultpos ); QCOMPARE( haystack.indexOf(needle.toLatin1().data(), startpos), resultpos ); } if (startpos == 0) { QCOMPARE( haystack.indexOf(needle), resultpos ); + QCOMPARE( haystack.indexOf(ref), resultpos ); if (needleIsLatin) { QCOMPARE( haystack.indexOf(needle.toLatin1()), resultpos ); QCOMPARE( haystack.indexOf(needle.toLatin1().data()), resultpos ); @@ -1110,6 +1119,7 @@ void tst_QString::indexOf() } if (needle.size() == 1) { QCOMPARE(haystack.indexOf(needle.at(0), startpos, cs), resultpos); + QCOMPARE(haystack.indexOf(ref.at(0), startpos, cs), resultpos); } } @@ -1170,14 +1180,17 @@ void tst_QString::indexOf2() QFETCH( QString, haystack ); QFETCH( QString, needle ); QFETCH( int, resultpos ); + CREATE_REF(needle); QByteArray chaystack = haystack.toLatin1(); QByteArray cneedle = needle.toLatin1(); int got; QCOMPARE( haystack.indexOf(needle, 0, Qt::CaseSensitive), resultpos ); + QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseSensitive), resultpos ); QCOMPARE( QStringMatcher(needle, Qt::CaseSensitive).indexIn(haystack, 0), resultpos ); QCOMPARE( haystack.indexOf(needle, 0, Qt::CaseInsensitive), resultpos ); + QCOMPARE( haystack.indexOf(ref, 0, Qt::CaseInsensitive), resultpos ); QCOMPARE( QStringMatcher(needle, Qt::CaseInsensitive).indexIn(haystack, 0), resultpos ); if ( needle.length() > 0 ) { got = haystack.lastIndexOf( needle, -1, Qt::CaseSensitive ); @@ -1244,10 +1257,12 @@ void tst_QString::lastIndexOf() QFETCH(int, from); QFETCH(int, expected); QFETCH(bool, caseSensitive); + CREATE_REF(needle); Qt::CaseSensitivity cs = (caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); QCOMPARE(haystack.lastIndexOf(needle, from, cs), expected); + QCOMPARE(haystack.lastIndexOf(ref, from, cs), expected); QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from, cs), expected); QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from, cs), expected); @@ -1277,20 +1292,23 @@ void tst_QString::lastIndexOf() if (cs == Qt::CaseSensitive) { QCOMPARE(haystack.lastIndexOf(needle, from), expected); + QCOMPARE(haystack.lastIndexOf(ref, from), expected); QCOMPARE(haystack.lastIndexOf(needle.toLatin1(), from), expected); QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data(), from), expected); if (from == -1) { QCOMPARE(haystack.lastIndexOf(needle), expected); + QCOMPARE(haystack.lastIndexOf(ref), expected); QCOMPARE(haystack.lastIndexOf(needle.toLatin1()), expected); QCOMPARE(haystack.lastIndexOf(needle.toLatin1().data()), expected); } } if (needle.size() == 1) { QCOMPARE(haystack.lastIndexOf(needle.at(0), from), expected); + QCOMPARE(haystack.lastIndexOf(ref.at(0), from), expected); } } -void tst_QString::contains() +void tst_QString::count() { QString a; a="ABCDEFGHIEfGEFG"; // 15 chars @@ -1305,8 +1323,42 @@ void tst_QString::contains() QCOMPARE(a.count( "", Qt::CaseInsensitive), 16); QCOMPARE(a.count(QRegExp("[FG][HI]")),1); QCOMPARE(a.count(QRegExp("[G][HE]")),2); + + CREATE_REF(QLatin1String("FG")); + QCOMPARE(a.count(ref),2); + QCOMPARE(a.count(ref,Qt::CaseInsensitive),3); + QCOMPARE(a.count( QStringRef(), Qt::CaseInsensitive), 16); + QStringRef emptyRef(&a, 0, 0); + QCOMPARE(a.count( emptyRef, Qt::CaseInsensitive), 16); + } +void tst_QString::contains() +{ + QString a; + a="ABCDEFGHIEfGEFG"; // 15 chars + QVERIFY(a.contains('A')); + QVERIFY(!a.contains('Z')); + QVERIFY(a.contains('E')); + QVERIFY(a.contains('F')); + QVERIFY(a.contains('F',Qt::CaseInsensitive)); + QVERIFY(a.contains("FG")); + QVERIFY(a.contains("FG",Qt::CaseInsensitive)); + QVERIFY(a.contains( QString(), Qt::CaseInsensitive)); + QVERIFY(a.contains( "", Qt::CaseInsensitive)); + QVERIFY(a.contains(QRegExp("[FG][HI]"))); + QVERIFY(a.contains(QRegExp("[G][HE]"))); + + CREATE_REF(QLatin1String("FG")); + QVERIFY(a.contains(ref)); + QVERIFY(a.contains(ref, Qt::CaseInsensitive)); + QVERIFY(a.contains( QStringRef(), Qt::CaseInsensitive)); + QStringRef emptyRef(&a, 0, 0); + QVERIFY(a.contains(emptyRef, Qt::CaseInsensitive)); + +} + + void tst_QString::left() { QString a; @@ -2827,6 +2879,14 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith(QChar(), Qt::CaseSensitive) ); QVERIFY( !a.startsWith(QLatin1Char(0), Qt::CaseSensitive) ); +#define TEST_REF_STARTS_WITH(string, yes) { CREATE_REF(string); QCOMPARE(a.startsWith(ref), yes); } + + TEST_REF_STARTS_WITH("A", true); + TEST_REF_STARTS_WITH("AB", true); + TEST_REF_STARTS_WITH("C", false); + TEST_REF_STARTS_WITH("ABCDEF", false); +#undef TEST_REF_STARTS_WITH + a = ""; QVERIFY( a.startsWith("") ); QVERIFY( a.startsWith(QString::null) ); @@ -2852,6 +2912,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith(QLatin1Char(0)) ); QVERIFY( !a.startsWith(QLatin1Char('x')) ); QVERIFY( !a.startsWith(QChar()) ); + } void tst_QString::endsWith() @@ -2919,6 +2980,17 @@ void tst_QString::endsWith() QVERIFY( !a.endsWith(QChar(), Qt::CaseSensitive) ); QVERIFY( !a.endsWith(QLatin1Char(0), Qt::CaseSensitive) ); + +#define TEST_REF_ENDS_WITH(string, yes) { CREATE_REF(string); QCOMPARE(a.endsWith(ref), yes); } + TEST_REF_ENDS_WITH(QLatin1String("B"), true); + TEST_REF_ENDS_WITH(QLatin1String("AB"), true); + TEST_REF_ENDS_WITH(QLatin1String("C"), false); + TEST_REF_ENDS_WITH(QLatin1String("ABCDEF"), false); + TEST_REF_ENDS_WITH(QLatin1String(""), true); + TEST_REF_ENDS_WITH(QLatin1String(0), true); + +#undef TEST_REF_STARTS_WITH + a = ""; QVERIFY( a.endsWith("") ); QVERIFY( a.endsWith(QString::null) ); diff --git a/tests/auto/qstringref/qstringref.pro b/tests/auto/qstringref/qstringref.pro new file mode 100644 index 0000000..48e7ddf --- /dev/null +++ b/tests/auto/qstringref/qstringref.pro @@ -0,0 +1,4 @@ +load(qttest_p4) +SOURCES += tst_qstringref.cpp + +QT = core diff --git a/tests/auto/qstringref/tst_qstringref.cpp b/tests/auto/qstringref/tst_qstringref.cpp new file mode 100644 index 0000000..1980901 --- /dev/null +++ b/tests/auto/qstringref/tst_qstringref.cpp @@ -0,0 +1,1058 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 + +Q_DECLARE_METATYPE(qlonglong) + +//TESTED_CLASS= +//TESTED_FILES= + + +class tst_QStringRef : public QObject +{ + Q_OBJECT + +public: + tst_QStringRef(); + virtual ~tst_QStringRef(); + + +public slots: + void init(); + void cleanup(); +private slots: + void endsWith(); + void startsWith(); + void contains(); + void count(); + void lastIndexOf_data(); + void lastIndexOf(); + void indexOf_data(); + void indexOf(); + void indexOf2_data(); + void indexOf2(); + void length_data(); + void length(); + void isEmpty(); + void compare_data(); + void compare(); + void operator_eqeq_nullstring(); + void localeAwareCompare_data(); + void localeAwareCompare(); +}; + +static QStringRef emptyRef() +{ + static const QString empty(""); + return empty.midRef(0); +} + +#define CREATE_REF(string) \ + const QString padded = QString::fromLatin1(" %1 ").arg(string); \ + QStringRef ref = padded.midRef(1, padded.size() - 2); + +typedef QList IntList; + +Q_DECLARE_METATYPE(QList) +Q_DECLARE_METATYPE(IntList) + +// This next bit is needed for the NAN and INF in string -> number conversion tests +#include +#include +#include +#if defined(Q_WS_WIN) +# include +// mingw defines NAN and INFINITY to 0/0 and x/0 +# if defined(Q_CC_GNU) +# undef NAN +# undef INFINITY +# else +# define isnan(d) _isnan(d) +# endif +#endif +#if defined(Q_OS_MAC) && !defined isnan +#define isnan(d) __isnand(d) +#endif +#if defined(Q_OS_SOLARIS) +# include +#endif +#if defined(Q_OS_OSF) && (defined(__DECC) || defined(__DECCXX)) +# define INFINITY DBL_INFINITY +# define NAN DBL_QNAN +#endif +#if defined(Q_OS_IRIX) && defined(Q_CC_GNU) +# include +# define isnan(d) isnand(d) +#endif + +enum { + LittleEndian, + BigEndian +#ifdef Q_BYTE_ORDER +# if Q_BYTE_ORDER == Q_BIG_ENDIAN + , ByteOrder = BigEndian +# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN + , ByteOrder = LittleEndian +# else +# error "undefined byte order" +# endif +}; +#else +}; +static const unsigned int one = 1; +static const bool ByteOrder = ((*((unsigned char *) &one) == 0) ? BigEndian : LittleEndian); +#endif +#if !defined(INFINITY) +static const unsigned char be_inf_bytes[] = { 0x7f, 0xf0, 0, 0, 0, 0, 0,0 }; +static const unsigned char le_inf_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f }; +static inline double inf() +{ + if (ByteOrder == BigEndian) + return *reinterpret_cast(be_inf_bytes); + return *reinterpret_cast(le_inf_bytes); +} +# define INFINITY (::inf()) +#endif +#if !defined(NAN) +static const unsigned char be_nan_bytes[] = { 0x7f, 0xf8, 0, 0, 0, 0, 0,0 }; +static const unsigned char le_nan_bytes[] = { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }; +static inline double nan() +{ + if (ByteOrder == BigEndian) + return *reinterpret_cast(be_nan_bytes); + return *reinterpret_cast(le_nan_bytes); +} +# define NAN(::nan()) +#endif + +tst_QStringRef::tst_QStringRef() +{ +} + +tst_QStringRef::~tst_QStringRef() +{ +} + +void tst_QStringRef::init() +{ +} + +void tst_QStringRef::cleanup() +{ + QLocale::setDefault(QString(QLatin1Char('C'))); +} + +void tst_QStringRef::length_data() +{ + QTest::addColumn("s1"); + QTest::addColumn("res"); + + QTest::newRow("data0") << QString("Test") << 4; + QTest::newRow("data1") << QString("The quick brown fox jumps over the lazy dog") << 43; + QTest::newRow("data2") << QString() << 0; + QTest::newRow("data3") << QString("A") << 1; + QTest::newRow("data4") << QString("AB") << 2; + QTest::newRow("data5") << QString("AB\n") << 3; + QTest::newRow("data6") << QString("AB\nC") << 4; + QTest::newRow("data7") << QString("\n") << 1; + QTest::newRow("data8") << QString("\nA") << 2; + QTest::newRow("data9") << QString("\nAB") << 3; + QTest::newRow("data10") << QString("\nAB\nCDE") << 7; + QTest::newRow("data11") << QString("shdnftrheid fhgnt gjvnfmd chfugkh bnfhg thgjf vnghturkf chfnguh bjgnfhvygh hnbhgutjfv dhdnjds dcjs d") << 100; + QTest::newRow("data12") << QString("") << 0; +} + + +void tst_QStringRef::length() +{ + QFETCH(QString, s1); + CREATE_REF(s1); + QTEST(ref.length(), "res"); +} + + +void tst_QStringRef::isEmpty() +{ + QStringRef a; + QVERIFY(a.isEmpty()); + QVERIFY(emptyRef().isEmpty()); + CREATE_REF("Not empty"); + QVERIFY(!ref.isEmpty()); +} + +void tst_QStringRef::indexOf_data() +{ + QTest::addColumn("haystack"); + QTest::addColumn("needle"); + QTest::addColumn("startpos"); + QTest::addColumn("bcs"); + QTest::addColumn("resultpos"); + + QTest::newRow("data0") << QString("abc") << QString("a") << 0 << true << 0; + QTest::newRow("data1") << QString("abc") << QString("a") << 0 << false << 0; + QTest::newRow("data2") << QString("abc") << QString("A") << 0 << true << -1; + QTest::newRow("data3") << QString("abc") << QString("A") << 0 << false << 0; + QTest::newRow("data4") << QString("abc") << QString("a") << 1 << true << -1; + QTest::newRow("data5") << QString("abc") << QString("a") << 1 << false << -1; + QTest::newRow("data6") << QString("abc") << QString("A") << 1 << true << -1; + QTest::newRow("data7") << QString("abc") << QString("A") << 1 << false << -1; + QTest::newRow("data8") << QString("abc") << QString("b") << 0 << true << 1; + QTest::newRow("data9") << QString("abc") << QString("b") << 0 << false << 1; + QTest::newRow("data10") << QString("abc") << QString("B") << 0 << true << -1; + QTest::newRow("data11") << QString("abc") << QString("B") << 0 << false << 1; + QTest::newRow("data12") << QString("abc") << QString("b") << 1 << true << 1; + QTest::newRow("data13") << QString("abc") << QString("b") << 1 << false << 1; + QTest::newRow("data14") << QString("abc") << QString("B") << 1 << true << -1; + QTest::newRow("data15") << QString("abc") << QString("B") << 1 << false << 1; + QTest::newRow("data16") << QString("abc") << QString("b") << 2 << true << -1; + QTest::newRow("data17") << QString("abc") << QString("b") << 2 << false << -1; + + QTest::newRow("data20") << QString("ABC") << QString("A") << 0 << true << 0; + QTest::newRow("data21") << QString("ABC") << QString("A") << 0 << false << 0; + QTest::newRow("data22") << QString("ABC") << QString("a") << 0 << true << -1; + QTest::newRow("data23") << QString("ABC") << QString("a") << 0 << false << 0; + QTest::newRow("data24") << QString("ABC") << QString("A") << 1 << true << -1; + QTest::newRow("data25") << QString("ABC") << QString("A") << 1 << false << -1; + QTest::newRow("data26") << QString("ABC") << QString("a") << 1 << true << -1; + QTest::newRow("data27") << QString("ABC") << QString("a") << 1 << false << -1; + QTest::newRow("data28") << QString("ABC") << QString("B") << 0 << true << 1; + QTest::newRow("data29") << QString("ABC") << QString("B") << 0 << false << 1; + QTest::newRow("data30") << QString("ABC") << QString("b") << 0 << true << -1; + QTest::newRow("data31") << QString("ABC") << QString("b") << 0 << false << 1; + QTest::newRow("data32") << QString("ABC") << QString("B") << 1 << true << 1; + QTest::newRow("data33") << QString("ABC") << QString("B") << 1 << false << 1; + QTest::newRow("data34") << QString("ABC") << QString("b") << 1 << true << -1; + QTest::newRow("data35") << QString("ABC") << QString("b") << 1 << false << 1; + QTest::newRow("data36") << QString("ABC") << QString("B") << 2 << true << -1; + QTest::newRow("data37") << QString("ABC") << QString("B") << 2 << false << -1; + + QTest::newRow("data40") << QString("aBc") << QString("bc") << 0 << true << -1; + QTest::newRow("data41") << QString("aBc") << QString("Bc") << 0 << true << 1; + QTest::newRow("data42") << QString("aBc") << QString("bC") << 0 << true << -1; + QTest::newRow("data43") << QString("aBc") << QString("BC") << 0 << true << -1; + QTest::newRow("data44") << QString("aBc") << QString("bc") << 0 << false << 1; + QTest::newRow("data45") << QString("aBc") << QString("Bc") << 0 << false << 1; + QTest::newRow("data46") << QString("aBc") << QString("bC") << 0 << false << 1; + QTest::newRow("data47") << QString("aBc") << QString("BC") << 0 << false << 1; + QTest::newRow("data48") << QString("AbC") << QString("bc") << 0 << true << -1; + QTest::newRow("data49") << QString("AbC") << QString("Bc") << 0 << true << -1; + QTest::newRow("data50") << QString("AbC") << QString("bC") << 0 << true << 1; + QTest::newRow("data51") << QString("AbC") << QString("BC") << 0 << true << -1; + QTest::newRow("data52") << QString("AbC") << QString("bc") << 0 << false << 1; + QTest::newRow("data53") << QString("AbC") << QString("Bc") << 0 << false << 1; + + QTest::newRow("data54") << QString("AbC") << QString("bC") << 0 << false << 1; + QTest::newRow("data55") << QString("AbC") << QString("BC") << 0 << false << 1; + QTest::newRow("data56") << QString("AbC") << QString("BC") << 1 << false << 1; + QTest::newRow("data57") << QString("AbC") << QString("BC") << 2 << false << -1; +#if 0 + QTest::newRow("null-in-null") << QString() << QString() << 0 << false << 0; + QTest::newRow("empty-in-null") << QString() << QString("") << 0 << false << 0; + QTest::newRow("null-in-empty") << QString("") << QString() << 0 << false << 0; + QTest::newRow("empty-in-empty") << QString("") << QString("") << 0 << false << 0; +#endif + + + QString s1 = "abc"; + s1 += QChar(0xb5); + QString s2; + s2 += QChar(0x3bc); + QTest::newRow("data58") << QString(s1) << QString(s2) << 0 << false << 3; + s2.prepend("C"); + QTest::newRow("data59") << QString(s1) << QString(s2) << 0 << false << 2; + + QString veryBigHaystack(500, 'a'); + veryBigHaystack += 'B'; + QTest::newRow("BoyerMooreStressTest") << veryBigHaystack << veryBigHaystack << 0 << true << 0; + QTest::newRow("BoyerMooreStressTest2") << veryBigHaystack + 'c' << veryBigHaystack << 0 << true << 0; + QTest::newRow("BoyerMooreStressTest3") << 'c' + veryBigHaystack << veryBigHaystack << 0 << true << 1; + QTest::newRow("BoyerMooreStressTest4") << veryBigHaystack << veryBigHaystack + 'c' << 0 << true << -1; + QTest::newRow("BoyerMooreStressTest5") << veryBigHaystack << 'c' + veryBigHaystack << 0 << true << -1; + QTest::newRow("BoyerMooreStressTest6") << 'd' + veryBigHaystack << 'c' + veryBigHaystack << 0 << true << -1; + QTest::newRow("BoyerMooreStressTest6") << veryBigHaystack + 'c' << 'c' + veryBigHaystack << 0 << true << -1; + + QTest::newRow("BoyerMooreInsensitiveStressTest") << veryBigHaystack << veryBigHaystack << 0 << false << 0; + +} + +void tst_QStringRef::indexOf() +{ + QFETCH(QString, haystack); + QFETCH(QString, needle); + QFETCH(int, startpos); + QFETCH(bool, bcs); + QFETCH(int, resultpos); + + const QString haystackPadded = QString::fromLatin1(" %1 ").arg(haystack); + const QString needlePadded = QString::fromLatin1(" %1 ").arg(needle); + const QStringRef haystackRef(&haystackPadded, 1, haystack.size()); + const QStringRef needleRef(&needlePadded, 1, needle.size()); + + Qt::CaseSensitivity cs = bcs ? Qt::CaseSensitive : Qt::CaseInsensitive; + + QCOMPARE(haystack.indexOf(needle, startpos, cs), resultpos); + QCOMPARE(haystackRef.indexOf(needle, startpos, cs), resultpos); + QCOMPARE(haystackRef.indexOf(needleRef, startpos, cs), resultpos); + QCOMPARE(haystack.indexOf(needleRef, startpos, cs), resultpos); + + if (cs == Qt::CaseSensitive) { + QCOMPARE(haystack.indexOf(needle, startpos), resultpos); + QCOMPARE(haystackRef.indexOf(needle, startpos), resultpos); + QCOMPARE(haystackRef.indexOf(needleRef, startpos), resultpos); + QCOMPARE(haystack.indexOf(needleRef, startpos), resultpos); + if (startpos == 0) { + QCOMPARE(haystack.indexOf(needle), resultpos); + QCOMPARE(haystackRef.indexOf(needle), resultpos); + QCOMPARE(haystackRef.indexOf(needleRef), resultpos); + QCOMPARE(haystack.indexOf(needleRef), resultpos); + } + } + if (needle.size() == 1) { + QCOMPARE(needle.at(0), needleRef.at(0)); + QCOMPARE(haystack.indexOf(needleRef.at(0), startpos, cs), resultpos); + QCOMPARE(haystackRef.indexOf(needle.at(0), startpos, cs), resultpos); + QCOMPARE(haystackRef.indexOf(needleRef.at(0), startpos, cs), resultpos); + QCOMPARE(haystack.indexOf(needleRef.at(0), startpos ,cs), resultpos); + } +} + +void tst_QStringRef::indexOf2_data() +{ + QTest::addColumn("haystack"); + QTest::addColumn("needle"); + QTest::addColumn("resultpos"); + + QTest::newRow("data0") << QString() << QString() << 0; + QTest::newRow("data1") << QString() << QString("") << 0; + QTest::newRow("data2") << QString("") << QString() << 0; + QTest::newRow("data3") << QString("") << QString("") << 0; + QTest::newRow("data4") << QString() << QString("a") << -1; + QTest::newRow("data5") << QString() << QString("abcdefg") << -1; + QTest::newRow("data6") << QString("") << QString("a") << -1; + QTest::newRow("data7") << QString("") << QString("abcdefg") << -1; + + QTest::newRow("data8") << QString("a") << QString() << 0; + QTest::newRow("data9") << QString("a") << QString("") << 0; + QTest::newRow("data10") << QString("a") << QString("a") << 0; + QTest::newRow("data11") << QString("a") << QString("b") << -1; + QTest::newRow("data12") << QString("a") << QString("abcdefg") << -1; + QTest::newRow("data13") << QString("ab") << QString() << 0; + QTest::newRow("data14") << QString("ab") << QString("") << 0; + QTest::newRow("data15") << QString("ab") << QString("a") << 0; + QTest::newRow("data16") << QString("ab") << QString("b") << 1; + QTest::newRow("data17") << QString("ab") << QString("ab") << 0; + QTest::newRow("data18") << QString("ab") << QString("bc") << -1; + QTest::newRow("data19") << QString("ab") << QString("abcdefg") << -1; + + QTest::newRow("data30") << QString("abc") << QString("a") << 0; + QTest::newRow("data31") << QString("abc") << QString("b") << 1; + QTest::newRow("data32") << QString("abc") << QString("c") << 2; + QTest::newRow("data33") << QString("abc") << QString("d") << -1; + QTest::newRow("data34") << QString("abc") << QString("ab") << 0; + QTest::newRow("data35") << QString("abc") << QString("bc") << 1; + QTest::newRow("data36") << QString("abc") << QString("cd") << -1; + QTest::newRow("data37") << QString("abc") << QString("ac") << -1; + + // sizeof(whale) > 32 + QString whale = "a5zby6cx7dw8evf9ug0th1si2rj3qkp4lomn"; + QString minnow = "zby"; + QTest::newRow("data40") << whale << minnow << 2; + QTest::newRow("data41") << (whale + whale) << minnow << 2; + QTest::newRow("data42") << (minnow + whale) << minnow << 0; + QTest::newRow("data43") << whale << whale << 0; + QTest::newRow("data44") << (whale + whale) << whale << 0; + QTest::newRow("data45") << whale << (whale + whale) << -1; + QTest::newRow("data46") << (whale + whale) << (whale + whale) << 0; + QTest::newRow("data47") << (whale + whale) << (whale + minnow) << -1; + QTest::newRow("data48") << (minnow + whale) << whale << (int)minnow.length(); +} + +void tst_QStringRef::indexOf2() +{ + QFETCH(QString, haystack); + QFETCH(QString, needle); + QFETCH(int, resultpos); + + const QString haystackPadded = QString::fromLatin1(" %1 ").arg(haystack); + const QString needlePadded = QString::fromLatin1(" %1 ").arg(needle); + const QStringRef haystackRef(&haystackPadded, 1, haystack.size()); + const QStringRef needleRef(&needlePadded, 1, needle.size()); + + + int got; + + QCOMPARE(haystack.indexOf(needleRef, 0, Qt::CaseSensitive), resultpos); + QCOMPARE(haystackRef.indexOf(needle, 0, Qt::CaseSensitive), resultpos); + QCOMPARE(haystackRef.indexOf(needleRef, 0, Qt::CaseSensitive), resultpos); + QCOMPARE(haystack.indexOf(needleRef, 0, Qt::CaseInsensitive), resultpos); + QCOMPARE(haystackRef.indexOf(needle, 0, Qt::CaseInsensitive), resultpos); + QCOMPARE(haystackRef.indexOf(needleRef, 0, Qt::CaseInsensitive), resultpos); + if (needle.length() > 0) { + got = haystackRef.lastIndexOf(needle, -1, Qt::CaseSensitive); + QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); + got = haystackRef.lastIndexOf(needle, -1, Qt::CaseInsensitive); + QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); + + got = haystack.lastIndexOf(needleRef, -1, Qt::CaseSensitive); + QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); + got = haystack.lastIndexOf(needleRef, -1, Qt::CaseInsensitive); + QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); + + got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseSensitive); + QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); + got = haystackRef.lastIndexOf(needleRef, -1, Qt::CaseInsensitive); + QVERIFY(got == resultpos || (resultpos >= 0 && got >= resultpos)); + } +} + +void tst_QStringRef::lastIndexOf_data() +{ + QTest::addColumn("haystack"); + QTest::addColumn("needle"); + QTest::addColumn("from"); + QTest::addColumn("expected"); + QTest::addColumn("caseSensitive"); + + QString a = "ABCDEFGHIEfGEFG"; + + QTest::newRow("-1") << a << "G" << a.size() - 1 << 14 << true; + QTest::newRow("1") << a << "G" << - 1 << 14 << true; + QTest::newRow("2") << a << "G" << -3 << 11 << true; + QTest::newRow("3") << a << "G" << -5 << 6 << true; + QTest::newRow("4") << a << "G" << 14 << 14 << true; + QTest::newRow("5") << a << "G" << 13 << 11 << true; + QTest::newRow("6") << a << "B" << a.size() - 1 << 1 << true; + QTest::newRow("6") << a << "B" << - 1 << 1 << true; + QTest::newRow("7") << a << "B" << 1 << 1 << true; + QTest::newRow("8") << a << "B" << 0 << -1 << true; + + QTest::newRow("9") << a << "G" << -1 << a.size()-1 << true; + QTest::newRow("10") << a << "G" << a.size()-1 << a.size()-1 << true; + QTest::newRow("11") << a << "G" << a.size() << -1 << true; + QTest::newRow("12") << a << "A" << 0 << 0 << true; + QTest::newRow("13") << a << "A" << -1*a.size() << 0 << true; + + QTest::newRow("15") << a << "efg" << 0 << -1 << false; + QTest::newRow("16") << a << "efg" << a.size() << -1 << false; + QTest::newRow("17") << a << "efg" << -1 * a.size() << -1 << false; + QTest::newRow("19") << a << "efg" << a.size() - 1 << 12 << false; + QTest::newRow("20") << a << "efg" << 12 << 12 << false; + QTest::newRow("21") << a << "efg" << -12 << -1 << false; + QTest::newRow("22") << a << "efg" << 11 << 9 << false; + + QTest::newRow("24") << "" << "asdf" << -1 << -1 << false; + QTest::newRow("25") << "asd" << "asdf" << -1 << -1 << false; + QTest::newRow("26") << "" << QString() << -1 << -1 << false; + + QTest::newRow("27") << a << "" << a.size() << a.size() << false; + QTest::newRow("28") << a << "" << a.size() + 10 << -1 << false; +} + +void tst_QStringRef::lastIndexOf() +{ + QFETCH(QString, haystack); + QFETCH(QString, needle); + QFETCH(int, from); + QFETCH(int, expected); + QFETCH(bool, caseSensitive); + + const QString haystackPadded = QString::fromLatin1(" %1 ").arg(haystack); + const QString needlePadded = QString::fromLatin1(" %1 ").arg(needle); + const QStringRef haystackRef(&haystackPadded, 1, haystack.size()); + const QStringRef needleRef(&needlePadded, 1, needle.size()); + + Qt::CaseSensitivity cs = (caseSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive); + + QCOMPARE(haystack.lastIndexOf(needleRef, from, cs), expected); + QCOMPARE(haystackRef.lastIndexOf(needle, from, cs), expected); + QCOMPARE(haystackRef.lastIndexOf(needleRef, from, cs), expected); + + + if (cs == Qt::CaseSensitive) { + QCOMPARE(haystack.lastIndexOf(needleRef, from), expected); + QCOMPARE(haystackRef.lastIndexOf(needle, from), expected); + QCOMPARE(haystackRef.lastIndexOf(needleRef, from), expected); + + if (from == -1) { + QCOMPARE(haystack.lastIndexOf(needleRef), expected); + QCOMPARE(haystackRef.lastIndexOf(needle), expected); + QCOMPARE(haystackRef.lastIndexOf(needleRef), expected); + + } + } + if (needle.size() == 1) { + QCOMPARE(haystack.lastIndexOf(needleRef.at(0), from), expected); + QCOMPARE(haystackRef.lastIndexOf(needle.at(0), from), expected); + QCOMPARE(haystackRef.lastIndexOf(needleRef.at(0), from), expected); + } +} + +void tst_QStringRef::count() +{ + const QString a = QString::fromLatin1("ABCDEFGHIEfGEFG"); // 15 chars + CREATE_REF(a); + QCOMPARE(ref.count('A'),1); + QCOMPARE(ref.count('Z'),0); + QCOMPARE(ref.count('E'),3); + QCOMPARE(ref.count('F'),2); + QCOMPARE(ref.count('F',Qt::CaseInsensitive),3); + QCOMPARE(ref.count("FG"),2); + QCOMPARE(ref.count("FG",Qt::CaseInsensitive),3); + QCOMPARE(ref.count(QString(), Qt::CaseInsensitive), 16); + QCOMPARE(ref.count("", Qt::CaseInsensitive), 16); +} + +void tst_QStringRef::contains() +{ + const QString a = QString::fromLatin1("ABCDEFGHIEfGEFG"); // 15 chars + CREATE_REF(a); + QVERIFY(ref.contains('A')); + QVERIFY(!ref.contains('Z')); + QVERIFY(ref.contains('E')); + QVERIFY(ref.contains('F')); + QVERIFY(ref.contains('F',Qt::CaseInsensitive)); + QVERIFY(ref.contains("FG")); + QVERIFY(ref.contains(QString("FG").midRef(0))); + const QString ref2 = QString::fromLatin1(" FG "); + QVERIFY(ref.contains(ref2.midRef(1, 2),Qt::CaseInsensitive)); + QVERIFY(ref.contains(QString(), Qt::CaseInsensitive)); + QVERIFY(ref.contains("", Qt::CaseInsensitive)); // apparently +} + +void tst_QStringRef::startsWith() +{ + { + const QString a = QString::fromLatin1("AB"); + CREATE_REF(a); + QVERIFY(ref.startsWith("A")); + QVERIFY(ref.startsWith("AB")); + QVERIFY(!ref.startsWith("C")); + QVERIFY(!ref.startsWith("ABCDEF")); + QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString::null)); + QVERIFY(ref.startsWith('A')); + QVERIFY(ref.startsWith(QLatin1Char('A'))); + QVERIFY(ref.startsWith(QChar('A'))); + QVERIFY(!ref.startsWith('C')); + QVERIFY(!ref.startsWith(QChar())); + QVERIFY(!ref.startsWith(QLatin1Char(0))); + + QVERIFY(ref.startsWith(QLatin1String("A"))); + QVERIFY(ref.startsWith(QLatin1String("AB"))); + QVERIFY(!ref.startsWith(QLatin1String("C"))); + QVERIFY(!ref.startsWith(QLatin1String("ABCDEF"))); + QVERIFY(ref.startsWith(QLatin1String(""))); + QVERIFY(ref.startsWith(QLatin1String(0))); + + QVERIFY(ref.startsWith("A", Qt::CaseSensitive)); + QVERIFY(ref.startsWith("A", Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith("a", Qt::CaseSensitive)); + QVERIFY(ref.startsWith("a", Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith("aB", Qt::CaseSensitive)); + QVERIFY(ref.startsWith("aB", Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith("C", Qt::CaseSensitive)); + QVERIFY(!ref.startsWith("C", Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith("c", Qt::CaseSensitive)); + QVERIFY(!ref.startsWith("c", Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith("abcdef", Qt::CaseInsensitive)); + QVERIFY(ref.startsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QString::null, Qt::CaseInsensitive)); + QVERIFY(ref.startsWith('a', Qt::CaseInsensitive)); + QVERIFY(ref.startsWith('A', Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QLatin1Char('a'), Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QChar('a'), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith('c', Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QChar(), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QLatin1Char(0), Qt::CaseInsensitive)); + + QVERIFY(ref.startsWith(QLatin1String("A"), Qt::CaseSensitive)); + QVERIFY(ref.startsWith(QLatin1String("A"), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QLatin1String("a"), Qt::CaseSensitive)); + QVERIFY(ref.startsWith(QLatin1String("a"), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QLatin1String("aB"), Qt::CaseSensitive)); + QVERIFY(ref.startsWith(QLatin1String("aB"), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QLatin1String("C"), Qt::CaseSensitive)); + QVERIFY(!ref.startsWith(QLatin1String("C"), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QLatin1String("c"), Qt::CaseSensitive)); + QVERIFY(!ref.startsWith(QLatin1String("c"), Qt::CaseInsensitive)); + QVERIFY(!ref.startsWith(QLatin1String("abcdef"), Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QLatin1String(""), Qt::CaseInsensitive)); + QVERIFY(ref.startsWith(QLatin1String(0), Qt::CaseInsensitive)); + QVERIFY(ref.startsWith('A', Qt::CaseSensitive)); + QVERIFY(ref.startsWith(QLatin1Char('A'), Qt::CaseSensitive)); + QVERIFY(ref.startsWith(QChar('A'), Qt::CaseSensitive)); + QVERIFY(!ref.startsWith('a', Qt::CaseSensitive)); + QVERIFY(!ref.startsWith(QChar(), Qt::CaseSensitive)); + QVERIFY(!ref.startsWith(QLatin1Char(0), Qt::CaseSensitive)); + } + { + const QString a = QString::fromLatin1(""); + CREATE_REF(a); + QVERIFY(ref.startsWith("")); + QVERIFY(ref.startsWith(QString::null)); + QVERIFY(!ref.startsWith("ABC")); + + QVERIFY(ref.startsWith(QLatin1String(""))); + QVERIFY(ref.startsWith(QLatin1String(0))); + QVERIFY(!ref.startsWith(QLatin1String("ABC"))); + + QVERIFY(!ref.startsWith(QLatin1Char(0))); + QVERIFY(!ref.startsWith(QLatin1Char('x'))); + QVERIFY(!ref.startsWith(QChar())); + } + { + const QStringRef ref; + QVERIFY(!ref.startsWith("")); + QVERIFY(ref.startsWith(QString::null)); + QVERIFY(!ref.startsWith("ABC")); + + QVERIFY(!ref.startsWith(QLatin1String(""))); + QVERIFY(ref.startsWith(QLatin1String(0))); + QVERIFY(!ref.startsWith(QLatin1String("ABC"))); + + QVERIFY(!ref.startsWith(QLatin1Char(0))); + QVERIFY(!ref.startsWith(QLatin1Char('x'))); + QVERIFY(!ref.startsWith(QChar())); + } +} + +void tst_QStringRef::endsWith() +{ + { + const QString a = QString::fromLatin1("AB"); + CREATE_REF(a); + QVERIFY(ref.endsWith("B")); + QVERIFY(ref.endsWith("AB")); + QVERIFY(!ref.endsWith("C")); + QVERIFY(!ref.endsWith("ABCDEF")); + QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString::null)); + QVERIFY(ref.endsWith('B')); + QVERIFY(ref.endsWith(QLatin1Char('B'))); + QVERIFY(ref.endsWith(QChar('B'))); + QVERIFY(!ref.endsWith('C')); + QVERIFY(!ref.endsWith(QChar())); + QVERIFY(!ref.endsWith(QLatin1Char(0))); + + QVERIFY(ref.endsWith(QLatin1String("B"))); + QVERIFY(ref.endsWith(QLatin1String("AB"))); + QVERIFY(!ref.endsWith(QLatin1String("C"))); + QVERIFY(!ref.endsWith(QLatin1String("ABCDEF"))); + QVERIFY(ref.endsWith(QLatin1String(""))); + QVERIFY(ref.endsWith(QLatin1String(0))); + + QVERIFY(ref.endsWith("B", Qt::CaseSensitive)); + QVERIFY(ref.endsWith("B", Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith("b", Qt::CaseSensitive)); + QVERIFY(ref.endsWith("b", Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith("aB", Qt::CaseSensitive)); + QVERIFY(ref.endsWith("aB", Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith("C", Qt::CaseSensitive)); + QVERIFY(!ref.endsWith("C", Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith("c", Qt::CaseSensitive)); + QVERIFY(!ref.endsWith("c", Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith("abcdef", Qt::CaseInsensitive)); + QVERIFY(ref.endsWith("", Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QString::null, Qt::CaseInsensitive)); + QVERIFY(ref.endsWith('b', Qt::CaseInsensitive)); + QVERIFY(ref.endsWith('B', Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QLatin1Char('b'), Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QChar('b'), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith('c', Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QChar(), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QLatin1Char(0), Qt::CaseInsensitive)); + + QVERIFY(ref.endsWith(QLatin1String("B"), Qt::CaseSensitive)); + QVERIFY(ref.endsWith(QLatin1String("B"), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QLatin1String("b"), Qt::CaseSensitive)); + QVERIFY(ref.endsWith(QLatin1String("b"), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QLatin1String("aB"), Qt::CaseSensitive)); + QVERIFY(ref.endsWith(QLatin1String("aB"), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QLatin1String("C"), Qt::CaseSensitive)); + QVERIFY(!ref.endsWith(QLatin1String("C"), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QLatin1String("c"), Qt::CaseSensitive)); + QVERIFY(!ref.endsWith(QLatin1String("c"), Qt::CaseInsensitive)); + QVERIFY(!ref.endsWith(QLatin1String("abcdef"), Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QLatin1String(""), Qt::CaseInsensitive)); + QVERIFY(ref.endsWith(QLatin1String(0), Qt::CaseInsensitive)); + QVERIFY(ref.endsWith('B', Qt::CaseSensitive)); + QVERIFY(ref.endsWith(QLatin1Char('B'), Qt::CaseSensitive)); + QVERIFY(ref.endsWith(QChar('B'), Qt::CaseSensitive)); + QVERIFY(!ref.endsWith('b', Qt::CaseSensitive)); + QVERIFY(!ref.endsWith(QChar(), Qt::CaseSensitive)); + QVERIFY(!ref.endsWith(QLatin1Char(0), Qt::CaseSensitive)); + + } + { + const QString a = QString::fromLatin1(""); + CREATE_REF(a); + QVERIFY(ref.endsWith("")); + QVERIFY(ref.endsWith(QString::null)); + QVERIFY(!ref.endsWith("ABC")); + QVERIFY(!ref.endsWith(QLatin1Char(0))); + QVERIFY(!ref.endsWith(QLatin1Char('x'))); + QVERIFY(!ref.endsWith(QChar())); + + QVERIFY(ref.endsWith(QLatin1String(""))); + QVERIFY(ref.endsWith(QLatin1String(0))); + QVERIFY(!ref.endsWith(QLatin1String("ABC"))); + } + + { + QStringRef ref; + QVERIFY(!ref.endsWith("")); + QVERIFY(ref.endsWith(QString::null)); + QVERIFY(!ref.endsWith("ABC")); + + QVERIFY(!ref.endsWith(QLatin1String(""))); + QVERIFY(ref.endsWith(QLatin1String(0))); + QVERIFY(!ref.endsWith(QLatin1String("ABC"))); + + QVERIFY(!ref.endsWith(QLatin1Char(0))); + QVERIFY(!ref.endsWith(QLatin1Char('x'))); + QVERIFY(!ref.endsWith(QChar())); + } +} + +void tst_QStringRef::operator_eqeq_nullstring() +{ + /* Some of these might not be all that logical but it's the behaviour we've had since 3.0.0 + so we should probably stick with it. */ + + QVERIFY(QStringRef() == ""); + QVERIFY("" == QStringRef()); + + QVERIFY(QString("") == ""); + QVERIFY("" == QString("")); + + QVERIFY(QStringRef().size() == 0); + + QVERIFY(QString("").size() == 0); + + QVERIFY(QStringRef() == QString("")); + QVERIFY(QString("") == QString()); +} + +void tst_QStringRef::localeAwareCompare_data() +{ +#ifdef Q_OS_WIN + QTest::addColumn("locale"); +#else + QTest::addColumn("locale"); +#endif + QTest::addColumn("s1"); + QTest::addColumn("s2"); + QTest::addColumn("result"); + + /* + The C locale performs pure byte comparisons for + Latin-1-specific characters(I think). Compare with Swedish + below. + */ +#ifdef Q_OS_WIN // assume c locale to be english + QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << 1; + QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1; +#else + QTest::newRow("c1") << QString("C") << QString("\xe5") << QString("\xe4") << 1; + QTest::newRow("c2") << QString("C") << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("c3") << QString("C") << QString("\xe5") << QString("\xf6") << -1; +#endif + + /* + It's hard to test English, because it's treated differently + on different platforms. For example, on Linux, it uses the + iso14651_t1 template file, which happens to provide good + defaults for Swedish. Mac OS X seems to do a pure bytewise + comparison of Latin-1 values, although I'm not sure. So I + just test digits to make sure that it's not totally broken. + */ +#ifdef Q_OS_WIN + QTest::newRow("english1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("4") << 1; + QTest::newRow("english2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("4") << QString("6") << -1; + QTest::newRow("english3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("6") << -1; +#else + QTest::newRow("english1") << QString("en_US") << QString("5") << QString("4") << 1; + QTest::newRow("english2") << QString("en_US") << QString("4") << QString("6") << -1; + QTest::newRow("english3") << QString("en_US") << QString("5") << QString("6") << -1; +#endif + /* + In Swedish, a with ring above(E5) comes before a with + diaresis(E4), which comes before o diaresis(F6), which + all come after z. + */ +#ifdef Q_OS_MAC + QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xe4") << -1; + QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xf6") << -1; + QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString("z") << QString("\xe5") << -1; +#elif defined(Q_OS_WIN) + QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << -1; + QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1; + QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("z") << QString("\xe5") << -1; +#else + QTest::newRow("swedish1") << QString("sv_SE") << QString("\xe5") << QString("\xe4") << -1; + QTest::newRow("swedish2") << QString("sv_SE") << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("swedish3") << QString("sv_SE") << QString("\xe5") << QString("\xf6") << -1; + QTest::newRow("swedish4") << QString("sv_SE") << QString("z") << QString("\xe5") << -1; +#endif + +#if 0 + /* + In Norwegian, ae(E6) comes before o with stroke(D8), which + comes before a with ring above(E5). + */ + QTest::newRow("norwegian1") << QString("no_NO") << QString("\xe6") << QString("\xd8") << -1; + QTest::newRow("norwegian2") << QString("no_NO") << QString("\xd8") << QString("\xe5") << -1; + QTest::newRow("norwegian3") << QString("no_NO") << QString("\xe6") << QString("\xe5") << -1; +#endif + + /* + In German, z comes *after* a with diaresis(E4), + which comes before o diaresis(F6). + */ +#ifdef Q_OS_MAC + QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xe4") << 1; + QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xf6") << 1; +#elif defined(Q_OS_WIN) + QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xe4") << 1; + QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xf6") << 1; +#else + QTest::newRow("german1") << QString("de_DE") << QString("z") << QString("\xe4") << 1; + QTest::newRow("german2") << QString("de_DE") << QString("\xe4") << QString("\xf6") << -1; + QTest::newRow("german3") << QString("de_DE") << QString("z") << QString("\xf6") << 1; +#endif +} + +void tst_QStringRef::localeAwareCompare() +{ +#ifdef Q_OS_WIN +# ifndef Q_OS_WINCE + QSKIP("On others than Win CE, we cannot set the system or user locale.", SkipAll); +# endif + QFETCH(ulong, locale); +#else + QFETCH(QString, locale); +#endif + QFETCH(QString, s1); + QFETCH(QString, s2); + + const QString padded1 = QString::fromLatin1(" %1 ").arg(s1); + const QString padded2 = QString::fromLatin1(" %2 ").arg(s2); + const QStringRef ref1 = padded1.midRef(1, s1.size()); + const QStringRef ref2 = padded2.midRef(1, s2.size()); + + QFETCH(int, result); + + +#ifdef Q_OS_WIN +# if defined(Q_OS_WINCE) + DWORD oldLcid = GetUserDefaultLCID(); + SetUserDefaultLCID(locale); + + QCOMPARE(locale, GetUserDefaultLCID()); +# else + DWORD oldLcid = GetThreadLocale(); + SetThreadLocale(locale); + + QCOMPARE(locale, GetThreadLocale()); +# endif + +#elif defined(Q_WS_MAC) + QSKIP("Setting the locale is not supported on OS X(you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)", SkipAll); +#else + if (!locale.isEmpty()) { + const char *newLocale = setlocale(LC_ALL, locale.toLatin1()); + if (!newLocale) { + setlocale(LC_ALL, ""); + QSKIP("Please install the proper locale on this machine to test properly", SkipSingle); + return; + } + } +#endif + + int testres = QStringRef::localeAwareCompare(ref1, ref2); + if (result < 0) { + QVERIFY(testres < 0); + } else if (result > 0) { + QVERIFY(testres > 0); + } else { + QVERIFY(testres == 0); + } + + + testres = QStringRef::localeAwareCompare(ref2, ref1); + if (result > 0) { + QVERIFY(testres < 0); + } else if (result < 0) { + QVERIFY(testres > 0); + } else { + QVERIFY(testres == 0); + } + +#ifdef Q_OS_WIN +# if defined(Q_OS_WINCE) + SetUserDefaultLCID(oldLcid); +# else + SetThreadLocale(oldLcid); +# endif + +#else + if (!locale.isEmpty()) + setlocale(LC_ALL, ""); +#endif +} + + +static inline int sign(int x) +{ + return x == 0 ? 0 : (x < 0 ? -1 : 1); +} + +void tst_QStringRef::compare_data() +{ + QTest::addColumn("s1"); + QTest::addColumn("s2"); + QTest::addColumn("csr"); // case sensitive result + QTest::addColumn("cir"); // case insensitive result + + + // null strings + QTest::newRow("data0") << QString("") << QString("") << 0 << 0; + QTest::newRow("data1") << QString("a") << QString("") << 1 << 1; + QTest::newRow("data2") << QString("") << QString("a") << -1 << -1; + + // equal length + QTest::newRow("data3") << QString("abc") << QString("abc") << 0 << 0; + QTest::newRow("data4") << QString("abC") << QString("abc") << -1 << 0; + QTest::newRow("data5") << QString("abc") << QString("abC") << 1 << 0; + + // different length + QTest::newRow("data6") << QString("abcdef") << QString("abc") << 1 << 1; + QTest::newRow("data6") << QString("abCdef") << QString("abc") << -1 << 1; + QTest::newRow("data7") << QString("abc") << QString("abcdef") << -1 << -1; + + QString upper; + upper += QChar(QChar::highSurrogate(0x10400)); + upper += QChar(QChar::lowSurrogate(0x10400)); + QString lower; + lower += QChar(QChar::highSurrogate(0x10428)); + lower += QChar(QChar::lowSurrogate(0x10428)); + QTest::newRow("data8") << upper << lower << -1 << 0; + + // embedded nulls + // These dont work as of now. Its OK that these dont work since \0 is not a valid unicode + /*QTest::newRow("data9") << QString(QByteArray("\0", 1)) << QString(QByteArray("\0", 1)) << 0 << 0; + QTest::newRow("data10") << QString(QByteArray("\0", 1)) << QString("") << 1 << 1; + QTest::newRow("data11") << QString("") << QString(QByteArray("\0", 1)) << -1 << -1; + QTest::newRow("data12") << QString("ab\0c") << QString(QByteArray("ab\0c", 4)) << 0 << 0; + QTest::newRow("data13") << QString(QByteArray("ab\0c", 4)) << QString("abc") << -1 << -1; + QTest::newRow("data14") << QString("abc") << QString(QByteArray("ab\0c", 4)) << 1 << 1;*/ +} + +static bool isLatin(const QString &s) +{ + for (int i = 0; i < s.length(); ++i) + if (s.at(i).unicode() > 0xff) + return false; + return true; +} + +void tst_QStringRef::compare() +{ + QFETCH(QString, s1); + QFETCH(QString, s2); + QFETCH(int, csr); + QFETCH(int, cir); + + QStringRef r1(&s1, 0, s1.length()); + QStringRef r2(&s2, 0, s2.length()); + + QCOMPARE(sign(QString::compare(s1, s2)), csr); + QCOMPARE(sign(QStringRef::compare(r1, r2)), csr); + QCOMPARE(sign(s1.compare(s2)), csr); + QCOMPARE(sign(s1.compare(r2)), csr); + QCOMPARE(sign(r1.compare(r2)), csr); + + QCOMPARE(sign(s1.compare(s2, Qt::CaseSensitive)), csr); + QCOMPARE(sign(s1.compare(s2, Qt::CaseInsensitive)), cir); + QCOMPARE(sign(s1.compare(r2, Qt::CaseSensitive)), csr); + QCOMPARE(sign(s1.compare(r2, Qt::CaseInsensitive)), cir); + QCOMPARE(sign(r1.compare(r2, Qt::CaseSensitive)), csr); + QCOMPARE(sign(r1.compare(r2, Qt::CaseInsensitive)), cir); + + QCOMPARE(sign(QString::compare(s1, s2, Qt::CaseSensitive)), csr); + QCOMPARE(sign(QString::compare(s1, s2, Qt::CaseInsensitive)), cir); + QCOMPARE(sign(QString::compare(s1, r2, Qt::CaseSensitive)), csr); + QCOMPARE(sign(QString::compare(s1, r2, Qt::CaseInsensitive)), cir); + QCOMPARE(sign(QStringRef::compare(r1, r2, Qt::CaseSensitive)), csr); + QCOMPARE(sign(QStringRef::compare(r1, r2, Qt::CaseInsensitive)), cir); + + if (!cir) { + QCOMPARE(s1.toCaseFolded(), s2.toCaseFolded()); + } + + if (isLatin(s2)) { + QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()))), csr); + QCOMPARE(sign(QString::compare(s1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir); + QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()))), csr); + QCOMPARE(sign(QStringRef::compare(r1, QLatin1String(s2.toLatin1()), Qt::CaseInsensitive)), cir); + } + + if (isLatin(s1)) { + QCOMPARE(sign(QString::compare(QLatin1String(s1.toLatin1()), s2)), csr); + QCOMPARE(sign(QString::compare(QLatin1String(s1.toLatin1()), s2, Qt::CaseInsensitive)), cir); + } +} + +QTEST_APPLESS_MAIN(tst_QStringRef) + +#include "tst_qstringref.moc" -- cgit v0.12 From ba9f3e4a232e2199115710a630906fd3da50552a Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 31 May 2010 14:39:03 +0200 Subject: Cocoa: fix broken drawers after content view structure change After setting top level widget views as content views in windows directly, the function this patch fixes, broke. --- src/gui/kernel/qwidget_mac.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 40c5dad..3e0ad40 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -223,6 +223,8 @@ static NSDrawer *qt_mac_drawer_for(const QWidget *widget) for (NSWindow *window in windows) { NSArray *drawers = [window drawers]; for (NSDrawer *drawer in drawers) { + if ([drawer contentView] == widgetView) + return drawer; NSArray *views = [[drawer contentView] subviews]; for (NSView *view in views) { if (view == widgetView) -- cgit v0.12 From 4d66a933837ffc51fdef01f9485be58d5788b787 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Mon, 31 May 2010 15:02:54 +0200 Subject: Revert "Cocoa: remove 'double' content view from window" This reverts commit 5cdafc956f6f2e18012b31d68851150d89d7e577. Reason: Broke some autotests (qgl, qglversioncheck). It needs some more investigation. --- src/gui/kernel/qwidget_mac.mm | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 3e0ad40..5bb3f1c 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -239,8 +239,6 @@ static NSDrawer *qt_mac_drawer_for(const QWidget *widget) static void qt_mac_destructView(OSViewRef view) { #ifdef QT_MAC_USE_COCOA - if ([[view window] contentView] == view) - [[view window] setContentView:0]; [view removeFromSuperview]; [view release]; #else @@ -2289,23 +2287,28 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin Q_UNUSED(dialog); data.fstrut_dirty = true; // when we create a toplevel widget, the frame strut should be dirty - OSViewRef nsview = (OSViewRef)data.winid; + OSViewRef window_contentview = qt_mac_get_contentview_for(windowRef); if (!nsview) { - nsview = qt_mac_create_widget(q, this, 0); + nsview = qt_mac_create_widget(q, this, window_contentview); setWinId(WId(nsview)); + } else { + [window_contentview addSubview:nsview]; + } + if (nsview) { + NSRect bounds = [window_contentview bounds]; + [nsview setFrame:bounds]; + [nsview setHidden:NO]; + if (q->testAttribute(Qt::WA_DropSiteRegistered)) + registerDropSite(true); + transferChildren(); + + // Tell Cocoa explicit that we wan't the view to receive key events + // (regardless of focus policy) because this is how it works on other + // platforms (and in the carbon port): + if (!qApp->focusWidget()) + [windowRef makeFirstResponder:nsview]; } - [windowRef setContentView:nsview]; - [nsview setHidden:NO]; - if (q->testAttribute(Qt::WA_DropSiteRegistered)) - registerDropSite(true); - transferChildren(); - - // Tell Cocoa explicit that we wan't the view to receive key events - // (regardless of focus policy) because this is how it works on other - // platforms (and in the carbon port): - if (!qApp->focusWidget()) - [windowRef makeFirstResponder:nsview]; if (topExtra->posFromMove) { updateFrameStrut(); -- 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 39067921bf2361b75a587090416514feecbdcba5 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 28 May 2010 12:45:30 +0200 Subject: Cocoa: remove 'double' content view from window, second try Up til now, we always used to create a new NSView for a top level widget, and make it a child of the windows content view. This is/should be unnecessary, as NSWindow has a method for setting the content view directly, thereby allowing for reducing the stacking level with one view. Not the biggest gain if the year, but it seems effortless to implement. And I do it as a part of Alien preparation. Rev-By: msorvig --- src/gui/kernel/qcocoaview_mac.mm | 2 +- src/gui/kernel/qwidget_mac.mm | 34 ++++++++++++++++------------------ 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 4953c48..86c4025 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -473,7 +473,7 @@ static int qCocoaViewCount = 0; } // Make sure the opengl context is updated on resize. - if (qwidgetprivate && qwidgetprivate->isGLWidget) { + if (qwidgetprivate && qwidgetprivate->isGLWidget && [self window]) { qwidgetprivate->needWindowChange = true; QEvent event(QEvent::MacGLWindowChange); qApp->sendEvent(qwidget, &event); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 5bb3f1c..6df9c3b 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -239,6 +239,9 @@ static NSDrawer *qt_mac_drawer_for(const QWidget *widget) static void qt_mac_destructView(OSViewRef view) { #ifdef QT_MAC_USE_COCOA + NSWindow *window = [view window]; + if ([window contentView] == view) + [window setContentView:[[NSView alloc] initWithFrame:[view bounds]]]; [view removeFromSuperview]; [view release]; #else @@ -2287,28 +2290,23 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin Q_UNUSED(dialog); data.fstrut_dirty = true; // when we create a toplevel widget, the frame strut should be dirty + OSViewRef nsview = (OSViewRef)data.winid; - OSViewRef window_contentview = qt_mac_get_contentview_for(windowRef); if (!nsview) { - nsview = qt_mac_create_widget(q, this, window_contentview); + nsview = qt_mac_create_widget(q, this, 0); setWinId(WId(nsview)); - } else { - [window_contentview addSubview:nsview]; - } - if (nsview) { - NSRect bounds = [window_contentview bounds]; - [nsview setFrame:bounds]; - [nsview setHidden:NO]; - if (q->testAttribute(Qt::WA_DropSiteRegistered)) - registerDropSite(true); - transferChildren(); - - // Tell Cocoa explicit that we wan't the view to receive key events - // (regardless of focus policy) because this is how it works on other - // platforms (and in the carbon port): - if (!qApp->focusWidget()) - [windowRef makeFirstResponder:nsview]; } + [windowRef setContentView:nsview]; + [nsview setHidden:NO]; + if (q->testAttribute(Qt::WA_DropSiteRegistered)) + registerDropSite(true); + transferChildren(); + + // Tell Cocoa explicit that we wan't the view to receive key events + // (regardless of focus policy) because this is how it works on other + // platforms (and in the carbon port): + if (!qApp->focusWidget()) + [windowRef makeFirstResponder:nsview]; if (topExtra->posFromMove) { updateFrameStrut(); -- 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 453b2578b5bdb67553dec1c4e8f480c94f1153cd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 1 Jun 2010 10:10:32 +0200 Subject: tst_qstringref.cpp: Fix licence header and compilation on windows Somehow the emacs macro for style did a too good job --- tests/auto/qstringref/tst_qstringref.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/auto/qstringref/tst_qstringref.cpp b/tests/auto/qstringref/tst_qstringref.cpp index 1980901..2d25efd 100644 --- a/tests/auto/qstringref/tst_qstringref.cpp +++ b/tests/auto/qstringref/tst_qstringref.cpp @@ -1,8 +1,8 @@ /**************************************************************************** ** -** Copyright(C) 2010 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) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -39,7 +39,6 @@ ** ****************************************************************************/ - #include #include #include @@ -167,7 +166,7 @@ static inline double nan() return *reinterpret_cast(be_nan_bytes); return *reinterpret_cast(le_nan_bytes); } -# define NAN(::nan()) +# define NAN (::nan()) #endif tst_QStringRef::tst_QStringRef() -- cgit v0.12 From 43b67ba9d500af9de0594d7d2db3e3613dd00f22 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 1 Jun 2010 11:37:13 +0200 Subject: Examples: Fix compilation with namespaces. --- demos/spectrum/app/engine.h | 5 ++++- demos/spectrum/app/mainwidget.h | 3 +++ demos/spectrum/app/settingsdialog.h | 2 ++ demos/spectrum/app/spectrograph.h | 2 ++ demos/spectrum/app/spectrumanalyser.h | 3 +++ demos/spectrum/app/tonegenerator.h | 2 ++ demos/spectrum/app/tonegeneratordialog.h | 2 ++ demos/spectrum/app/utils.h | 2 ++ demos/spectrum/app/waveform.h | 2 ++ 9 files changed, 22 insertions(+), 1 deletion(-) diff --git a/demos/spectrum/app/engine.h b/demos/spectrum/app/engine.h index 16088b2..93733fe 100644 --- a/demos/spectrum/app/engine.h +++ b/demos/spectrum/app/engine.h @@ -61,10 +61,13 @@ #include #endif +QT_BEGIN_NAMESPACE class QAudioInput; class QAudioOutput; -class FrequencySpectrum; class QFile; +QT_END_NAMESPACE + +class FrequencySpectrum; /** * This class interfaces with the QtMultimedia audio classes, and also with diff --git a/demos/spectrum/app/mainwidget.h b/demos/spectrum/app/mainwidget.h index 846b97a..c59dbd6 100644 --- a/demos/spectrum/app/mainwidget.h +++ b/demos/spectrum/app/mainwidget.h @@ -50,11 +50,14 @@ class Waveform; class LevelMeter; class SettingsDialog; class ToneGeneratorDialog; + +QT_BEGIN_NAMESPACE class QAudioFormat; class QLabel; class QPushButton; class QMenu; class QAction; +QT_END_NAMESPACE /** * Main application widget, responsible for connecting the various UI diff --git a/demos/spectrum/app/settingsdialog.h b/demos/spectrum/app/settingsdialog.h index 7215a50..fda518b 100644 --- a/demos/spectrum/app/settingsdialog.h +++ b/demos/spectrum/app/settingsdialog.h @@ -42,11 +42,13 @@ #include #include +QT_BEGIN_NAMESPACE class QComboBox; class QCheckBox; class QSlider; class QSpinBox; class QGridLayout; +QT_END_NAMESPACE /** * Dialog used to control settings such as the audio input / output device diff --git a/demos/spectrum/app/spectrograph.h b/demos/spectrum/app/spectrograph.h index 6bfef33..a7790ff 100644 --- a/demos/spectrum/app/spectrograph.h +++ b/demos/spectrum/app/spectrograph.h @@ -41,7 +41,9 @@ #include #include "frequencyspectrum.h" +QT_BEGIN_NAMESPACE class QMouseEvent; +QT_END_NAMESPACE /** * Widget which displays a spectrograph showing the frequency spectrum diff --git a/demos/spectrum/app/spectrumanalyser.h b/demos/spectrum/app/spectrumanalyser.h index caeb1c1..f10da63 100644 --- a/demos/spectrum/app/spectrumanalyser.h +++ b/demos/spectrum/app/spectrumanalyser.h @@ -55,8 +55,11 @@ #include "FFTRealFixLenParam.h" #endif +QT_BEGIN_NAMESPACE class QAudioFormat; class QThread; +QT_END_NAMESPACE + class FFTRealWrapper; class SpectrumAnalyserThreadPrivate; diff --git a/demos/spectrum/app/tonegenerator.h b/demos/spectrum/app/tonegenerator.h index 419f7e4..d387768 100644 --- a/demos/spectrum/app/tonegenerator.h +++ b/demos/spectrum/app/tonegenerator.h @@ -41,8 +41,10 @@ #include #include "spectrum.h" +QT_BEGIN_NAMESPACE class QAudioFormat; class QByteArray; +QT_END_NAMESPACE /** * Generate a sine wave diff --git a/demos/spectrum/app/tonegeneratordialog.h b/demos/spectrum/app/tonegeneratordialog.h index 35d69c2..d6fcffa 100644 --- a/demos/spectrum/app/tonegeneratordialog.h +++ b/demos/spectrum/app/tonegeneratordialog.h @@ -42,10 +42,12 @@ #include #include +QT_BEGIN_NAMESPACE class QCheckBox; class QSlider; class QSpinBox; class QGridLayout; +QT_END_NAMESPACE /** * Dialog which controls the parameters of the tone generator. diff --git a/demos/spectrum/app/utils.h b/demos/spectrum/app/utils.h index 83467cd..548f884 100644 --- a/demos/spectrum/app/utils.h +++ b/demos/spectrum/app/utils.h @@ -41,7 +41,9 @@ #include #include +QT_BEGIN_NAMESPACE class QAudioFormat; +QT_END_NAMESPACE //----------------------------------------------------------------------------- // Miscellaneous utility functions diff --git a/demos/spectrum/app/waveform.h b/demos/spectrum/app/waveform.h index 4de527f..909e5ee 100644 --- a/demos/spectrum/app/waveform.h +++ b/demos/spectrum/app/waveform.h @@ -43,7 +43,9 @@ #include #include +QT_BEGIN_NAMESPACE class QByteArray; +QT_END_NAMESPACE /** * Widget which displays a section of the audio waveform. -- 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 bf6de2f79991bb66161960343f18fc1cae0aca41 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 2 Jun 2010 10:04:56 +0200 Subject: Itemviews: use localeAwareCompare for comparing in the widget classes Task-number: QTBUG-10839 Reviewed-by: Thierry --- src/corelib/kernel/qabstractitemmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 3660a3c..83aed8c 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -532,7 +532,7 @@ bool QAbstractItemModelPrivate::variantLessThan(const QVariant &v1, const QVaria case 1: //floating point return v1.toReal() < v2.toReal(); default: - return v1.toString() < v2.toString(); + return v1.toString().localeAwareCompare(v2.toString()) < 0; } } -- 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 89f4deb6ae092c5d5fe91a169cb328288a87f146 Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 2 Jun 2010 12:16:18 +0200 Subject: Add missing trace, small cleanup. Reviewed-by: ck --- .../assistant/tools/assistant/openpagesmanager.cpp | 8 +++++- tools/assistant/tools/assistant/openpagesmanager.h | 33 +++++++++++----------- .../assistant/tools/assistant/openpageswidget.cpp | 13 +++++++-- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp index b6005e8..490fddd 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.cpp +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -181,11 +181,13 @@ HelpViewer *OpenPagesManager::createPage(const QUrl &url, bool fromSearch) HelpViewer *OpenPagesManager::createNewPageFromSearch(const QUrl &url) { + TRACE_OBJ return createPage(url, true); } void OpenPagesManager::closePage(const QModelIndex &index) { + TRACE_OBJ if (index.isValid()) removePage(index.row()); } @@ -282,23 +284,27 @@ void OpenPagesManager::closePagesExcept(const QModelIndex &index) QAbstractItemView *OpenPagesManager::openPagesWidget() const { + TRACE_OBJ return m_openPagesWidget; } void OpenPagesManager::nextPage() { + TRACE_OBJ nextOrPreviousPage(1); } void OpenPagesManager::previousPage() { + TRACE_OBJ nextOrPreviousPage(-1); } void OpenPagesManager::nextOrPreviousPage(int offset) { + TRACE_OBJ setCurrentPage((CentralWidget::instance()->currentIndex() + offset - + m_model->rowCount()) % m_model->rowCount()); + + m_model->rowCount()) % m_model->rowCount()); } OpenPagesManager *OpenPagesManager::m_instance = 0; diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h index 5e7a9af..0ae3180 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.h +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -41,27 +41,27 @@ #ifndef OPENPAGESMANAGER_H #define OPENPAGESMANAGER_H - + #include - + QT_BEGIN_NAMESPACE class QAbstractItemView; class QModelIndex; class QUrl; - + class HelpViewer; class OpenPagesModel; class OpenPagesWidget; - + class OpenPagesManager : public QObject - { +{ Q_OBJECT - public: +public: static OpenPagesManager *createInstance(QObject *parent, - bool defaultCollection, const QUrl &cmdLineUrl); + bool defaultCollection, const QUrl &cmdLineUrl); static OpenPagesManager *instance(); - + bool pagesOpenForNamespace(const QString &nameSpace) const; void closePages(const QString &nameSpace); void reloadPages(const QString &nameSpace); @@ -71,7 +71,7 @@ class OpenPagesManager : public QObject int pageCount() const; void setCurrentPage(int index); - public slots: +public slots: HelpViewer *createPage(const QUrl &url, bool fromSearch = false); HelpViewer *createNewPageFromSearch(const QUrl &url); HelpViewer *createPage(); @@ -86,19 +86,18 @@ private slots: private: OpenPagesManager(QObject *parent, bool defaultCollection, - const QUrl &cmdLineUrl); + const QUrl &cmdLineUrl); void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); void closeOrReloadPages(const QString &nameSpace, bool tryReload); void selectCurrentPage(); void removePage(int index); void nextOrPreviousPage(int offset); - - OpenPagesModel *m_model; - OpenPagesWidget *m_openPagesWidget; + OpenPagesModel *m_model; + OpenPagesWidget *m_openPagesWidget; + + static OpenPagesManager *m_instance; +}; - static OpenPagesManager *m_instance; - }; - QT_END_NAMESPACE - + #endif // OPENPAGESMANAGER_H diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp index d702c28..1a5c292 100644 --- a/tools/assistant/tools/assistant/openpageswidget.cpp +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -42,6 +42,7 @@ #include "openpageswidget.h" #include "openpagesmodel.h" +#include "tracer.h" #include #include @@ -57,13 +58,15 @@ QT_BEGIN_NAMESPACE OpenPagesDelegate::OpenPagesDelegate(QObject *parent) - : QStyledItemDelegate(parent) + : QStyledItemDelegate(parent) { + TRACE_OBJ } void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { + TRACE_OBJ if (option.state & QStyle::State_MouseOver) { if ((QApplication::mouseButtons() & Qt::LeftButton) == 0) pressedIndex = QModelIndex(); @@ -90,6 +93,7 @@ void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) { + TRACE_OBJ setModel(model); setIndentation(0); setItemDelegate((m_delegate = new OpenPagesDelegate(this))); @@ -122,10 +126,12 @@ OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) OpenPagesWidget::~OpenPagesWidget() { + TRACE_OBJ } void OpenPagesWidget::contextMenuRequested(QPoint pos) { + TRACE_OBJ QModelIndex index = indexAt(pos); if (!index.isValid()) return; @@ -152,6 +158,7 @@ void OpenPagesWidget::contextMenuRequested(QPoint pos) void OpenPagesWidget::handlePressed(const QModelIndex &index) { + TRACE_OBJ if (index.column() == 0) emit setCurrentPage(index); @@ -161,7 +168,8 @@ void OpenPagesWidget::handlePressed(const QModelIndex &index) void OpenPagesWidget::handleClicked(const QModelIndex &index) { - // implemented here to handle the funky close button and to work around a + TRACE_OBJ + // implemented here to handle the funky close button and to work around a // bug in item views where the delegate wouldn't get the QStyle::State_MouseOver if (index.column() == 1) { if (model()->rowCount() > 1) @@ -177,6 +185,7 @@ void OpenPagesWidget::handleClicked(const QModelIndex &index) bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event) { + TRACE_OBJ if (obj == this && event->type() == QEvent::KeyPress) { if (currentIndex().isValid()) { QKeyEvent *ke = static_cast(event); -- cgit v0.12 From 2573227b32597f3ae1ab861f0724765662e41174 Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 2 Jun 2010 12:28:40 +0200 Subject: Remove in-page switcher. Reviewed-by: ck --- tools/assistant/tools/assistant/helpviewer.cpp | 33 ++++------------------ tools/assistant/tools/assistant/helpviewer.h | 3 -- tools/assistant/tools/assistant/helpviewer_p.h | 30 -------------------- tools/assistant/tools/assistant/helpviewer_qtb.cpp | 7 ----- tools/assistant/tools/assistant/helpviewer_qwv.cpp | 11 ++------ 5 files changed, 9 insertions(+), 75 deletions(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index 81870a9..a448dd4 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -51,7 +51,6 @@ #include #include -#include #include #include @@ -109,6 +108,12 @@ struct ExtensionMap { { 0, 0 } }; +HelpViewer::~HelpViewer() +{ + TRACE_OBJ + delete d; +} + bool HelpViewer::isLocalUrl(const QUrl &url) { TRACE_OBJ @@ -208,30 +213,4 @@ bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event) return false; } -bool HelpViewer::openPagesListRequested(const QMouseEvent *event) const -{ - return event->buttons() == Qt::RightButton - && event->modifiers() == Qt::ControlModifier; -} - -bool HelpViewer::openPagesListRequested(const QContextMenuEvent *event) const -{ - return event->reason() == QContextMenuEvent::Mouse - && event->modifiers() == Qt::ControlModifier; -} - -void HelpViewer::showOpenPagesList(const QPoint &pos) -{ - QComboBox * const openPagesBox = d->openPagesBox(this); - openPagesBox->move(pos); - openPagesBox->setCurrentIndex(CentralWidget::instance()->currentIndex()); - openPagesBox->showPopup(); -} - -HelpViewer::~HelpViewer() -{ - TRACE_OBJ - delete d; -} - QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 1f897d9..847b0ca 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -145,9 +145,6 @@ private: void contextMenuEvent(QContextMenuEvent *event); QVariant loadResource(int type, const QUrl &name); bool handleForwardBackwardMouseButtons(QMouseEvent *e); - bool openPagesListRequested(const QMouseEvent *event) const; - bool openPagesListRequested(const QContextMenuEvent *event) const; - void showOpenPagesList(const QPoint &pos); private: HelpViewerPrivate *d; diff --git a/tools/assistant/tools/assistant/helpviewer_p.h b/tools/assistant/tools/assistant/helpviewer_p.h index 2bd4e16..2772905 100644 --- a/tools/assistant/tools/assistant/helpviewer_p.h +++ b/tools/assistant/tools/assistant/helpviewer_p.h @@ -47,11 +47,9 @@ #include "openpagesmanager.h" #include -#include #ifdef QT_NO_WEBKIT #include #endif -#include QT_BEGIN_NAMESPACE @@ -69,7 +67,6 @@ public: HelpViewerPrivate() #endif { - m_openPagesBox = 0; } #ifdef QT_NO_WEBKIT @@ -98,25 +95,8 @@ public: CentralWidget::instance()->setSource(lastAnchor); lastAnchor.clear(); } -#endif // QT_NO_WEBKIT - - QComboBox *openPagesBox(QWidget *parent = 0) - { - if (!m_openPagesBox) { - m_openPagesBox = new QComboBox(parent); - m_openPagesBox->setSizeAdjustPolicy(QComboBox::AdjustToContents); - m_openPagesBox->setModel(OpenPagesManager::instance() - ->openPagesWidget()->model()); - connect(m_openPagesBox, SIGNAL(activated(int)), this, - SLOT(switchToPage(int))); - } - - return m_openPagesBox; - } public slots: - -#ifdef QT_NO_WEBKIT void openLink() { openLink(false); @@ -132,16 +112,6 @@ public: bool forceFont; QString lastAnchor; #endif // QT_NO_WEBKIT - -private slots: - - void switchToPage(int row) - { - OpenPagesManager::instance()->setCurrentPage(row); - } - -private: - QComboBox *m_openPagesBox; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index 98eb59f..f6b5022 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -298,10 +298,6 @@ void HelpViewer::mousePressEvent(QMouseEvent *e) if (handleForwardBackwardMouseButtons(e)) return; #endif - if (openPagesListRequested(e)) { - showOpenPagesList(e->pos()); - return; - } QTextBrowser::mousePressEvent(e); } @@ -346,9 +342,6 @@ void HelpViewer::contextMenuEvent(QContextMenuEvent *event) { TRACE_OBJ - if (openPagesListRequested(event)) - return; - QMenu menu(QString(), 0); QUrl link; QAction *copyAnchorAction = 0; diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index 869789b..f61d6d4 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -243,7 +243,8 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, // -- HelpViewer HelpViewer::HelpViewer(qreal zoom, QWidget *parent) - : QWebView(parent), d(new HelpViewerPrivate) + : QWebView(parent) + , d(new HelpViewerPrivate) { TRACE_OBJ setAcceptDrops(false); @@ -432,11 +433,6 @@ void HelpViewer::mousePressEvent(QMouseEvent *event) return; #endif - if (openPagesListRequested(event)) { - showOpenPagesList(event->pos()); - return; - } - if (HelpPage *currentPage = static_cast (page())) { currentPage->m_pressedButtons = event->buttons(); currentPage->m_keyboardModifiers = event->modifiers(); @@ -481,8 +477,7 @@ bool HelpViewer::eventFilter(QObject *obj, QEvent *event) void HelpViewer::contextMenuEvent(QContextMenuEvent *event) { TRACE_OBJ - if (!openPagesListRequested(event)) - QWebView::contextMenuEvent(event); + QWebView::contextMenuEvent(event); } QT_END_NAMESPACE -- cgit v0.12 From 65cedbf9872bbf8e64ff03c49abce09a292d7ec0 Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 2 Jun 2010 13:50:05 +0200 Subject: Backport open pages switcher from Qt Creator. Reviewed-by: ck --- tools/assistant/tools/assistant/assistant.pro | 6 +- tools/assistant/tools/assistant/mainwindow.cpp | 13 ++ .../assistant/tools/assistant/openpagesmanager.cpp | 98 ++++++++--- tools/assistant/tools/assistant/openpagesmanager.h | 11 +- .../tools/assistant/openpagesswitcher.cpp | 194 +++++++++++++++++++++ .../assistant/tools/assistant/openpagesswitcher.h | 85 +++++++++ .../assistant/tools/assistant/openpageswidget.cpp | 22 ++- tools/assistant/tools/assistant/openpageswidget.h | 4 + 8 files changed, 403 insertions(+), 30 deletions(-) create mode 100644 tools/assistant/tools/assistant/openpagesswitcher.cpp create mode 100644 tools/assistant/tools/assistant/openpagesswitcher.h diff --git a/tools/assistant/tools/assistant/assistant.pro b/tools/assistant/tools/assistant/assistant.pro index af306a5..97d88dc 100644 --- a/tools/assistant/tools/assistant/assistant.pro +++ b/tools/assistant/tools/assistant/assistant.pro @@ -47,7 +47,8 @@ HEADERS += aboutdialog.h \ openpagesmodel.h \ globalactions.h \ openpageswidget.h \ - openpagesmanager.h + openpagesmanager.h \ + openpagesswitcher.h win32:HEADERS += remotecontrol_win.h SOURCES += aboutdialog.cpp \ @@ -78,7 +79,8 @@ SOURCES += aboutdialog.cpp \ openpagesmodel.cpp \ globalactions.cpp \ openpageswidget.cpp \ - openpagesmanager.cpp + openpagesmanager.cpp \ + openpagesswitcher.cpp contains(QT_CONFIG, webkit) { SOURCES += helpviewer_qwv.cpp } else { diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index ca10d38..e436201 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -79,6 +79,7 @@ #include #include #include +#include #include #include #include @@ -516,6 +517,18 @@ void MainWindow::setupActions() tmp->setShortcuts(QList() << QKeySequence(tr("Ctrl+Alt+Left")) << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); +#ifdef Q_WS_MAC + QShortcut *sct = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(nextPageWithSwitcher())); + sct = new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(previousPageWithSwitcher())); +#else + QShortcut *sct = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(nextPageWithSwitcher())); + sct = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab), this); + connect(sct, SIGNAL(activated()), openPages, SLOT(previousPageWithSwitcher())); +#endif + BookmarkManager::instance()->takeBookmarksMenu(menuBar()->addMenu(tr("&Bookmarks"))); menu = menuBar()->addMenu(tr("&Help")); diff --git a/tools/assistant/tools/assistant/openpagesmanager.cpp b/tools/assistant/tools/assistant/openpagesmanager.cpp index 490fddd..6b08c46 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.cpp +++ b/tools/assistant/tools/assistant/openpagesmanager.cpp @@ -38,20 +38,25 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include "openpagesmanager.h" - + #include "centralwidget.h" #include "helpenginewrapper.h" #include "helpviewer.h" #include "openpagesmodel.h" +#include "openpagesswitcher.h" #include "openpageswidget.h" #include "tracer.h" #include "../shared/collectionconfiguration.h" +#include #include - + QT_BEGIN_NAMESPACE +OpenPagesManager *OpenPagesManager::m_instance = 0; + OpenPagesManager *OpenPagesManager::createInstance(QObject *parent, bool defaultCollection, const QUrl &cmdLineUrl) { @@ -70,25 +75,43 @@ OpenPagesManager *OpenPagesManager::instance() OpenPagesManager::OpenPagesManager(QObject *parent, bool defaultCollection, const QUrl &cmdLineUrl) - : QObject(parent), m_model(new OpenPagesModel(this)), - m_openPagesWidget(new OpenPagesWidget(m_model)) + : QObject(parent) + , m_model(new OpenPagesModel(this)) + , m_openPagesWidget(0) + , m_openPagesSwitcher(0) { TRACE_OBJ + m_openPagesWidget = new OpenPagesWidget(m_model); + m_openPagesWidget->setFrameStyle(QFrame::NoFrame); connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, SLOT(setCurrentPage(QModelIndex))); connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, SLOT(closePage(QModelIndex))); connect(m_openPagesWidget, SIGNAL(closePagesExcept(QModelIndex)), this, SLOT(closePagesExcept(QModelIndex))); + + m_openPagesSwitcher = new OpenPagesSwitcher(m_model); + connect(m_openPagesSwitcher, SIGNAL(closePage(QModelIndex)), this, + SLOT(closePage(QModelIndex))); + connect(m_openPagesSwitcher, SIGNAL(setCurrentPage(QModelIndex)), this, + SLOT(setCurrentPage(QModelIndex))); + setupInitialPages(defaultCollection, cmdLineUrl); } - + +OpenPagesManager ::~OpenPagesManager() +{ + TRACE_OBJ + m_instance = 0; + delete m_openPagesSwitcher; +} + int OpenPagesManager::pageCount() const { TRACE_OBJ return m_model->rowCount(); } - + void OpenPagesManager::setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl) { @@ -145,6 +168,7 @@ void OpenPagesManager::setupInitialPages(bool defaultCollection, for (int i = 0; i < m_model->rowCount(); ++i) CentralWidget::instance()->addPage(m_model->pageAt(i)); setCurrentPage(initialPage); + m_openPagesSwitcher->selectCurrentPage(); } HelpViewer *OpenPagesManager::createPage() @@ -202,13 +226,12 @@ void OpenPagesManager::reloadPages(const QString &nameSpace) { TRACE_OBJ closeOrReloadPages(nameSpace, true); - selectCurrentPage(); + m_openPagesWidget->selectCurrentPage(); } void OpenPagesManager::closeOrReloadPages(const QString &nameSpace, bool tryReload) { TRACE_OBJ - for (int i = m_model->rowCount() - 1; i >= 0; --i) { HelpViewer *page = m_model->pageAt(i); if (page->source().host() != nameSpace) @@ -234,27 +257,15 @@ bool OpenPagesManager::pagesOpenForNamespace(const QString &nameSpace) const void OpenPagesManager::setCurrentPage(const QModelIndex &index) { TRACE_OBJ - if (!index.isValid()) - return; - HelpViewer * const page = m_model->pageAt(index.row()); - CentralWidget::instance()->setCurrentPage(page); + if (index.isValid()) + setCurrentPage(index.row()); } void OpenPagesManager::setCurrentPage(int index) { TRACE_OBJ CentralWidget::instance()->setCurrentPage(m_model->pageAt(index)); - selectCurrentPage(); -} - -void OpenPagesManager::selectCurrentPage() -{ - TRACE_OBJ - QItemSelectionModel * const selModel = m_openPagesWidget->selectionModel(); - selModel->clearSelection(); - selModel->select(m_model->index(CentralWidget::instance()->currentIndex(), 0), - QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - m_openPagesWidget->scrollTo(m_openPagesWidget->currentIndex()); + m_openPagesWidget->selectCurrentPage(); } void OpenPagesManager::removePage(int index) @@ -262,7 +273,7 @@ void OpenPagesManager::removePage(int index) TRACE_OBJ CentralWidget::instance()->removePage(index); m_model->removePage(index); - selectCurrentPage(); + m_openPagesWidget->selectCurrentPage(); } @@ -294,12 +305,36 @@ void OpenPagesManager::nextPage() nextOrPreviousPage(1); } +void OpenPagesManager::nextPageWithSwitcher() +{ + TRACE_OBJ + if (!m_openPagesSwitcher->isVisible()) { + m_openPagesSwitcher->selectCurrentPage(); + m_openPagesSwitcher->gotoNextPage(); + showSwitcherOrSelectPage(); + } else { + m_openPagesSwitcher->gotoNextPage(); + } +} + void OpenPagesManager::previousPage() { TRACE_OBJ nextOrPreviousPage(-1); } +void OpenPagesManager::previousPageWithSwitcher() +{ + TRACE_OBJ + if (!m_openPagesSwitcher->isVisible()) { + m_openPagesSwitcher->selectCurrentPage(); + m_openPagesSwitcher->gotoPreviousPage(); + showSwitcherOrSelectPage(); + } else { + m_openPagesSwitcher->gotoPreviousPage(); + } +} + void OpenPagesManager::nextOrPreviousPage(int offset) { TRACE_OBJ @@ -307,6 +342,19 @@ void OpenPagesManager::nextOrPreviousPage(int offset) + m_model->rowCount()) % m_model->rowCount()); } -OpenPagesManager *OpenPagesManager::m_instance = 0; +void OpenPagesManager::showSwitcherOrSelectPage() const +{ + TRACE_OBJ + if (QApplication::keyboardModifiers() != Qt::NoModifier) { + const int width = CentralWidget::instance()->width(); + const int height = CentralWidget::instance()->height(); + const QPoint p(CentralWidget::instance()->mapToGlobal(QPoint(0, 0))); + m_openPagesSwitcher->move((width - m_openPagesSwitcher->width()) / 2 + p.x(), + (height - m_openPagesSwitcher->height()) / 2 + p.y()); + m_openPagesSwitcher->setVisible(true); + } else { + m_openPagesSwitcher->selectAndHide(); + } +} QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesmanager.h b/tools/assistant/tools/assistant/openpagesmanager.h index 0ae3180..56a1ce7 100644 --- a/tools/assistant/tools/assistant/openpagesmanager.h +++ b/tools/assistant/tools/assistant/openpagesmanager.h @@ -52,6 +52,7 @@ class QUrl; class HelpViewer; class OpenPagesModel; +class OpenPagesSwitcher; class OpenPagesWidget; class OpenPagesManager : public QObject @@ -76,8 +77,11 @@ public slots: HelpViewer *createNewPageFromSearch(const QUrl &url); HelpViewer *createPage(); void closeCurrentPage(); + void nextPage(); + void nextPageWithSwitcher(); void previousPage(); + void previousPageWithSwitcher(); private slots: void setCurrentPage(const QModelIndex &index); @@ -87,13 +91,18 @@ private slots: private: OpenPagesManager(QObject *parent, bool defaultCollection, const QUrl &cmdLineUrl); + ~OpenPagesManager(); + void setupInitialPages(bool defaultCollection, const QUrl &cmdLineUrl); void closeOrReloadPages(const QString &nameSpace, bool tryReload); - void selectCurrentPage(); void removePage(int index); + void nextOrPreviousPage(int offset); + void showSwitcherOrSelectPage() const; + OpenPagesModel *m_model; OpenPagesWidget *m_openPagesWidget; + OpenPagesSwitcher *m_openPagesSwitcher; static OpenPagesManager *m_instance; }; diff --git a/tools/assistant/tools/assistant/openpagesswitcher.cpp b/tools/assistant/tools/assistant/openpagesswitcher.cpp new file mode 100644 index 0000000..d4b7d82 --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesswitcher.cpp @@ -0,0 +1,194 @@ +/**************************************************************************** +** +** 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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "openpagesswitcher.h" + +#include "centralwidget.h" +#include "openpagesmodel.h" +#include "openpageswidget.h" +#include "tracer.h" + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +const int gWidth = 300; +const int gHeight = 200; + +OpenPagesSwitcher::OpenPagesSwitcher(OpenPagesModel *model) + : QFrame(0, Qt::Popup) + , m_openPagesModel(model) +{ + TRACE_OBJ + resize(gWidth, gHeight); + + m_openPagesWidget = new OpenPagesWidget(m_openPagesModel); + + // We disable the frame on this list view and use a QFrame around it instead. + // This improves the look with QGTKStyle. +#ifndef Q_WS_MAC + setFrameStyle(m_openPagesWidget->frameStyle()); +#endif + m_openPagesWidget->setFrameStyle(QFrame::NoFrame); + + m_openPagesWidget->allowContextMenu(false); + m_openPagesWidget->installEventFilter(this); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_openPagesWidget); + + connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, + SIGNAL(closePage(QModelIndex))); + connect(m_openPagesWidget, SIGNAL(setCurrentPage(QModelIndex)), this, + SIGNAL(setCurrentPage(QModelIndex))); +} + +OpenPagesSwitcher::~OpenPagesSwitcher() +{ + TRACE_OBJ +} + +void OpenPagesSwitcher::gotoNextPage() +{ + TRACE_OBJ + selectPageUpDown(1); +} + +void OpenPagesSwitcher::gotoPreviousPage() +{ + TRACE_OBJ + selectPageUpDown(-1); +} + +void OpenPagesSwitcher::selectAndHide() +{ + TRACE_OBJ + setVisible(false); + emit setCurrentPage(m_openPagesWidget->currentIndex()); +} + +void OpenPagesSwitcher::selectCurrentPage() +{ + TRACE_OBJ + m_openPagesWidget->selectCurrentPage(); +} + +void OpenPagesSwitcher::setVisible(bool visible) +{ + TRACE_OBJ + QWidget::setVisible(visible); + if (visible) + setFocus(); +} + +void OpenPagesSwitcher::focusInEvent(QFocusEvent *event) +{ + TRACE_OBJ + Q_UNUSED(event) + m_openPagesWidget->setFocus(); +} + +bool OpenPagesSwitcher::eventFilter(QObject *object, QEvent *event) +{ + TRACE_OBJ + if (object == m_openPagesWidget) { + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + if (ke->key() == Qt::Key_Escape) { + setVisible(false); + return true; + } + + const int key = ke->key(); + if (key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) { + emit setCurrentPage(m_openPagesWidget->currentIndex()); + return true; + } + + Qt::KeyboardModifier modifier = Qt::ControlModifier; +#ifdef Q_WS_MAC + modifier = Qt::AltModifier; +#endif + if (key == Qt::Key_Backtab + && (ke->modifiers() == (modifier | Qt::ShiftModifier))) + gotoPreviousPage(); + else if (key == Qt::Key_Tab && (ke->modifiers() == modifier)) + gotoNextPage(); + } else if (event->type() == QEvent::KeyRelease) { + QKeyEvent *ke = static_cast(event); + if (ke->modifiers() == 0 + /*HACK this is to overcome some event inconsistencies between platforms*/ + || (ke->modifiers() == Qt::AltModifier + && (ke->key() == Qt::Key_Alt || ke->key() == -1))) { + selectAndHide(); + } + } + } + return QWidget::eventFilter(object, event); +} + +void OpenPagesSwitcher::selectPageUpDown(int summand) +{ + TRACE_OBJ + const int pageCount = m_openPagesModel->rowCount(); + if (pageCount < 2) + return; + + const QModelIndexList &list = m_openPagesWidget->selectionModel()->selectedIndexes(); + if (list.isEmpty()) + return; + + QModelIndex index = list.first(); + if (!index.isValid()) + return; + + index = m_openPagesModel->index((index.row() + summand + pageCount) % pageCount, 0); + if (index.isValid()) { + m_openPagesWidget->setCurrentIndex(index); + m_openPagesWidget->scrollTo(index, QAbstractItemView::PositionAtCenter); + } +} + +QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/openpagesswitcher.h b/tools/assistant/tools/assistant/openpagesswitcher.h new file mode 100644 index 0000000..e27db6b --- /dev/null +++ b/tools/assistant/tools/assistant/openpagesswitcher.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 Assistant module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt 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 OPENPAGESSWITCHER_H +#define OPENPAGESSWITCHER_H + +#include + +QT_BEGIN_NAMESPACE + +class OpenPagesModel; +class OpenPagesWidget; +class QModelIndex; + +class OpenPagesSwitcher : public QFrame +{ + Q_OBJECT + +public: + OpenPagesSwitcher(OpenPagesModel *model); + ~OpenPagesSwitcher(); + + void gotoNextPage(); + void gotoPreviousPage(); + + void selectAndHide(); + void selectCurrentPage(); + + void setVisible(bool visible); + void focusInEvent(QFocusEvent *event); + bool eventFilter(QObject *object, QEvent *event); + +signals: + void closePage(const QModelIndex &index); + void setCurrentPage(const QModelIndex &index); + +private: + void selectPageUpDown(int summand); + +private: + OpenPagesModel *m_openPagesModel; + OpenPagesWidget *m_openPagesWidget; +}; + +QT_END_NAMESPACE + +#endif // OPENPAGESSWITCHER_H diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp index 1a5c292..a68da23 100644 --- a/tools/assistant/tools/assistant/openpageswidget.cpp +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -41,6 +41,7 @@ #include "openpageswidget.h" +#include "centralwidget.h" #include "openpagesmodel.h" #include "tracer.h" @@ -90,15 +91,16 @@ void OpenPagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt } } +// -- OpenPagesWidget OpenPagesWidget::OpenPagesWidget(OpenPagesModel *model) + : m_allowContextMenu(true) { TRACE_OBJ setModel(model); setIndentation(0); setItemDelegate((m_delegate = new OpenPagesDelegate(this))); - setFrameStyle(QFrame::NoFrame); setTextElideMode(Qt::ElideMiddle); setAttribute(Qt::WA_MacShowFocusRect, false); @@ -129,11 +131,27 @@ OpenPagesWidget::~OpenPagesWidget() TRACE_OBJ } +void OpenPagesWidget::selectCurrentPage() +{ + TRACE_OBJ + QItemSelectionModel * const selModel = selectionModel(); + selModel->clearSelection(); + selModel->select(model()->index(CentralWidget::instance()->currentIndex(), 0), + QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + scrollTo(currentIndex()); +} + +void OpenPagesWidget::allowContextMenu(bool ok) +{ + TRACE_OBJ + m_allowContextMenu = ok; +} + void OpenPagesWidget::contextMenuRequested(QPoint pos) { TRACE_OBJ QModelIndex index = indexAt(pos); - if (!index.isValid()) + if (!index.isValid() || !m_allowContextMenu) return; if (index.column() == 1) diff --git a/tools/assistant/tools/assistant/openpageswidget.h b/tools/assistant/tools/assistant/openpageswidget.h index 46c0022..4b972f3 100644 --- a/tools/assistant/tools/assistant/openpageswidget.h +++ b/tools/assistant/tools/assistant/openpageswidget.h @@ -67,6 +67,9 @@ public: OpenPagesWidget(OpenPagesModel *model); ~OpenPagesWidget(); + void selectCurrentPage(); + void allowContextMenu(bool ok); + signals: void setCurrentPage(const QModelIndex &index); void closePage(const QModelIndex &index); @@ -80,6 +83,7 @@ private slots: private: bool eventFilter(QObject *obj, QEvent *event); + bool m_allowContextMenu; OpenPagesDelegate *m_delegate; }; -- cgit v0.12 From d20d5611aec3eb2c4be1808250f8eed47e0ebf19 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 2 Jun 2010 14:43:53 +0200 Subject: Remove tst_QStringRef::localeAwareCompare This new test breaks on embedded. --- tests/auto/qstringref/tst_qstringref.cpp | 176 ------------------------------- 1 file changed, 176 deletions(-) diff --git a/tests/auto/qstringref/tst_qstringref.cpp b/tests/auto/qstringref/tst_qstringref.cpp index 2d25efd..585e14e 100644 --- a/tests/auto/qstringref/tst_qstringref.cpp +++ b/tests/auto/qstringref/tst_qstringref.cpp @@ -81,8 +81,6 @@ private slots: void compare_data(); void compare(); void operator_eqeq_nullstring(); - void localeAwareCompare_data(); - void localeAwareCompare(); }; static QStringRef emptyRef() @@ -777,180 +775,6 @@ void tst_QStringRef::operator_eqeq_nullstring() QVERIFY(QString("") == QString()); } -void tst_QStringRef::localeAwareCompare_data() -{ -#ifdef Q_OS_WIN - QTest::addColumn("locale"); -#else - QTest::addColumn("locale"); -#endif - QTest::addColumn("s1"); - QTest::addColumn("s2"); - QTest::addColumn("result"); - - /* - The C locale performs pure byte comparisons for - Latin-1-specific characters(I think). Compare with Swedish - below. - */ -#ifdef Q_OS_WIN // assume c locale to be english - QTest::newRow("c1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << 1; - QTest::newRow("c2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("c3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1; -#else - QTest::newRow("c1") << QString("C") << QString("\xe5") << QString("\xe4") << 1; - QTest::newRow("c2") << QString("C") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("c3") << QString("C") << QString("\xe5") << QString("\xf6") << -1; -#endif - - /* - It's hard to test English, because it's treated differently - on different platforms. For example, on Linux, it uses the - iso14651_t1 template file, which happens to provide good - defaults for Swedish. Mac OS X seems to do a pure bytewise - comparison of Latin-1 values, although I'm not sure. So I - just test digits to make sure that it's not totally broken. - */ -#ifdef Q_OS_WIN - QTest::newRow("english1") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("4") << 1; - QTest::newRow("english2") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("4") << QString("6") << -1; - QTest::newRow("english3") << MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) << QString("5") << QString("6") << -1; -#else - QTest::newRow("english1") << QString("en_US") << QString("5") << QString("4") << 1; - QTest::newRow("english2") << QString("en_US") << QString("4") << QString("6") << -1; - QTest::newRow("english3") << QString("en_US") << QString("5") << QString("6") << -1; -#endif - /* - In Swedish, a with ring above(E5) comes before a with - diaresis(E4), which comes before o diaresis(F6), which - all come after z. - */ -#ifdef Q_OS_MAC - QTest::newRow("swedish1") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xe4") << -1; - QTest::newRow("swedish2") << QString("sv_SE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("swedish3") << QString("sv_SE.ISO8859-1") << QString("\xe5") << QString("\xf6") << -1; - QTest::newRow("swedish4") << QString("sv_SE.ISO8859-1") << QString("z") << QString("\xe5") << -1; -#elif defined(Q_OS_WIN) - QTest::newRow("swedish1") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xe4") << -1; - QTest::newRow("swedish2") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("swedish3") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("\xe5") << QString("\xf6") << -1; - QTest::newRow("swedish4") << MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_SWEDISH), SORT_DEFAULT) << QString("z") << QString("\xe5") << -1; -#else - QTest::newRow("swedish1") << QString("sv_SE") << QString("\xe5") << QString("\xe4") << -1; - QTest::newRow("swedish2") << QString("sv_SE") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("swedish3") << QString("sv_SE") << QString("\xe5") << QString("\xf6") << -1; - QTest::newRow("swedish4") << QString("sv_SE") << QString("z") << QString("\xe5") << -1; -#endif - -#if 0 - /* - In Norwegian, ae(E6) comes before o with stroke(D8), which - comes before a with ring above(E5). - */ - QTest::newRow("norwegian1") << QString("no_NO") << QString("\xe6") << QString("\xd8") << -1; - QTest::newRow("norwegian2") << QString("no_NO") << QString("\xd8") << QString("\xe5") << -1; - QTest::newRow("norwegian3") << QString("no_NO") << QString("\xe6") << QString("\xe5") << -1; -#endif - - /* - In German, z comes *after* a with diaresis(E4), - which comes before o diaresis(F6). - */ -#ifdef Q_OS_MAC - QTest::newRow("german1") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xe4") << 1; - QTest::newRow("german2") << QString("de_DE.ISO8859-1") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("german3") << QString("de_DE.ISO8859-1") << QString("z") << QString("\xf6") << 1; -#elif defined(Q_OS_WIN) - QTest::newRow("german1") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xe4") << 1; - QTest::newRow("german2") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("german3") << MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT) << QString("z") << QString("\xf6") << 1; -#else - QTest::newRow("german1") << QString("de_DE") << QString("z") << QString("\xe4") << 1; - QTest::newRow("german2") << QString("de_DE") << QString("\xe4") << QString("\xf6") << -1; - QTest::newRow("german3") << QString("de_DE") << QString("z") << QString("\xf6") << 1; -#endif -} - -void tst_QStringRef::localeAwareCompare() -{ -#ifdef Q_OS_WIN -# ifndef Q_OS_WINCE - QSKIP("On others than Win CE, we cannot set the system or user locale.", SkipAll); -# endif - QFETCH(ulong, locale); -#else - QFETCH(QString, locale); -#endif - QFETCH(QString, s1); - QFETCH(QString, s2); - - const QString padded1 = QString::fromLatin1(" %1 ").arg(s1); - const QString padded2 = QString::fromLatin1(" %2 ").arg(s2); - const QStringRef ref1 = padded1.midRef(1, s1.size()); - const QStringRef ref2 = padded2.midRef(1, s2.size()); - - QFETCH(int, result); - - -#ifdef Q_OS_WIN -# if defined(Q_OS_WINCE) - DWORD oldLcid = GetUserDefaultLCID(); - SetUserDefaultLCID(locale); - - QCOMPARE(locale, GetUserDefaultLCID()); -# else - DWORD oldLcid = GetThreadLocale(); - SetThreadLocale(locale); - - QCOMPARE(locale, GetThreadLocale()); -# endif - -#elif defined(Q_WS_MAC) - QSKIP("Setting the locale is not supported on OS X(you can set the C locale, but that won't affect CFStringCompare which is used to compare strings)", SkipAll); -#else - if (!locale.isEmpty()) { - const char *newLocale = setlocale(LC_ALL, locale.toLatin1()); - if (!newLocale) { - setlocale(LC_ALL, ""); - QSKIP("Please install the proper locale on this machine to test properly", SkipSingle); - return; - } - } -#endif - - int testres = QStringRef::localeAwareCompare(ref1, ref2); - if (result < 0) { - QVERIFY(testres < 0); - } else if (result > 0) { - QVERIFY(testres > 0); - } else { - QVERIFY(testres == 0); - } - - - testres = QStringRef::localeAwareCompare(ref2, ref1); - if (result > 0) { - QVERIFY(testres < 0); - } else if (result < 0) { - QVERIFY(testres > 0); - } else { - QVERIFY(testres == 0); - } - -#ifdef Q_OS_WIN -# if defined(Q_OS_WINCE) - SetUserDefaultLCID(oldLcid); -# else - SetThreadLocale(oldLcid); -# endif - -#else - if (!locale.isEmpty()) - setlocale(LC_ALL, ""); -#endif -} - - static inline int sign(int x) { return x == 0 ? 0 : (x < 0 ? -1 : 1); -- cgit v0.12 From ad3d90572e2a5ed9ab63553ee3e5be3db5c957a3 Mon Sep 17 00:00:00 2001 From: Ian Walters Date: Wed, 28 Apr 2010 10:59:54 +1000 Subject: Fix LeftToRight + setSpacing + setWrapping when drag-and-dropping Quite a number of assumptions in qlistview assume either wrapping or spacing, but not both. This fixes the Flow left to right case. The TopToBottom case is not affected. TopToBottom + wrapping still works TopToBottom + spacing still works, TopToBottom + spacing + wrapping is still as broken as ever. Drag move prior to this patch was correct, but also need the drop to use the spacing when determining what index to apply to, not just the drag move. Reviewed-by: gabi Merge-Request: 586 Task-number: QTBUG-8938 --- src/gui/itemviews/qabstractitemview_p.h | 2 +- src/gui/itemviews/qlistview.cpp | 95 ++++++++++++++++++++++++++++++--- src/gui/itemviews/qlistview_p.h | 2 + 3 files changed, 90 insertions(+), 9 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index fce74f3..b9408a5 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -136,7 +136,7 @@ public: void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;} - bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); + virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); bool droppingOnItself(QDropEvent *event, const QModelIndex &index); QWidget *editor(const QModelIndex &index, const QStyleOptionViewItem &options); diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 1869093..846d911 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1833,6 +1833,14 @@ QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint else return QAbstractItemViewPrivate::position(pos, rect, idx); } + +bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex) +{ + if (viewMode == QListView::ListMode && flow == QListView::LeftToRight) + return static_cast(commonListView)->dropOn(event, dropRow, dropCol, dropIndex); + else + return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex); +} #endif /* @@ -1960,7 +1968,13 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) // ignore by default event->ignore(); - QModelIndex index = qq->indexAt(event->pos()); + // can't use indexAt, doesn't account for spacing. + QPoint p = event->pos(); + QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); + rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); + const QVector intersectVector = dd->intersectingSet(rect); + QModelIndex index = intersectVector.count() > 0 + ? intersectVector.last() : QModelIndex(); dd->hover = index; if (!dd->droppingOnItself(event, index) && dd->canDecode(event)) { @@ -1968,10 +1982,11 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) if (index.isValid() && dd->showDropIndicator) { QRect rect = qq->visualRect(index); dd->dropIndicatorPosition = position(event->pos(), rect, index); + // if spacing, should try to draw between items, not just next to item. switch (dd->dropIndicatorPosition) { case QAbstractItemView::AboveItem: if (dd->isIndexDropEnabled(index.parent())) { - dd->dropIndicatorRect = QRect(rect.left(), rect.top(), 0, rect.height()); + dd->dropIndicatorRect = QRect(rect.left()-dd->spacing(), rect.top(), 0, rect.height()); event->accept(); } else { dd->dropIndicatorRect = QRect(); @@ -1979,7 +1994,7 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) break; case QAbstractItemView::BelowItem: if (dd->isIndexDropEnabled(index.parent())) { - dd->dropIndicatorRect = QRect(rect.right(), rect.top(), 0, rect.height()); + dd->dropIndicatorRect = QRect(rect.right()+dd->spacing(), rect.top(), 0, rect.height()); event->accept(); } else { dd->dropIndicatorRect = QRect(); @@ -2014,6 +2029,68 @@ void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event) qq->startAutoScroll(); } +/*! + If the event hasn't already been accepted, determines the index to drop on. + + if (row == -1 && col == -1) + // append to this drop index + else + // place at row, col in drop index + + If it returns true a drop can be done, and dropRow, dropCol and dropIndex reflects the position of the drop. + \internal + */ +bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex) +{ + if (event->isAccepted()) + return false; + + QModelIndex index; + if (dd->viewport->rect().contains(event->pos())) { + // can't use indexAt, doesn't account for spacing. + QPoint p = event->pos(); + QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1); + rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing()); + const QVector intersectVector = dd->intersectingSet(rect); + index = intersectVector.count() > 0 + ? intersectVector.last() : QModelIndex(); + if (!index.isValid()) + index = dd->root; + } + + // If we are allowed to do the drop + if (dd->model->supportedDropActions() & event->dropAction()) { + int row = -1; + int col = -1; + if (index != dd->root) { + dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index); + switch (dd->dropIndicatorPosition) { + case QAbstractItemView::AboveItem: + row = index.row(); + col = index.column(); + index = index.parent(); + break; + case QAbstractItemView::BelowItem: + row = index.row() + 1; + col = index.column(); + index = index.parent(); + break; + case QAbstractItemView::OnItem: + case QAbstractItemView::OnViewport: + break; + } + } else { + dd->dropIndicatorPosition = QAbstractItemView::OnViewport; + } + *dropIndex = index; + *dropRow = row; + *dropCol = col; + if (!dd->droppingOnItself(event, index)) + return true; + } + return false; +} + #endif //QT_NO_DRAGANDDROP void QListModeViewBase::updateVerticalScrollBar(const QSize &step) @@ -2107,7 +2184,7 @@ int QListModeViewBase::verticalOffset() const int value = verticalScrollBar()->value(); if (value >= segmentPositions.count()) return 0; - return segmentPositions.at(value); + return segmentPositions.at(value) - spacing(); } } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) { int value = verticalScrollBar()->value(); @@ -2155,14 +2232,14 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) if (horizontal && flow() == QListView::TopToBottom && dx != 0) { int currentValue = qBound(0, horizontalValue, max); int previousValue = qBound(0, currentValue + dx, max); - int currentCoordinate = segmentPositions.at(currentValue); - int previousCoordinate = segmentPositions.at(previousValue); + int currentCoordinate = segmentPositions.at(currentValue) - spacing(); + int previousCoordinate = segmentPositions.at(previousValue) - spacing(); dx = previousCoordinate - currentCoordinate; } else if (vertical && flow() == QListView::LeftToRight && dy != 0) { int currentValue = qBound(0, verticalValue, max); int previousValue = qBound(0, currentValue + dy, max); - int currentCoordinate = segmentPositions.at(currentValue); - int previousCoordinate = segmentPositions.at(previousValue); + int currentCoordinate = segmentPositions.at(currentValue) - spacing(); + int previousCoordinate = segmentPositions.at(previousValue) - spacing(); dy = previousCoordinate - currentCoordinate; } } else { @@ -2330,6 +2407,8 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) segmentExtents.append(flowPosition); flowPosition = info.spacing + segStartPosition; segPosition += deltaSegPosition; + if (info.wrap) + segPosition += info.spacing; segmentPositions.append(segPosition); segmentStartRows.append(row); deltaSegPosition = 0; diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index bf7657b..9ae1f50 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -237,6 +237,7 @@ public: // WARNING: Plenty of duplicated code from QAbstractItemView{,Private}. QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; void dragMoveEvent(QDragMoveEvent *e); + bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); #endif private: @@ -364,6 +365,7 @@ public: #ifndef QT_NO_DRAGANDDROP virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const; + bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); #endif inline void setGridSize(const QSize &size) { grid = size; } -- 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 919ce79845d077f2509d6cc0f8fac50d339175b3 Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 2 Jun 2010 15:54:45 +0200 Subject: Remove leftover. Reviewed-by: ck --- tools/assistant/tools/assistant/contentwindow.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/assistant/tools/assistant/contentwindow.h b/tools/assistant/tools/assistant/contentwindow.h index 62855dd..658e74e 100644 --- a/tools/assistant/tools/assistant/contentwindow.h +++ b/tools/assistant/tools/assistant/contentwindow.h @@ -76,7 +76,6 @@ private: void focusInEvent(QFocusEvent *e); void keyPressEvent(QKeyEvent *e); bool eventFilter(QObject *o, QEvent *e); - bool isPdfFile(QHelpContentItem *item) const; QHelpContentWidget * const m_contentWidget; int m_expandDepth; -- 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 27c4c963de1a28afa95e7837fa844ae8a3bccd2c Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 3 Jun 2010 14:23:52 +0200 Subject: Make the open pages widget act on the up/ down key directly. Reviewed-by: ck --- .../assistant/tools/assistant/openpageswidget.cpp | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/assistant/tools/assistant/openpageswidget.cpp b/tools/assistant/tools/assistant/openpageswidget.cpp index a68da23..b7ac33e 100644 --- a/tools/assistant/tools/assistant/openpageswidget.cpp +++ b/tools/assistant/tools/assistant/openpageswidget.cpp @@ -134,10 +134,15 @@ OpenPagesWidget::~OpenPagesWidget() void OpenPagesWidget::selectCurrentPage() { TRACE_OBJ + const QModelIndex ¤t = + model()->index(CentralWidget::instance()->currentIndex(), 0); + QItemSelectionModel * const selModel = selectionModel(); - selModel->clearSelection(); - selModel->select(model()->index(CentralWidget::instance()->currentIndex(), 0), + selModel->select(current, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + selModel->clearSelection(); + + setCurrentIndex(current); scrollTo(currentIndex()); } @@ -204,18 +209,27 @@ void OpenPagesWidget::handleClicked(const QModelIndex &index) bool OpenPagesWidget::eventFilter(QObject *obj, QEvent *event) { TRACE_OBJ - if (obj == this && event->type() == QEvent::KeyPress) { - if (currentIndex().isValid()) { - QKeyEvent *ke = static_cast(event); + if (obj != this) + return QWidget::eventFilter(obj, event); + + if (event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast(event); + if (currentIndex().isValid() && ke->modifiers() == 0) { const int key = ke->key(); - if ((key == Qt::Key_Return || key == Qt::Key_Enter || key == Qt::Key_Space) - && ke->modifiers() == 0) { + if (key == Qt::Key_Return || key == Qt::Key_Enter + || key == Qt::Key_Space) { emit setCurrentPage(currentIndex()); } else if ((key == Qt::Key_Delete || key == Qt::Key_Backspace) - && ke->modifiers() == 0 && model()->rowCount() > 1) { + && model()->rowCount() > 1) { emit closePage(currentIndex()); } } + } else if (event->type() == QEvent::KeyRelease) { + QKeyEvent *ke = static_cast(event); + if (ke->modifiers() == 0 + && (ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down)) { + emit setCurrentPage(currentIndex()); + } } return QWidget::eventFilter(obj, event); } -- cgit v0.12 From a64791bdf663fb1d7595f11fbe7e44a62acd4126 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 3 Jun 2010 16:55:38 +0200 Subject: QItemSelectionModel: When rows are removed from the middle of the range, remove them from the selection. Merge-request: 2403 Reviewed-by: Olivier Goffart --- src/gui/itemviews/qitemselectionmodel.cpp | 18 +++++--- .../tst_qitemselectionmodel.cpp | 48 ++++++++++++++++++++++ 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index f848321..4979db6 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -634,6 +634,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } QItemSelection deselected; + QItemSelection newParts; QItemSelection::iterator it = ranges.begin(); while (it != ranges.end()) { if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range @@ -659,13 +660,20 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight())); *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); ++it; - } else { - if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing) - deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), - model->index(end, it->left(), it->parent()))); + } else if (it->top() < start && end < it->bottom()) { // Middle intersection + // If the parent contains (1, 2, 3, 4, 5, 6, 7, 8) and [3, 4, 5, 6] is selected, + // and [4, 5] is removed, we need to split [3, 4, 5, 6] into [3], [4, 5] and [6]. + // [4, 5] is appended to deselected, and [3] and [6] remain part of the selection + // in ranges. + const QItemSelectionRange removedRange(model->index(start, it->right(), it->parent()), + model->index(end, it->left(), it->parent())); + deselected.append(removedRange); + QItemSelection::split(*it, removedRange, &newParts); + it = ranges.erase(it); + } else ++it; - } } + ranges.append(newParts); if (!deselected.isEmpty()) emit q->selectionChanged(QItemSelection(), deselected); diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 3b2a716..bfe306d 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -94,6 +94,7 @@ private slots: void task260134_layoutChangedWithAllSelected(); void QTBUG5671_layoutChangedWithAllSelected(); void QTBUG2804_layoutChangedTreeSelection(); + void deselectRemovedMiddleRange(); private: QAbstractItemModel *model; @@ -2353,6 +2354,53 @@ void tst_QItemSelectionModel::QTBUG2804_layoutChangedTreeSelection() QCOMPARE(selModel.selectedIndexes().count(), 4); } +class RemovalObserver : public QObject +{ + Q_OBJECT + QItemSelectionModel *m_itemSelectionModel; +public: + RemovalObserver(QItemSelectionModel *selectionModel) + : m_itemSelectionModel(selectionModel) + { + connect(m_itemSelectionModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(selectionChanged(QItemSelection, QItemSelection))); + } + +public slots: + void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) + { + foreach(const QModelIndex &index, deselected.indexes()) { + QVERIFY(!m_itemSelectionModel->selection().contains(index)); + } + QVERIFY(m_itemSelectionModel->selection().size() == 2); + } + +}; + +void tst_QItemSelectionModel::deselectRemovedMiddleRange() +{ + QStandardItemModel model(8, 0); + + for (int row = 0; row < 8; ++row) { + static const int column = 0; + QStandardItem *item = new QStandardItem(QString::number(row)); + model.setItem(row, column, item); + } + + QItemSelectionModel selModel(&model); + + selModel.select(QItemSelection(model.index(3, 0), model.index(6, 0)), QItemSelectionModel::Select); + + QVERIFY(selModel.selection().size() == 1); + + RemovalObserver ro(&selModel); + + QSignalSpy spy(&selModel, SIGNAL(selectionChanged(QItemSelection, QItemSelection))); + bool ok = model.removeRows(4, 2); + + QVERIFY(ok); + QVERIFY(spy.size() == 1); +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- cgit v0.12 From cad70d64d0bbada72a072ac7fdf461839db9d72a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 3 May 2010 09:55:44 +0200 Subject: New class: QGlyphs Introduce an API to access glyph indexes in a font directly. A bug was discovered during this work, where different hinting flags in loadGlyph() and loadGlyphMetrics() would make the metrics in the two functions different, thus causing drawCachedGlyphs() (which uses loadGlyphMetrics() indirectly) to use different metrics than the standard drawTextItem() code path (which uses loadGlyph()). The bug was visible in the tst_QGlyphs::drawExistingGlyphs() test. Reviewed-by: Simon Hausmann --- src/gui/painting/qpainter.cpp | 52 +++-- src/gui/painting/qpainter.h | 3 + src/gui/painting/qpainter_p.h | 3 +- src/gui/text/qfont.h | 1 + src/gui/text/qfontengine.cpp | 18 ++ src/gui/text/qfontengine_ft.cpp | 9 + src/gui/text/qfontengine_mac.mm | 27 +++ src/gui/text/qfontengine_p.h | 9 +- src/gui/text/qglyphs.cpp | 199 +++++++++++++++++ src/gui/text/qglyphs.h | 96 +++++++++ src/gui/text/qglyphs_p.h | 84 ++++++++ src/gui/text/qtextlayout.cpp | 136 ++++++++++++ src/gui/text/qtextlayout.h | 5 + src/gui/text/text.pri | 7 +- tests/auto/qglyphs/qglyphs.pro | 5 + tests/auto/qglyphs/test.ttf | Bin 0 -> 3712 bytes tests/auto/qglyphs/tst_qglyphs.cpp | 431 +++++++++++++++++++++++++++++++++++++ 17 files changed, 1069 insertions(+), 16 deletions(-) create mode 100644 src/gui/text/qglyphs.cpp create mode 100644 src/gui/text/qglyphs.h create mode 100644 src/gui/text/qglyphs_p.h create mode 100644 tests/auto/qglyphs/qglyphs.pro create mode 100644 tests/auto/qglyphs/test.ttf create mode 100644 tests/auto/qglyphs/tst_qglyphs.cpp diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index dd3584a..cb56ac8 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -61,6 +61,8 @@ #include "qstyle.h" #include "qthread.h" #include "qvarlengtharray.h" +#include "qstatictext.h" +#include "qglyphs.h" #include #include @@ -70,8 +72,8 @@ #include #include #include -#include #include +#include QT_BEGIN_NAMESPACE @@ -5704,16 +5706,47 @@ void QPainter::drawImage(const QRectF &targetRect, const QImage &image, const QR d->engine->drawImage(QRectF(x, y, w, h), image, QRectF(sx, sy, sw, sh), flags); } +/*! + Draws the glyphs represented by \a glyphs at \a position. The \a position gives the + edge of the baseline for the string of glyphs. The glyphs will be retrieved from the font + selected on \a glyphs and at offsets given by the positions in \a glyphs. + + \since 4.8 + + \sa QGlyphs::setFont(), QGlyphs::setPositions(), QGlyphs::setGlyphIndexes() +*/ +void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) +{ + Q_D(QPainter); + + QFont oldFont = d->state->font; + d->state->font = glyphs.font(); + + QVector glyphIndexes = glyphs.glyphIndexes(); + QVector glyphPositions = glyphs.positions(); + + int count = qMin(glyphIndexes.size(), glyphPositions.size()); + QVarLengthArray fixedPointPositions(count); + for (int i=0; idrawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count); + + d->state->font = oldFont; +} void qt_draw_glyphs(QPainter *painter, const quint32 *glyphArray, const QPointF *positionArray, int glyphCount) -{ +{ + QVarLengthArray positions(glyphCount); + for (int i=0; idrawGlyphs(glyphArray, positionArray, glyphCount); + painter_d->drawGlyphs(const_cast(glyphArray), positions.data(), glyphCount); } -void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *positionArray, - int glyphCount) +void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount) { updateState(state); @@ -5729,11 +5762,6 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit fontEngine = static_cast(fontEngine)->engine(engineIdx); } - QVarLengthArray positions; - for (int i=0; i(const_cast(glyphArray)); - staticTextItem.glyphPositions = positions.data(); + staticTextItem.glyphPositions = positions; extended->drawStaticTextItem(&staticTextItem); } else { @@ -5759,7 +5787,7 @@ void QPainterPrivate::drawGlyphs(const quint32 *glyphArray, const QPointF *posit textItem.glyphs.numGlyphs = glyphCount; textItem.glyphs.glyphs = reinterpret_cast(const_cast(glyphArray)); - textItem.glyphs.offsets = positions.data(); + textItem.glyphs.offsets = positions; textItem.glyphs.advances_x = advances.data(); textItem.glyphs.advances_y = advances.data(); textItem.glyphs.justifications = glyphJustifications.data(); diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index edfb67e..85751a9 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -79,6 +79,7 @@ class QTextItem; class QMatrix; class QTransform; class QStaticText; +class QGlyphs; class QPainterPrivateDeleter; @@ -396,6 +397,8 @@ public: void setLayoutDirection(Qt::LayoutDirection direction); Qt::LayoutDirection layoutDirection() const; + void drawGlyphs(const QPointF &position, const QGlyphs &glyphs); + void drawStaticText(const QPointF &topLeftPosition, const QStaticText &staticText); inline void drawStaticText(const QPoint &topLeftPosition, const QStaticText &staticText); inline void drawStaticText(int left, int top, const QStaticText &staticText); diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 9362dbe..a61f5ca 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE class QPaintEngine; class QEmulationPaintEngine; class QPaintEngineEx; +struct QFixedPoint; struct QTLWExtra; @@ -228,7 +229,7 @@ public: void draw_helper(const QPainterPath &path, DrawOperation operation = StrokeAndFillDraw); void drawStretchedGradient(const QPainterPath &path, DrawOperation operation); void drawOpaqueBackground(const QPainterPath &path, DrawOperation operation); - void drawGlyphs(const quint32 *glyphArray, const QPointF *positionArray, int glyphCount); + void drawGlyphs(quint32 *glyphArray, QFixedPoint *positionArray, int glyphCount); void updateMatrix(); void updateInvMatrix(); diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index 6f62424..b0e405e 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -312,6 +312,7 @@ private: friend class QPainterReplayer; friend class QPaintBufferEngine; friend class QCommandLinkButtonPrivate; + friend class QFontEngine; #ifndef QT_NO_DATASTREAM friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &); diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 194c5f3..2d95bae 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -242,6 +242,24 @@ glyph_metrics_t QFontEngine::boundingBox(glyph_t glyph, const QTransform &matrix return metrics; } +QFont QFontEngine::createExplicitFont() const +{ + return createExplicitFontWithName(fontDef.family); +} + +QFont QFontEngine::createExplicitFontWithName(const QString &familyName) const +{ + QFont font(familyName); + font.setStyleStrategy(QFont::NoFontMerging); + font.setWeight(fontDef.weight); + font.setItalic(fontDef.style == QFont::StyleItalic); + if (fontDef.pointSize < 0) + font.setPixelSize(fontDef.pixelSize); + else + font.setPointSizeF(fontDef.pointSize); + return font; +} + QFixed QFontEngine::xHeight() const { QGlyphLayoutArray<8> glyphs; diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 9056012..7376893 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -756,9 +756,18 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph return g; int load_flags = FT_LOAD_DEFAULT | default_load_flags; + int load_target = default_hint_style == HintLight + ? FT_LOAD_TARGET_LIGHT + : FT_LOAD_TARGET_NORMAL; + if (set->outline_drawing) load_flags = FT_LOAD_NO_BITMAP; + if (default_hint_style == HintNone) + load_flags |= FT_LOAD_NO_HINTING; + else + load_flags |= load_target; + // apply our matrix to this, but note that the metrics will not be affected by this. FT_Face face = lockFace(); FT_Matrix matrix = this->matrix; diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm index 3be6d28..c9b5655 100644 --- a/src/gui/text/qfontengine_mac.mm +++ b/src/gui/text/qfontengine_mac.mm @@ -607,6 +607,12 @@ void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *position } } +QFont QCoreTextFontEngine::createExplicitFont() const +{ + QString familyName = QCFString::toQString(CTFontCopyFamilyName(ctfont)); + return createExplicitFontWithName(familyName); +} + QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, int margin, bool aa) { const glyph_metrics_t br = boundingBox(glyph); @@ -1542,6 +1548,27 @@ static void addGlyphsToPathHelper(ATSUStyle style, glyph_t *glyphs, QFixedPoint DisposeATSCubicClosePathUPP(closePath); } +QFont QFontEngineMac::createExplicitFont() const +{ + FMFont fmFont = FMGetFontFromATSFontRef(fontID); + + FMFontFamily fmFamily; + FMFontStyle fmStyle; + QString familyName; + if (!FMGetFontFamilyInstanceFromFont(fmFont, &fmFamily, &fmStyle)) { + ATSFontFamilyRef familyRef = FMGetATSFontFamilyRefFromFontFamily(fmFamily); + QCFString cfFamilyName;; + ATSFontFamilyGetName(familyRef, kATSOptionFlagsDefault, &cfFamilyName); + familyName = cfFamilyName; + } else { + QCFString cfFontName; + ATSFontGetName(fontID, kATSOptionFlagsDefault, &cfFontName); + familyName = cfFontName; + } + + return createExplicitFontWithName(familyName); +} + void QFontEngineMac::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path, QTextItem::RenderFlags) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 922acfb..d29ef45 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -173,6 +173,10 @@ public: #endif virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags); + + /* Creates a QFont object to represent this particular QFontEngine */ + virtual QFont createExplicitFont() const; + void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray &glyphs_out, QVarLengthArray &positions); @@ -252,6 +256,7 @@ public: int glyphFormat; protected: + QFont createExplicitFontWithName(const QString &familyName) const; static const QVector &grayPalette(); private: @@ -454,7 +459,7 @@ public: virtual QImage alphaRGBMapForGlyph(glyph_t, int margin, const QTransform &t); virtual qreal minRightBearing() const; virtual qreal minLeftBearing() const; - + virtual QFont createExplicitFont() const; private: QImage imageForGlyph(glyph_t glyph, int margin, bool colorful); @@ -520,6 +525,8 @@ public: virtual qreal maxCharWidth() const; virtual QFixed averageCharWidth() const; + virtual QFont createExplicitFont() const; + virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int numGlyphs, QPainterPath *path, QTextItem::RenderFlags); diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphs.cpp new file mode 100644 index 0000000..847646e --- /dev/null +++ b/src/gui/text/qglyphs.cpp @@ -0,0 +1,199 @@ +#include "qglyphs.h" +#include "qglyphs_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QGlyphs + \brief the QGlyphs class provides direct access to the internal glyphs in a font + \since 4.8 + + \ingroup text + \mainclass + + When Qt displays a string of text encoded in Unicode, it will first convert the Unicode points + into a list of glyph indexes and a list of positions based on one or more fonts. The Unicode + representation of the text and the QFont object will in this case serve as a convenient + abstraction that hides the details of what actually takes place when displaying the text + on-screen. For instance, by the time the text actually reaches the screen, it may be represented + by a set of fonts in addition to the one specified by the user, e.g. in case the originally + selected font did not support all the writing systems contained in the text. + + Under certain circumstances, it can be useful as an application developer to have more low-level + control over which glyphs in a specific font are drawn to the screen. This could for instance + be the case in applications that use an external font engine and text shaper together with Qt. + QGlyphs provides an interface to the raw data needed to get text on the screen. It + contains a list of glyph indexes, a position for each glyph and a font. + + It is the user's responsibility to ensure that the selected font actually contains the + provided glyph indexes. + + QTextLayout::glyphs() can be used to convert unicode encoded text into a list of QGlyphs + objects, and QPainter::drawGlyphs() can be used to draw the glyphs. +*/ + + +/*! + Constructs an empty QGlyphs object. +*/ +QGlyphs::QGlyphs() : d(new QGlyphsPrivate) +{ +} + +/*! + Constructs a QGlyphs object which is a copy of \a other. +*/ +QGlyphs::QGlyphs(const QGlyphs &other) +{ + d = other.d; +} + +/*! + Destroys the QGlyphs. +*/ +QGlyphs::~QGlyphs() +{ + // Required for QExplicitlySharedDataPointer +} + +/*! + \internal +*/ +void QGlyphs::detach() +{ + if (d->ref != 1) + d.detach(); +} + +/*! + Assigns \a other to this QGlyphs object. +*/ +QGlyphs &QGlyphs::operator=(const QGlyphs &other) +{ + d = other.d; + return *this; +} + +/*! + Compares \a other to this QGlyphs object. Returns true if the list of glyph indexes, + the list of positions and the font are all equal, otherwise returns false. +*/ +bool QGlyphs::operator==(const QGlyphs &other) const +{ + return ((d == other.d) + || (d->glyphIndexes == other.d->glyphIndexes + && d->glyphPositions == other.d->glyphPositions + && d->font == other.d->font)); +} + +/*! + Compares \a other to this QGlyphs object. Returns true if any of the list of glyph + indexes, the list of positions or the font are different, otherwise returns false. +*/ +bool QGlyphs::operator!=(const QGlyphs &other) const +{ + return !(*this == other); +} + +/*! + \internal + + Adds together the lists of glyph indexes and positions in \a other and this QGlyphs + object and returns the result. The font in the returned QGlyphs will be the same as in + this QGlyphs object. +*/ +QGlyphs QGlyphs::operator+(const QGlyphs &other) const +{ + QGlyphs ret(*this); + ret += other; + return ret; +} + +/*! + \internal + + Appends the glyph indexes and positions in \a other to this QGlyphs object and returns + a reference to the current object. +*/ +QGlyphs &QGlyphs::operator+=(const QGlyphs &other) +{ + detach(); + + d->glyphIndexes += other.d->glyphIndexes; + d->glyphPositions += other.d->glyphPositions; + + return *this; +} + +/*! + Returns the font selected for this QGlyphs object. + + \sa setFont() +*/ +QFont QGlyphs::font() const +{ + return d->font; +} + +/*! + Sets the font in which to look up the glyph indexes to \a font. This must be an explicitly + resolvable font which defines glyphs for the specified glyph indexes. + + \sa font(), setGlyphIndexes() +*/ +void QGlyphs::setFont(const QFont &font) +{ + detach(); + d->font = font; +} + +/*! + Returns the glyph indexes for this QGlyphs object. + + \sa setGlyphIndexes(), setPositions() +*/ +QVector QGlyphs::glyphIndexes() const +{ + return d->glyphIndexes; +} + +/*! + Set the glyph indexes for this QGlyphs object to \a glyphIndexes. The glyph indexes must + be valid for the selected font. +*/ +void QGlyphs::setGlyphIndexes(const QVector &glyphIndexes) +{ + detach(); + d->glyphIndexes = glyphIndexes; +} + +/*! + Returns the position of the edge of the baseline for each glyph in this set of glyph indexes. +*/ +QVector QGlyphs::positions() const +{ + return d->glyphPositions; +} + +/*! + Sets the positions of the edge of the baseline for each glyph in this set of glyph indexes to + \a positions. +*/ +void QGlyphs::setPositions(const QVector &positions) +{ + detach(); + d->glyphPositions = positions; +} + +/*! + Clears all data in the QGlyphs object. +*/ +void QGlyphs::clear() +{ + detach(); + d->glyphPositions = QVector(); + d->glyphIndexes = QVector(); + d->font = QFont(); +} + +QT_END_NAMESPACE diff --git a/src/gui/text/qglyphs.h b/src/gui/text/qglyphs.h new file mode 100644 index 0000000..282ecb4 --- /dev/null +++ b/src/gui/text/qglyphs.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 QGLYPHS_H +#define QGLYPHS_H + +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QGlyphsPrivate; +class Q_GUI_EXPORT QGlyphs +{ +public: + QGlyphs(); + QGlyphs(const QGlyphs &other); + ~QGlyphs(); + + QFont font() const; + void setFont(const QFont &font); + + QVector glyphIndexes() const; + void setGlyphIndexes(const QVector &glyphIndexes); + + QVector positions() const; + void setPositions(const QVector &positions); + + void clear(); + + QGlyphs &operator=(const QGlyphs &other); + bool operator==(const QGlyphs &other) const; + bool operator!=(const QGlyphs &other) const; + +private: + friend class QGlyphsPrivate; + friend class QTextLine; + + QGlyphs operator+(const QGlyphs &other) const; + QGlyphs &operator+=(const QGlyphs &other); + + void detach(); + QExplicitlySharedDataPointer d; + +}; + +QT_END_NAMESPACE + +QT_END_HEADER + + +#endif // QGLYPHS_H diff --git a/src/gui/text/qglyphs_p.h b/src/gui/text/qglyphs_p.h new file mode 100644 index 0000000..c39f5d0 --- /dev/null +++ b/src/gui/text/qglyphs_p.h @@ -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 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 QGLYPHS_P_H +#define QGLYPHS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of internal files. This header file may change from version to version +// without notice, or even be removed. +// +// We mean it. +// + +#include +#include "qglyphs.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QGlyphsPrivate: public QSharedData +{ +public: + QGlyphsPrivate() + { + } + + QGlyphsPrivate(const QGlyphsPrivate &other) + : QSharedData(other), glyphIndexes(other.glyphIndexes), glyphPositions(other.glyphPositions), font(other.font) + { + } + + QVector glyphIndexes; + QVector glyphPositions; + QFont font; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QGLYPHS_P_H diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 412c909..b581969 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -52,6 +52,8 @@ #include "qtextformat_p.h" #include "qstyleoption.h" #include "qpainterpath.h" +#include "qglyphs.h" +#include "qglyphs_p.h" #include #include @@ -894,6 +896,7 @@ qreal QTextLayout::maximumWidth() const return d->maxWidth.toReal(); } + /*! \internal */ @@ -1106,6 +1109,24 @@ static inline QRectF clipIfValid(const QRectF &rect, const QRectF &clip) return clip.isValid() ? (rect & clip) : rect; } + +/*! + Returns the glyph indexes and positions for all glyphs in this QTextLayout. This is an + expensive function, and should not be called in a time sensitive context. + + \since 4.8 + + \sa draw(), QPainter::drawGlyphs() +*/ +QList QTextLayout::glyphs() const +{ + QList glyphs; + for (int i=0; ilines.size(); ++i) + glyphs += QTextLine(i, d).glyphs(); + + return glyphs; +} + /*! Draws the whole layout on the painter \a p at the position specified by \a pos. @@ -2135,6 +2156,121 @@ static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const Q } +namespace { + struct GlyphInfo + { + GlyphInfo(const QGlyphLayout &layout, const QPointF &position) + : glyphLayout(layout), itemPosition(position) + { + } + + QGlyphLayout glyphLayout; + QPointF itemPosition; + }; +} + +/*! + \internal + + Returns the glyph indexes and positions for all glyphs in this QTextLine. + + \since 4.8 + + \sa QTextLayout::glyphs() +*/ +QList QTextLine::glyphs() const +{ + const QScriptLine &line = eng->lines[i]; + + if (line.length == 0) + return QList(); + + QHash glyphLayoutHash; + + QTextLineItemIterator iterator(eng, i); + qreal y = line.y.toReal() + line.base().toReal(); + while (!iterator.atEnd()) { + QScriptItem &si = iterator.next(); + QPointF pos(iterator.x.toReal(), y); + + QFont font = eng->font(si); + QGlyphLayout glyphLayout = eng->shapedGlyphs(&si).mid(iterator.glyphsStart, + iterator.glyphsEnd - iterator.glyphsStart); + + if (glyphLayout.numGlyphs > 0) { + QFontEngine *mainFontEngine = font.d->engineForScript(si.analysis.script); + if (mainFontEngine->type() == QFontEngine::Multi) { + QFontEngineMulti *multiFontEngine = static_cast(mainFontEngine); + int start = 0; + int end; + int which = glyphLayout.glyphs[0] >> 24; + for (end = 0; end < glyphLayout.numGlyphs; ++end) { + const int e = glyphLayout.glyphs[end] >> 24; + if (e == which) + continue; + + QGlyphLayout subLayout = glyphLayout.mid(start, end - start); + glyphLayoutHash.insertMulti(multiFontEngine->engine(which), + GlyphInfo(subLayout, pos)); + + start = end; + which = e; + } + + QGlyphLayout subLayout = glyphLayout.mid(start, end - start); + glyphLayoutHash.insertMulti(multiFontEngine->engine(which), + GlyphInfo(subLayout, pos)); + + } else { + glyphLayoutHash.insertMulti(mainFontEngine, + GlyphInfo(glyphLayout, pos)); + } + } + } + + QHash glyphsHash; + + QList keys = glyphLayoutHash.uniqueKeys(); + for (int i=0; icreateExplicitFont(); + + QList glyphLayouts = glyphLayoutHash.values(fontEngine); + for (int j=0; j glyphsArray; + QVarLengthArray positionsArray; + + fontEngine->getGlyphPositions(glyphLayout, QTransform(), 0, glyphsArray, positionsArray); + Q_ASSERT(glyphsArray.size() == positionsArray.size()); + + QVector glyphs; + QVector positions; + for (int i=0; i #include #include +#include QT_BEGIN_HEADER @@ -166,6 +167,8 @@ public: qreal minimumWidth() const; qreal maximumWidth() const; + QList glyphs() const; + QTextEngine *engine() const { return d; } void setFlags(int flags); private: @@ -236,6 +239,8 @@ public: private: QTextLine(int line, QTextEngine *e) : i(line), eng(e) {} void layout_helper(int numGlyphs); + QList glyphs() const; + friend class QTextLayout; int i; QTextEngine *eng; diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri index 9ec3142..4e1e9fa 100644 --- a/src/gui/text/text.pri +++ b/src/gui/text/text.pri @@ -39,7 +39,9 @@ HEADERS += \ text/qzipwriter_p.h \ text/qtextodfwriter_p.h \ text/qstatictext_p.h \ - text/qstatictext.h + text/qstatictext.h \ + text/qglyphs.h \ + text/qglyphs_p.h SOURCES += \ text/qfont.cpp \ @@ -69,7 +71,8 @@ SOURCES += \ text/qcssparser.cpp \ text/qzip.cpp \ text/qtextodfwriter.cpp \ - text/qstatictext.cpp + text/qstatictext.cpp \ + text/qglyphs.cpp win32 { SOURCES += \ diff --git a/tests/auto/qglyphs/qglyphs.pro b/tests/auto/qglyphs/qglyphs.pro new file mode 100644 index 0000000..70920f0 --- /dev/null +++ b/tests/auto/qglyphs/qglyphs.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +QT = core gui + +SOURCES += \ + tst_qglyphs.cpp diff --git a/tests/auto/qglyphs/test.ttf b/tests/auto/qglyphs/test.ttf new file mode 100644 index 0000000..9043a57 Binary files /dev/null and b/tests/auto/qglyphs/test.ttf differ diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp new file mode 100644 index 0000000..c906f10 --- /dev/null +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -0,0 +1,431 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 + +//#define DEBUG_SAVE_IMAGE + +class tst_QGlyphs: public QObject +{ + Q_OBJECT + +private slots: + void initTestCase(); + void cleanupTestCase(); + + void constructionAndDestruction(); + void copyConstructor(); + void assignment(); + void equalsOperator_data(); + void equalsOperator(); + void textLayoutGlyphIndexes(); + void drawExistingGlyphs(); + void drawNonExistentGlyphs(); + void drawMultiScriptText1(); + void drawMultiScriptText2(); + void detach(); + +private: + int m_testFontId; + QFont m_testFont; +}; + +Q_DECLARE_METATYPE(QGlyphs); + +void tst_QGlyphs::initTestCase() +{ + m_testFontId = QFontDatabase::addApplicationFont("test.ttf"); + QVERIFY(m_testFontId >= 0); + + m_testFont = QFont("QtsSpecialTestFont"); + + QCOMPARE(QFontInfo(m_testFont).family(), QString::fromLatin1("QtsSpecialTestFont")); +} + +void tst_QGlyphs::cleanupTestCase() +{ + QFontDatabase::removeApplicationFont(m_testFontId); +} + +void tst_QGlyphs::constructionAndDestruction() +{ + QGlyphs glyphIndexes; +} + +static QGlyphs make_dummy_indexes() +{ + QGlyphs glyphs; + + QVector glyphIndexes; + QVector positions; + QFont font; + font.setPointSize(18); + + glyphIndexes.append(1); + glyphIndexes.append(2); + glyphIndexes.append(3); + + positions.append(QPointF(1, 2)); + positions.append(QPointF(3, 4)); + positions.append(QPointF(5, 6)); + + glyphs.setFont(font); + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(positions); + + return glyphs; +} + +static QGlyphs make_dummy_indexes2() +{ + QGlyphs glyphs; + + QVector glyphIndexes; + QVector positions; + QFont font; + font.setPointSize(26); + + glyphIndexes.append(4); + glyphIndexes.append(5); + glyphIndexes.append(6); + + positions.append(QPointF(7, 8)); + positions.append(QPointF(9, 10)); + positions.append(QPointF(11, 12)); + + glyphs.setFont(font); + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(positions); + + return glyphs; +} + + +void tst_QGlyphs::copyConstructor() +{ + QGlyphs glyphs; + + { + QVector glyphIndexes; + QVector positions; + QFont font; + font.setPointSize(18); + + glyphIndexes.append(1); + glyphIndexes.append(2); + glyphIndexes.append(3); + + positions.append(QPointF(1, 2)); + positions.append(QPointF(3, 4)); + positions.append(QPointF(5, 6)); + + glyphs.setFont(font); + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(positions); + } + + QGlyphs otherGlyphs(glyphs); + QCOMPARE(otherGlyphs.font(), glyphs.font()); + QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes()); + QCOMPARE(glyphs.positions(), otherGlyphs.positions()); +} + +void tst_QGlyphs::assignment() +{ + QGlyphs glyphs(make_dummy_indexes()); + + QGlyphs otherGlyphs = glyphs; + QCOMPARE(otherGlyphs.font(), glyphs.font()); + QCOMPARE(glyphs.glyphIndexes(), otherGlyphs.glyphIndexes()); + QCOMPARE(glyphs.positions(), otherGlyphs.positions()); +} + +void tst_QGlyphs::equalsOperator_data() +{ + QTest::addColumn("one"); + QTest::addColumn("two"); + QTest::addColumn("equals"); + + QGlyphs one(make_dummy_indexes()); + QGlyphs two(make_dummy_indexes()); + + QTest::newRow("Identical") << one << two << true; + + { + QGlyphs busted(two); + + QVector positions = busted.positions(); + positions[2] += QPointF(1, 1); + busted.setPositions(positions); + + QTest::newRow("Different positions") << one << busted << false; + } + + { + QGlyphs busted(two); + QFont font = busted.font(); + font.setPointSize(font.pointSize() * 2); + busted.setFont(font); + + QTest::newRow("Different fonts") << one << busted << false; + } + + { + QGlyphs busted(two); + + QVector glyphIndexes = busted.glyphIndexes(); + glyphIndexes[2] += 1; + busted.setGlyphIndexes(glyphIndexes); + + QTest::newRow("Different glyph indexes") << one << busted << false; + } + +} + +void tst_QGlyphs::equalsOperator() +{ + QFETCH(QGlyphs, one); + QFETCH(QGlyphs, two); + QFETCH(bool, equals); + + QCOMPARE(one == two, equals); + QCOMPARE(one != two, !equals); +} + + +void tst_QGlyphs::textLayoutGlyphIndexes() +{ + QString s; + s.append(QLatin1Char('A')); + s.append(QChar(0xe000)); + + QTextLayout layout(s); + layout.setFont(m_testFont); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + QList listOfGlyphs = layout.glyphs(); + QCOMPARE(listOfGlyphs.size(), 1); + + QGlyphs glyphs = listOfGlyphs.at(0); + + QCOMPARE(glyphs.glyphIndexes().size(), 2); + QCOMPARE(glyphs.glyphIndexes().at(0), quint32(2)); + QCOMPARE(glyphs.glyphIndexes().at(1), quint32(1)); +} + +void tst_QGlyphs::drawExistingGlyphs() +{ + QImage textLayoutDraw(1000, 1000, QImage::Format_ARGB32); + QImage drawGlyphs(1000, 1000, QImage::Format_ARGB32); + + textLayoutDraw.fill(0xffffffff); + drawGlyphs.fill(0xffffffff); + + QString s; + s.append(QLatin1Char('A')); + s.append(QChar(0xe000)); + + QTextLayout layout(s); + layout.setFont(m_testFont); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphs glyphs = layout.glyphs().size() > 0 + ? layout.glyphs().at(0) + : QGlyphs(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawExistingGlyphs_textLayoutDraw.png"); + drawGlyphs.save("drawExistingGlyphs_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphs::drawNonExistentGlyphs() +{ + QVector glyphIndexes; + glyphIndexes.append(3); + + QVector glyphPositions; + glyphPositions.append(QPointF(0, 0)); + + QGlyphs glyphs; + glyphs.setGlyphIndexes(glyphIndexes); + glyphs.setPositions(glyphPositions); + glyphs.setFont(m_testFont); + + QImage image(1000, 1000, QImage::Format_ARGB32); + image.fill(0); + + QImage imageBefore = image; + { + QPainter p(&image); + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + image.save("drawNonExistentGlyphs.png"); +#endif + + QCOMPARE(image, imageBefore); // Should be unchanged +} + +void tst_QGlyphs::drawMultiScriptText1() +{ + QString text; + text += QChar(0x3131); // Hangul, Kiyeok + + QTextLayout textLayout(text); + textLayout.beginLayout(); + textLayout.createLine(); + textLayout.endLayout(); + + QImage textLayoutDraw(1000, 1000, QImage::Format_ARGB32); + textLayoutDraw.fill(0xffffffff); + + QImage drawGlyphs(1000, 1000, QImage::Format_ARGB32); + drawGlyphs.fill(0xffffffff); + + QList glyphsList = textLayout.glyphs(); + QCOMPARE(glyphsList.size(), 1); + + { + QPainter p(&textLayoutDraw); + textLayout.draw(&p, QPointF(50, 50)); + } + + { + QPainter p(&drawGlyphs); + foreach (QGlyphs glyphs, glyphsList) + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawMultiScriptText1_textLayoutDraw.png"); + drawGlyphs.save("drawMultiScriptText1_drawGlyphIndexes.png"); +#endif + + QCOMPARE(drawGlyphs, textLayoutDraw); +} + + +void tst_QGlyphs::drawMultiScriptText2() +{ +#if defined(Q_WS_MAC) + QSKIP("Unstable because of QTBUG-11145", SkipAll); +#endif + + QString text; + text += QChar(0x0621); // Arabic, Hamza + text += QChar(0x3131); // Hangul, Kiyeok + + QTextLayout textLayout(text); + textLayout.beginLayout(); + textLayout.createLine(); + textLayout.endLayout(); + + QImage textLayoutDraw(1000, 1000, QImage::Format_ARGB32); + textLayoutDraw.fill(0xffffffff); + + QImage drawGlyphs(1000, 1000, QImage::Format_ARGB32); + drawGlyphs.fill(0xffffffff); + + QList glyphsList = textLayout.glyphs(); + QCOMPARE(glyphsList.size(), 2); + + { + QPainter p(&textLayoutDraw); + textLayout.draw(&p, QPointF(50, 50)); + } + + { + QPainter p(&drawGlyphs); + foreach (QGlyphs glyphs, glyphsList) + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawMultiScriptText2_textLayoutDraw.png"); + drawGlyphs.save("drawMultiScriptText2_drawGlyphIndexes.png"); +#endif + + QCOMPARE(drawGlyphs, textLayoutDraw); +} + +void tst_QGlyphs::detach() +{ + QGlyphs glyphs; + + glyphs.setGlyphIndexes(QVector() << 1 << 2 << 3); + + QGlyphs otherGlyphs; + otherGlyphs = glyphs; + + QCOMPARE(otherGlyphs.glyphIndexes(), glyphs.glyphIndexes()); + + otherGlyphs.setGlyphIndexes(QVector() << 4 << 5 << 6); + + QCOMPARE(otherGlyphs.glyphIndexes(), QVector() << 4 << 5 << 6); + QCOMPARE(glyphs.glyphIndexes(), QVector() << 1 << 2 << 3); +} + +QTEST_MAIN(tst_QGlyphs) +#include "tst_qglyphs.moc" + -- cgit v0.12 From 3a3a3964c001112738890dde897a2f024baf8825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Jun 2010 10:36:03 +0200 Subject: Don't add the qmediaplayer.pro to the destination path of the sources. Casper observed that installing the demo created a folder called qmediaplayer.pro in the same folder as qmediaplayer.pro was located. Reviewed-by: Casper van Donderen --- demos/qmediaplayer/qmediaplayer.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/qmediaplayer/qmediaplayer.pro b/demos/qmediaplayer/qmediaplayer.pro index cfe3905..9407a81 100644 --- a/demos/qmediaplayer/qmediaplayer.pro +++ b/demos/qmediaplayer/qmediaplayer.pro @@ -17,7 +17,7 @@ HEADERS += mediaplayer.h target.path = $$[QT_INSTALL_DEMOS]/qmediaplayer sources.files = $$SOURCES $$HEADERS $$FORMS $$RESOURCES *.pro *.html *.doc images -sources.path = $$[QT_INSTALL_DEMOS]/qmediaplayer qmediaplayer.pro +sources.path = $$[QT_INSTALL_DEMOS]/qmediaplayer INSTALLS += target sources wince*{ -- cgit v0.12 From 397295f1a91c782f905374213b85ef1108c357e3 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 4 Jun 2010 11:10:47 +0200 Subject: Qt now really unloads plugins and libraries when exiting an app It also means that when creating a QPluginLoader or a QLibrary for a dynamic lib already loaded, isLoaded will return true immediately after the creation of the instance of QPluginLoader or QLibrary. Reviewed-By: Jan-Arve Saether --- src/corelib/plugin/qlibrary.cpp | 31 +++++++++++++--- src/corelib/plugin/qlibrary_p.h | 2 ++ src/corelib/plugin/qpluginloader.cpp | 8 ++--- src/gui/kernel/qapplication_win.cpp | 14 +++----- src/gui/kernel/qapplication_x11.cpp | 28 +++++++-------- src/gui/kernel/qdesktopwidget_win.cpp | 14 +++----- src/gui/kernel/qguifunctions_wince.cpp | 2 -- src/gui/widgets/qmenu_wince.cpp | 2 -- tests/auto/qlibrary/tst_qlibrary.cpp | 66 ++++++++++++++++++++++------------ 9 files changed, 97 insertions(+), 70 deletions(-) diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index ccde2b0..f6ae038 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -426,10 +426,14 @@ struct LibraryData { LibraryData() : settings(0) { } ~LibraryData() { delete settings; + foreach(QLibraryPrivate *lib, loadedLibs) { + lib->unload(); + } } QSettings *settings; LibraryMap libraryMap; + QSet loadedLibs; }; Q_GLOBAL_STATIC(LibraryData, libraryData) @@ -481,7 +485,18 @@ bool QLibraryPrivate::load() return true; if (fileName.isEmpty()) return false; - return load_sys(); + + bool ret = load_sys(); + if (ret) { + //when loading a library we add a reference to it so that the QLibraryPrivate won't get deleted + //this allows to unload the library at a later time + if (LibraryData *lib = libraryData()) { + lib->loadedLibs += this; + libraryRefCount.ref(); + } + } + + return ret; } bool QLibraryPrivate::unload() @@ -489,10 +504,16 @@ bool QLibraryPrivate::unload() if (!pHnd) return false; if (!libraryUnloadCount.deref()) { // only unload if ALL QLibrary instance wanted to - if (instance) - delete instance(); + delete inst.data(); if (unload_sys()) { - instance = 0; + if (qt_debug_component()) + qWarning() << "QLibraryPrivate::unload succeeded on" << fileName; + //when the library is unloaded, we release the reference on it so that 'this' + //can get deleted + if (LibraryData *lib = libraryData()) { + if (lib->loadedLibs.remove(this)) + libraryRefCount.deref(); + } pHnd = 0; } } @@ -1126,7 +1147,7 @@ void QLibrary::setFileNameAndVersion(const QString &fileName, const QString &ver */ void *QLibrary::resolve(const char *symbol) { - if (!load()) + if (!isLoaded() && !load()) return 0; return d->resolve(symbol); } diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 02dc523..b73fce5 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -60,6 +60,7 @@ #include "QtCore/qpointer.h" #include "QtCore/qstringlist.h" #include "QtCore/qplugin.h" +#include "QtCore/qsharedpointer.h" #ifndef QT_NO_LIBRARY @@ -90,6 +91,7 @@ public: static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString()); + QWeakPointer inst; QtPluginInstanceFunction instance; uint qt_version; QString lastModified; diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index b1d1ecc..9f322df 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -198,11 +198,11 @@ QPluginLoader::~QPluginLoader() */ QObject *QPluginLoader::instance() { - if (!load()) + if (!isLoaded() && !load()) return 0; - if (d->instance) - return d->instance(); - return 0; + if (!d->inst && d->instance) + d->inst = d->instance(); + return d->inst.data(); } /*! diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 60fc5e1..d2ce5ff 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -206,8 +206,6 @@ static void resolveAygLibs() if (!aygResolved) { aygResolved = true; QLibrary ayglib(QLatin1String("aygshell")); - if (!ayglib.load()) - return; ptrRecognizeGesture = (AygRecognizeGesture) ayglib.resolve("SHRecognizeGesture"); } } @@ -3642,13 +3640,11 @@ static void initWinTabFunctions() return; QLibrary library(QLatin1String("wintab32")); - if (library.load()) { - ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); - ptrWTGet = (PtrWTGet)library.resolve("WTGetW"); - ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable"); - ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap"); - ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet"); - } + ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW"); + ptrWTGet = (PtrWTGet)library.resolve("WTGetW"); + ptrWTEnable = (PtrWTEnable)library.resolve("WTEnable"); + ptrWTOverlap = (PtrWTEnable)library.resolve("WTOverlap"); + ptrWTPacketsGet = (PtrWTPacketsGet)library.resolve("WTPacketsGet"); #endif // Q_OS_WINCE } #endif // QT_NO_TABLETEVENT diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 78fc704..b2dc638 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -456,11 +456,9 @@ static void* qt_load_library_runtime(const char *library, int vernum, Q_FOREACH(int version, versions) { QLatin1String libName(library); QLibrary xfixesLib(libName, version); - if (xfixesLib.load()) { - void *ptr = xfixesLib.resolve(symbol); - if (ptr) - return ptr; - } + void *ptr = xfixesLib.resolve(symbol); + if (ptr) + return ptr; } return 0; } @@ -2557,22 +2555,20 @@ void qt_init(QApplicationPrivate *priv, int, #if !defined (Q_OS_IRIX) && !defined (QT_NO_TABLET) QLibrary wacom(QString::fromLatin1("wacomcfg"), 0); // version 0 is the latest release at time of writing this. - if (wacom.load()) { - // NOTE: C casts instead of reinterpret_cast for GCC 3.3.x - ptrWacomConfigInit = (PtrWacomConfigInit)wacom.resolve("WacomConfigInit"); - ptrWacomConfigOpenDevice = (PtrWacomConfigOpenDevice)wacom.resolve("WacomConfigOpenDevice"); - ptrWacomConfigGetRawParam = (PtrWacomConfigGetRawParam)wacom.resolve("WacomConfigGetRawParam"); - ptrWacomConfigCloseDevice = (PtrWacomConfigCloseDevice)wacom.resolve("WacomConfigCloseDevice"); - ptrWacomConfigTerm = (PtrWacomConfigTerm)wacom.resolve("WacomConfigTerm"); - - if (ptrWacomConfigInit == 0 || ptrWacomConfigOpenDevice == 0 || ptrWacomConfigGetRawParam == 0 - || ptrWacomConfigCloseDevice == 0 || ptrWacomConfigTerm == 0) { // either we have all, or we have none. + // NOTE: C casts instead of reinterpret_cast for GCC 3.3.x + ptrWacomConfigInit = (PtrWacomConfigInit)wacom.resolve("WacomConfigInit"); + ptrWacomConfigOpenDevice = (PtrWacomConfigOpenDevice)wacom.resolve("WacomConfigOpenDevice"); + ptrWacomConfigGetRawParam = (PtrWacomConfigGetRawParam)wacom.resolve("WacomConfigGetRawParam"); + ptrWacomConfigCloseDevice = (PtrWacomConfigCloseDevice)wacom.resolve("WacomConfigCloseDevice"); + ptrWacomConfigTerm = (PtrWacomConfigTerm)wacom.resolve("WacomConfigTerm"); + + if (ptrWacomConfigInit == 0 || ptrWacomConfigOpenDevice == 0 || ptrWacomConfigGetRawParam == 0 + || ptrWacomConfigCloseDevice == 0 || ptrWacomConfigTerm == 0) { // either we have all, or we have none. ptrWacomConfigInit = 0; ptrWacomConfigOpenDevice = 0; ptrWacomConfigGetRawParam = 0; ptrWacomConfigCloseDevice = 0; ptrWacomConfigTerm = 0; - } } #endif } diff --git a/src/gui/kernel/qdesktopwidget_win.cpp b/src/gui/kernel/qdesktopwidget_win.cpp index 07dbc24..5aa206c 100644 --- a/src/gui/kernel/qdesktopwidget_win.cpp +++ b/src/gui/kernel/qdesktopwidget_win.cpp @@ -156,10 +156,8 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that) #ifndef Q_OS_WINCE QLibrary user32Lib(QLatin1String("user32")); - if (user32Lib.load()) { - enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors"); - getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW"); - } + enumDisplayMonitors = (EnumFunc)user32Lib.resolve("EnumDisplayMonitors"); + getMonitorInfo = (InfoFunc)user32Lib.resolve("GetMonitorInfoW"); if (!enumDisplayMonitors || !getMonitorInfo) { screenCount = GetSystemMetrics(80); // SM_CMONITORS @@ -174,11 +172,9 @@ void QDesktopWidgetPrivate::init(QDesktopWidget *that) getMonitorInfo = 0; #else QLibrary coreLib(QLatin1String("coredll")); - if (coreLib.load()) { - // CE >= 4.0 case - enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors"); - getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo"); - } + // CE >= 4.0 case + enumDisplayMonitors = (EnumFunc)coreLib.resolve("EnumDisplayMonitors"); + getMonitorInfo = (InfoFunc)coreLib.resolve("GetMonitorInfo"); if ((!enumDisplayMonitors || !getMonitorInfo)) { screenCount = GetSystemMetrics(SM_CMONITORS); diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp index f5004b0..cc98d43 100644 --- a/src/gui/kernel/qguifunctions_wince.cpp +++ b/src/gui/kernel/qguifunctions_wince.cpp @@ -123,8 +123,6 @@ static void resolveAygLibs() if (!aygResolved) { aygResolved = true; QLibrary ayglib(QLatin1String("aygshell")); - if (!ayglib.load()) - return; ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog"); ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen"); ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo"); diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp index e088db6..15d0116 100644 --- a/src/gui/widgets/qmenu_wince.cpp +++ b/src/gui/widgets/qmenu_wince.cpp @@ -113,8 +113,6 @@ static void resolveAygLibs() if (!aygResolved) { aygResolved = true; QLibrary aygLib(QLatin1String("aygshell")); - if (!aygLib.load()) - return; ptrCreateMenuBar = (AygCreateMenuBar) aygLib.resolve("SHCreateMenuBar"); ptrEnableSoftKey = (AygEnableSoftKey) aygLib.resolve("SHEnableSoftkey"); } diff --git a/tests/auto/qlibrary/tst_qlibrary.cpp b/tests/auto/qlibrary/tst_qlibrary.cpp index 3d26e0b..99e6de3 100644 --- a/tests/auto/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/qlibrary/tst_qlibrary.cpp @@ -203,6 +203,7 @@ void tst_QLibrary::version() VersionFunction fnVersion = (VersionFunction)library.resolve("mylibversion"); QVERIFY(fnVersion); QCOMPARE(fnVersion(), resultversion); + QVERIFY(library.unload()); #else Q_UNUSED(lib); Q_UNUSED(loadversion); @@ -249,6 +250,7 @@ void tst_QLibrary::load() bool ok = library.load(); if ( result ) { QVERIFY( ok ); + QVERIFY(library.unload()); } else { QVERIFY( !ok ); } @@ -338,6 +340,7 @@ void tst_QLibrary::resolve() } else { QVERIFY( func == 0 ); } + library.unload(); } void tst_QLibrary::library_data() @@ -469,7 +472,9 @@ void tst_QLibrary::errorString() break; } QRegExp re(errorString); - QVERIFY2(re.exactMatch(lib.errorString()), qPrintable(lib.errorString())); + QString libErrorString = lib.errorString(); + QVERIFY(!lib.isLoaded() || lib.unload()); + QVERIFY2(re.exactMatch(libErrorString), qPrintable(libErrorString)); QCOMPARE(ok, success); } @@ -525,6 +530,7 @@ void tst_QLibrary::loadHints() bool ok = library.load(); if ( result ) { QVERIFY( ok ); + QVERIFY(library.unload()); } else { QVERIFY( !ok ); } @@ -565,6 +571,7 @@ void tst_QLibrary::fileName() #else QCOMPARE(lib.fileName(), expectedFilename); #endif + QVERIFY(lib.unload()); } @@ -576,29 +583,42 @@ void tst_QLibrary::multipleInstancesForOneLibrary() QString lib = QDir::currentPath() + "/mylib"; #endif - QLibrary lib1(lib); - QLibrary lib2(lib); - QCOMPARE(lib1.isLoaded(), false); - QCOMPARE(lib2.isLoaded(), false); - lib1.load(); - QCOMPARE(lib1.isLoaded(), true); - QCOMPARE(lib2.isLoaded(), true); - QCOMPARE(lib1.unload(), true); - QCOMPARE(lib1.isLoaded(), false); - QCOMPARE(lib2.isLoaded(), false); - lib1.load(); - lib2.load(); - QCOMPARE(lib1.isLoaded(), true); - QCOMPARE(lib2.isLoaded(), true); - QCOMPARE(lib1.unload(), false); - QCOMPARE(lib1.isLoaded(), true); - QCOMPARE(lib2.isLoaded(), true); - QCOMPARE(lib2.unload(), true); - QCOMPARE(lib1.isLoaded(), false); - QCOMPARE(lib2.isLoaded(), false); + { + QLibrary lib1(lib); + QLibrary lib2(lib); + QCOMPARE(lib1.isLoaded(), false); + QCOMPARE(lib2.isLoaded(), false); + lib1.load(); + QCOMPARE(lib1.isLoaded(), true); + QCOMPARE(lib2.isLoaded(), true); + QCOMPARE(lib1.unload(), true); + QCOMPARE(lib1.isLoaded(), false); + QCOMPARE(lib2.isLoaded(), false); + lib1.load(); + lib2.load(); + QCOMPARE(lib1.isLoaded(), true); + QCOMPARE(lib2.isLoaded(), true); + QCOMPARE(lib1.unload(), false); + QCOMPARE(lib1.isLoaded(), true); + QCOMPARE(lib2.isLoaded(), true); + QCOMPARE(lib2.unload(), true); + QCOMPARE(lib1.isLoaded(), false); + QCOMPARE(lib2.isLoaded(), false); + + // Finally; unload on that is already unloaded + QCOMPARE(lib1.unload(), false); + } - // Finally; unload on that is already unloaded - QCOMPARE(lib1.unload(), false); + //now let's try with a 3rd one that will go out of scope + { + QLibrary lib1(lib); + QCOMPARE(lib1.isLoaded(), false); + lib1.load(); + QCOMPARE(lib1.isLoaded(), true); + } + QLibrary lib2(lib); + //lib2 should be loaded because lib1 was loaded and never unloaded + QCOMPARE(lib2.isLoaded(), true); /* lib1.setLoadHints(QLibrary::ResolveAllSymbolsHint); -- cgit v0.12 From a865aa2a022478aabea26b0f363a55db2c43fec7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 4 Jun 2010 15:34:30 +0200 Subject: Reimplement more of QAbstractItemModel in QAbstractProxyModel The non-structural parts of the API are implemented to forward calls to the source model. Merge-request: 656 Reviewed-by: Olivier Goffart --- src/gui/itemviews/qabstractproxymodel.cpp | 96 +++++++++++++++++++++++++++++++ src/gui/itemviews/qabstractproxymodel.h | 12 ++++ 2 files changed, 108 insertions(+) diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp index 43a1327..4d4b3d8 100644 --- a/src/gui/itemviews/qabstractproxymodel.cpp +++ b/src/gui/itemviews/qabstractproxymodel.cpp @@ -45,6 +45,9 @@ #include "qitemselectionmodel.h" #include +#include +#include + QT_BEGIN_NAMESPACE @@ -262,6 +265,15 @@ bool QAbstractProxyModel::setData(const QModelIndex &index, const QVariant &valu /*! \reimp */ +bool QAbstractProxyModel::setItemData(const QModelIndex &index, const QMap< int, QVariant >& roles) +{ + Q_D(QAbstractProxyModel); + return d->model->setItemData(mapToSource(index), roles); +} + +/*! + \reimp + */ bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { Q_D(QAbstractProxyModel); @@ -276,6 +288,90 @@ bool QAbstractProxyModel::setHeaderData(int section, Qt::Orientation orientation return d->model->setHeaderData(sourceSection, orientation, value, role); } +/*! + \reimp + */ +QModelIndex QAbstractProxyModel::buddy(const QModelIndex &index) const +{ + Q_D(const QAbstractProxyModel); + return mapFromSource(d->model->buddy(mapToSource(index))); +} + +/*! + \reimp + */ +bool QAbstractProxyModel::canFetchMore(const QModelIndex &parent) const +{ + Q_D(const QAbstractProxyModel); + return d->model->canFetchMore(mapToSource(parent)); +} + +/*! + \reimp + */ +void QAbstractProxyModel::fetchMore(const QModelIndex &parent) +{ + Q_D(QAbstractProxyModel); + d->model->fetchMore(mapToSource(parent)); +} + +/*! + \reimp + */ +void QAbstractProxyModel::sort(int column, Qt::SortOrder order) +{ + Q_D(QAbstractProxyModel); + d->model->sort(column, order); +} + +/*! + \reimp + */ +QSize QAbstractProxyModel::span(const QModelIndex &index) const +{ + Q_D(const QAbstractProxyModel); + return d->model->span(mapToSource(index)); +} + +/*! + \reimp + */ +bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const +{ + Q_D(const QAbstractProxyModel); + return d->model->hasChildren(mapToSource(parent)); +} + +/*! + \reimp + */ +QMimeData* QAbstractProxyModel::mimeData(const QModelIndexList &indexes) const +{ + Q_D(const QAbstractProxyModel); + QModelIndexList list; + foreach(const QModelIndex &index, indexes) + list << mapToSource(index); + return d->model->mimeData(indexes); +} + +/*! + \reimp + */ +QStringList QAbstractProxyModel::mimeTypes() const +{ + Q_D(const QAbstractProxyModel); + return d->model->mimeTypes(); +} + +/*! + \reimp + */ +Qt::DropActions QAbstractProxyModel::supportedDropActions() const +{ + Q_D(const QAbstractProxyModel); + return d->model->supportedDropActions(); +} + QT_END_NAMESPACE #include "moc_qabstractproxymodel.cpp" diff --git a/src/gui/itemviews/qabstractproxymodel.h b/src/gui/itemviews/qabstractproxymodel.h index c6bb985..a5a1168 100644 --- a/src/gui/itemviews/qabstractproxymodel.h +++ b/src/gui/itemviews/qabstractproxymodel.h @@ -81,8 +81,20 @@ public: Qt::ItemFlags flags(const QModelIndex &index) const; bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + bool setItemData(const QModelIndex& index, const QMap &roles); bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); + QModelIndex buddy(const QModelIndex &index) const; + bool canFetchMore(const QModelIndex &parent) const; + void fetchMore(const QModelIndex &parent); + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); + QSize span(const QModelIndex &index) const; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const; + + QMimeData* mimeData(const QModelIndexList &indexes) const; + QStringList mimeTypes() const; + Qt::DropActions supportedDropActions() const; + protected: QAbstractProxyModel(QAbstractProxyModelPrivate &, QObject *parent); -- cgit v0.12 From 114bd0ca8e3e892cd3118ac2dd4cfe87e12b0310 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 4 Jun 2010 17:17:25 +0200 Subject: make the plugin loader autotests pass --- tests/auto/qpluginloader/tst_qpluginloader.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/auto/qpluginloader/tst_qpluginloader.cpp b/tests/auto/qpluginloader/tst_qpluginloader.cpp index 705e600..61d59a1 100644 --- a/tests/auto/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/qpluginloader/tst_qpluginloader.cpp @@ -287,12 +287,14 @@ void tst_QPluginLoader::deleteinstanceOnUnload() QSignalSpy spy1(loader1.instance(), SIGNAL(destroyed())); QSignalSpy spy2(loader2.instance(), SIGNAL(destroyed())); - QCOMPARE(loader1.unload(), false); // refcount not reached 0, not really unloaded - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); + if (pass == 0) { + QCOMPARE(loader2.unload(), false); // refcount not reached 0, not really unloaded + QCOMPARE(spy1.count(), 0); + QCOMPARE(spy2.count(), 0); + } QCOMPARE(instance1->pluginName(), QLatin1String("Plugin ok")); QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok")); - QCOMPARE(loader2.unload(), true); // refcount reached 0, did really unload + QVERIFY(loader1.unload()); // refcount reached 0, did really unload QCOMPARE(spy1.count(), 1); QCOMPARE(spy2.count(), 1); } -- cgit v0.12 From 3ef17db7085f0b77661ced78522c8cfcb0e52144 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 4 Jun 2010 18:37:29 +0200 Subject: add missing header --- src/gui/text/qglyphs.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/gui/text/qglyphs.cpp b/src/gui/text/qglyphs.cpp index 847646e..2447752 100644 --- a/src/gui/text/qglyphs.cpp +++ b/src/gui/text/qglyphs.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 "qglyphs.h" #include "qglyphs_p.h" -- cgit v0.12 From 9e712c65899681ca08534476145dda05e5edb0bc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Jun 2010 12:14:10 +0200 Subject: Fix maketestselftest by adding the qglyphs test Also make the test find the font in shadow build Reviewed-by: eskil --- tests/auto/gui.pro | 1 + tests/auto/qglyphs/qglyphs.pro | 6 ++++++ tests/auto/qglyphs/tst_qglyphs.cpp | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/auto/gui.pro b/tests/auto/gui.pro index a8fd2b4..d2669c6 100644 --- a/tests/auto/gui.pro +++ b/tests/auto/gui.pro @@ -57,6 +57,7 @@ SUBDIRS=\ qfontdialog \ qfontmetrics \ qformlayout \ + qglyphs \ qgraphicsanchorlayout \ qgraphicsanchorlayout1 \ qgraphicseffect \ diff --git a/tests/auto/qglyphs/qglyphs.pro b/tests/auto/qglyphs/qglyphs.pro index 70920f0..5084cf9 100644 --- a/tests/auto/qglyphs/qglyphs.pro +++ b/tests/auto/qglyphs/qglyphs.pro @@ -3,3 +3,9 @@ QT = core gui SOURCES += \ tst_qglyphs.cpp + +wince*|symbian*: { + DEFINES += SRCDIR=\\\"\\\" +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} \ No newline at end of file diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index c906f10..2a0e670 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -77,7 +77,7 @@ Q_DECLARE_METATYPE(QGlyphs); void tst_QGlyphs::initTestCase() { - m_testFontId = QFontDatabase::addApplicationFont("test.ttf"); + m_testFontId = QFontDatabase::addApplicationFont(SRCDIR "test.ttf"); QVERIFY(m_testFontId >= 0); m_testFont = QFont("QtsSpecialTestFont"); -- cgit v0.12 From e55b6a34ea06646e81b559a0605aabc150119565 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Apr 2010 12:10:36 +0200 Subject: qdrawhelper: remove code duplication Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 154 ++++++++------------------------------- 1 file changed, 30 insertions(+), 124 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index bfa1136..e18ab75 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -656,6 +656,28 @@ const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const return buffer; } +template +static inline void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2) +{ + if (blendType == BlendTransformedBilinearTiled) { + v1 %= max; + if (v1 < 0) v1 += max; + v2 = v1 + 1; + v2 %= max; + } else { + if (v1 < l1) { + v2 = v1 = l1; + } else if (v1 >= l2 - 1) { + v2 = v1 = l2 - 1; + } else { + v2 = v1 + 1; + } + } + + Q_ASSERT(v1 >= 0 && v1 < max); + Q_ASSERT(v2 >= 0 && v2 < max); +} + template /* blendType = BlendTransformedBilinear or BlendTransformedBilinearTiled */ Q_STATIC_TEMPLATE_FUNCTION const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator *, const QSpanData *data, @@ -702,37 +724,8 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * int y1 = (fy >> 16); int y2; - if (blendType == BlendTransformedBilinearTiled) { - x1 %= image_width; - if (x1 < 0) x1 += image_width; - x2 = x1 + 1; - x2 %= image_width; - - y1 %= image_height; - if (y1 < 0) y1 += image_height; - y2 = y1 + 1; - y2 %= image_height; - } else { - if (x1 < image_x1) { - x2 = x1 = image_x1; - } else if (x1 >= image_x2 - 1) { - x2 = x1 = image_x2 - 1; - } else { - x2 = x1 + 1; - } - if (y1 < image_y1) { - y2 = y1 = image_y1; - } else if (y1 >= image_y2 - 1) { - y2 = y1 = image_y2 - 1; - } else { - y2 = y1 + 1; - } - } - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); @@ -779,37 +772,8 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * int idistx = 256 - distx; int idisty = 256 - disty; - if (blendType == BlendTransformedBilinearTiled) { - x1 %= image_width; - if (x1 < 0) x1 += image_width; - x2 = x1 + 1; - x2 %= image_width; - - y1 %= image_height; - if (y1 < 0) y1 += image_height; - y2 = y1 + 1; - y2 %= image_height; - } else { - if (x1 < 0) { - x2 = x1 = 0; - } else if (x1 >= image_width - 1) { - x2 = x1 = image_width - 1; - } else { - x2 = x1 + 1; - } - if (y1 < 0) { - y2 = y1 = 0; - } else if (y1 >= image_height - 1) { - y2 = y1 = image_height - 1; - } else { - y2 = y1 + 1; - } - } - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); @@ -5220,37 +5184,8 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const int y1 = (y >> 16); int y2; - if (blendType == BlendTransformedBilinearTiled) { - x1 %= image_width; - if (x1 < 0) x1 += image_width; - x2 = x1 + 1; - x2 %= image_width; - - y1 %= image_height; - if (y1 < 0) y1 += image_height; - y2 = y1 + 1; - y2 %= image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); - } else { - if (x1 < image_x1) { - x2 = x1 = image_x1; - } else if (x1 >= image_x2 - 1) { - x2 = x1 = image_x2 - 1; - } else { - x2 = x1 + 1; - } - if (y1 < image_y1) { - y2 = y1 = image_y1; - } else if (y1 >= image_y2 - 1) { - y2 = y1 = image_y2 - 1; - } else { - y2 = y1 + 1; - } - } + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); int y1_offset = y1 * scanline_offset; int y2_offset = y2 * scanline_offset; @@ -5330,37 +5265,8 @@ Q_STATIC_TEMPLATE_FUNCTION void blend_transformed_bilinear_argb(int count, const int idistx = 256 - distx; int idisty = 256 - disty; - if (blendType == BlendTransformedBilinearTiled) { - x1 %= image_width; - if (x1 < 0) x1 += image_width; - x2 = x1 + 1; - x2 %= image_width; - - y1 %= image_height; - if (y1 < 0) y1 += image_height; - y2 = y1 + 1; - y2 %= image_height; - - Q_ASSERT(x1 >= 0 && x1 < image_width); - Q_ASSERT(x2 >= 0 && x2 < image_width); - Q_ASSERT(y1 >= 0 && y1 < image_height); - Q_ASSERT(y2 >= 0 && y2 < image_height); - } else { - if (x1 < image_x1) { - x2 = x1 = image_x1; - } else if (x1 >= image_x2 - 1) { - x2 = x1 = image_x2 - 1; - } else { - x2 = x1 + 1; - } - if (y1 < image_y1) { - y2 = y1 = image_y1; - } else if (y1 >= image_y2 - 1) { - y2 = y1 = image_y2 - 1; - } else { - y2 = y1 + 1; - } - } + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); int y1_offset = y1 * scanline_offset; int y2_offset = y2 * scanline_offset; -- cgit v0.12 From 0d7e6839172f5feae2c81c5c552f685520504afc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Apr 2010 13:40:09 +0200 Subject: qdrawhelper: optimize fetchTransformedBilinear When scaling down, there is no need to keep 8 bit accurancy on the position 4 bit is enough and should not be noticable for the human eye. Also optimize the pure scaling if there is no rotation: when scaling up, do the average between the top and the bottom row then use this pre-computation later. Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 195 +++++++++++++++++++++++++++++++++++---- tests/auto/qimage/tst_qimage.cpp | 6 +- 2 files changed, 178 insertions(+), 23 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index e18ab75..bd961a4 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -656,6 +656,24 @@ const uint * QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const return buffer; } +/** \internal + interpolate 4 argb pixels with the distx and disty factor. + distx and disty bust be between 0 and 16 + */ +static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, int distx, int disty, int idistx, int idisty) +{ + uint tlrb = ((tl & 0x00ff00ff) * idistx * idisty); + uint tlag = (((tl & 0xff00ff00) >> 8) * idistx * idisty); + uint trrb = ((tr & 0x00ff00ff) * distx * idisty); + uint trag = (((tr & 0xff00ff00) >> 8) * distx * idisty); + uint blrb = ((bl & 0x00ff00ff) * idistx * disty); + uint blag = (((bl & 0xff00ff00) >> 8) * idistx * disty); + uint brrb = ((br & 0x00ff00ff) * distx * disty); + uint brag = (((br & 0xff00ff00) >> 8) * distx * disty); + return (((tlrb + trrb + blrb + brrb) >> 8) & 0x00ff00ff) | ((tlag + trag + blag + brag) & 0xff00ff00); +} + + template static inline void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2) { @@ -718,35 +736,172 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * fx -= half_point; fy -= half_point; - while (b < end) { - int x1 = (fx >> 16); - int x2; + + if (fdy == 0) { //simple scale, no rotation int y1 = (fy >> 16); int y2; - - fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); - const uchar *s1 = data->texture.scanLine(y1); const uchar *s2 = data->texture.scanLine(y2); - uint tl = fetch(s1, x1, data->texture.colorTable); - uint tr = fetch(s1, x2, data->texture.colorTable); - uint bl = fetch(s2, x1, data->texture.colorTable); - uint br = fetch(s2, x2, data->texture.colorTable); + 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; + + quint32 intermediate_buffer[buffer_size + 2][2]; + Q_ASSERT(length * data->m11 <= buffer_size); + if (blendType == BlendTransformedBilinearTiled) { + x_ %= image_width; + if (x_ < 0) x_ += image_width; + } + for (int f = 0; f < count; f++) { + int x; + if (blendType == BlendTransformedBilinearTiled) { + if (x_ >= image_width) x_ -= image_width; + x = x_; + } else { + x = qBound(image_x1, x_, image_x2 - 1); + } - int distx = (fx & 0x0000ffff) >> 8; - int disty = (fy & 0x0000ffff) >> 8; - int idistx = 256 - distx; - int idisty = 256 - disty; + uint t = fetch(s1, x, data->texture.colorTable); + uint b = fetch(s2, x, data->texture.colorTable); - uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); - uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); - *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); + intermediate_buffer[f][0] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; + intermediate_buffer[f][1] = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; + x_++; + } + fx &= fixed_scale - 1; + Q_ASSERT((fx >> 16) == 0); + while (b < end) { + register int x1 = (fx >> 16); + register int x2 = x1 + 1; + Q_ASSERT(x1 >= 0); + Q_ASSERT(x2 < count); + + register int distx = (fx & 0x0000ffff) >> 8; + register int idistx = 256 - distx; + int rb = ((intermediate_buffer[x1][0] * idistx + intermediate_buffer[x2][0] * distx) >> 8) & 0xff00ff; + int ag = (intermediate_buffer[x1][1] * idistx + intermediate_buffer[x2][1] * distx) & 0xff00ff00; + *b = rb | ag; + b++; + fx += fdx; + } + } else if ((fdx < 0 && fdx > -(fixed_scale / 8)) || fabs(data->m22) < (1./8.)) { // scale up more than 8x + int y1 = (fy >> 16); + int y2; + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); + const uchar *s1 = data->texture.scanLine(y1); + const uchar *s2 = data->texture.scanLine(y2); + int disty = (fy & 0x0000ffff) >> 8; + int idisty = 256 - disty; + while (b < end) { + int x1 = (fx >> 16); + int x2; + fetchTransformedBilinear_pixelBounds(image_height, image_x1, image_x2, x1, x2); + uint tl = fetch(s1, x1, data->texture.colorTable); + uint tr = fetch(s1, x2, data->texture.colorTable); + uint bl = fetch(s2, x1, data->texture.colorTable); + uint br = fetch(s2, x2, data->texture.colorTable); - fx += fdx; - fy += fdy; - ++b; + int distx = (fx & 0x0000ffff) >> 8; + int idistx = 256 - distx; + + uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); + uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); + *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); + + fx += fdx; + ++b; + } + } else { //scale down + int y1 = (fy >> 16); + int y2; + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); + const uchar *s1 = data->texture.scanLine(y1); + const uchar *s2 = data->texture.scanLine(y2); + int disty = (fy & 0x0000ffff) >> 12; + int idisty = 16 - disty; + while (b < end) { + int x1 = (fx >> 16); + int x2; + fetchTransformedBilinear_pixelBounds(image_height, image_x1, image_x2, x1, x2); + uint tl = fetch(s1, x1, data->texture.colorTable); + uint tr = fetch(s1, x2, data->texture.colorTable); + uint bl = fetch(s2, x1, data->texture.colorTable); + uint br = fetch(s2, x2, data->texture.colorTable); + int distx = (fx & 0x0000ffff) >> 12; + int idistx = 16 - distx; + *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty, idistx, idisty); + fx += fdx; + ++b; + } + } + } else { //rotation + if (fabs(data->m11) > 8 || fabs(data->m22) > 8) { + //if we are zooming more than 8 times, we use 8bit precision for the position. + while (b < end) { + int x1 = (fx >> 16); + int x2; + int y1 = (fy >> 16); + int y2; + + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); + + const uchar *s1 = data->texture.scanLine(y1); + const uchar *s2 = data->texture.scanLine(y2); + + uint tl = fetch(s1, x1, data->texture.colorTable); + uint tr = fetch(s1, x2, data->texture.colorTable); + uint bl = fetch(s2, x1, data->texture.colorTable); + uint br = fetch(s2, x2, data->texture.colorTable); + + int distx = (fx & 0x0000ffff) >> 8; + int disty = (fy & 0x0000ffff) >> 8; + int idistx = 256 - distx; + int idisty = 256 - disty; + + uint xtop = INTERPOLATE_PIXEL_256(tl, idistx, tr, distx); + uint xbot = INTERPOLATE_PIXEL_256(bl, idistx, br, distx); + *b = INTERPOLATE_PIXEL_256(xtop, idisty, xbot, disty); + + fx += fdx; + fy += fdy; + ++b; + } + } else { + //we are zooming less than 8x, use 4bit precision + while (b < end) { + int x1 = (fx >> 16); + int x2; + int y1 = (fy >> 16); + int y2; + + fetchTransformedBilinear_pixelBounds(image_width, image_x1, image_x2, x1, x2); + fetchTransformedBilinear_pixelBounds(image_height, image_y1, image_y2, y1, y2); + + const uchar *s1 = data->texture.scanLine(y1); + const uchar *s2 = data->texture.scanLine(y2); + + uint tl = fetch(s1, x1, data->texture.colorTable); + uint tr = fetch(s1, x2, data->texture.colorTable); + uint bl = fetch(s2, x1, data->texture.colorTable); + uint br = fetch(s2, x2, data->texture.colorTable); + + int distx = (fx & 0x0000ffff) >> 12; + int disty = (fy & 0x0000ffff) >> 12; + int idistx = 16 - distx; + int idisty = 16 - disty; + + *b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty, idistx, idisty); + + fx += fdx; + fy += fdy; + ++b; + } + } } } else { const qreal fdx = data->m11; diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 16deb03..10514d9 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -1465,9 +1465,9 @@ void tst_QImage::smoothScale3() QRgb cb = b.pixel(x, y); // tolerate a little bit of rounding errors - QVERIFY(compare(qRed(ca), qRed(cb), 3)); - QVERIFY(compare(qGreen(ca), qGreen(cb), 3)); - QVERIFY(compare(qBlue(ca), qBlue(cb), 3)); + QVERIFY(compare(qRed(ca), qRed(cb), 16)); + QVERIFY(compare(qGreen(ca), qGreen(cb), 16)); + QVERIFY(compare(qBlue(ca), qBlue(cb), 16)); } } } -- cgit v0.12 From bc846277c47cb9980f3b6003ec702b7739568d15 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 7 Jun 2010 12:40:15 +0200 Subject: Remove unused function in tst_QGlyphs Static function which was never called, caused a warning with gcc --- tests/auto/qglyphs/tst_qglyphs.cpp | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index 2a0e670..177b981 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -119,31 +119,6 @@ static QGlyphs make_dummy_indexes() return glyphs; } -static QGlyphs make_dummy_indexes2() -{ - QGlyphs glyphs; - - QVector glyphIndexes; - QVector positions; - QFont font; - font.setPointSize(26); - - glyphIndexes.append(4); - glyphIndexes.append(5); - glyphIndexes.append(6); - - positions.append(QPointF(7, 8)); - positions.append(QPointF(9, 10)); - positions.append(QPointF(11, 12)); - - glyphs.setFont(font); - glyphs.setGlyphIndexes(glyphIndexes); - glyphs.setPositions(positions); - - return glyphs; -} - - void tst_QGlyphs::copyConstructor() { QGlyphs glyphs; -- cgit v0.12 From 422648966d634b27cfcf8cad8a895724322637cb Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 7 Jun 2010 13:24:56 +0200 Subject: Test native graphics engine in tst_QGlyphs Drawing to QImage will always go through the raster engine, so some bugs might not be caught. This also fixes a test failure on X11, since the raster engine on X11 is inconsistent with regards to how it handles subpixel antialiasing into images. See task QTBUG-11268. Reviewed-by: Olivier --- tests/auto/qglyphs/tst_qglyphs.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index 177b981..90309ea 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -235,11 +235,11 @@ void tst_QGlyphs::textLayoutGlyphIndexes() void tst_QGlyphs::drawExistingGlyphs() { - QImage textLayoutDraw(1000, 1000, QImage::Format_ARGB32); - QImage drawGlyphs(1000, 1000, QImage::Format_ARGB32); + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); - textLayoutDraw.fill(0xffffffff); - drawGlyphs.fill(0xffffffff); + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); QString s; s.append(QLatin1Char('A')); @@ -286,10 +286,10 @@ void tst_QGlyphs::drawNonExistentGlyphs() glyphs.setPositions(glyphPositions); glyphs.setFont(m_testFont); - QImage image(1000, 1000, QImage::Format_ARGB32); - image.fill(0); + QPixmap image(1000, 1000); + image.fill(Qt::white); - QImage imageBefore = image; + QPixmap imageBefore = image; { QPainter p(&image); p.drawGlyphs(QPointF(50, 50), glyphs); @@ -312,11 +312,11 @@ void tst_QGlyphs::drawMultiScriptText1() textLayout.createLine(); textLayout.endLayout(); - QImage textLayoutDraw(1000, 1000, QImage::Format_ARGB32); - textLayoutDraw.fill(0xffffffff); + QPixmap textLayoutDraw(1000, 1000); + textLayoutDraw.fill(Qt::white); - QImage drawGlyphs(1000, 1000, QImage::Format_ARGB32); - drawGlyphs.fill(0xffffffff); + QPixmap drawGlyphs(1000, 1000); + drawGlyphs.fill(Qt::white); QList glyphsList = textLayout.glyphs(); QCOMPARE(glyphsList.size(), 1); @@ -356,11 +356,11 @@ void tst_QGlyphs::drawMultiScriptText2() textLayout.createLine(); textLayout.endLayout(); - QImage textLayoutDraw(1000, 1000, QImage::Format_ARGB32); - textLayoutDraw.fill(0xffffffff); + QPixmap textLayoutDraw(1000, 1000); + textLayoutDraw.fill(Qt::white); - QImage drawGlyphs(1000, 1000, QImage::Format_ARGB32); - drawGlyphs.fill(0xffffffff); + QPixmap drawGlyphs(1000, 1000); + drawGlyphs.fill(Qt::white); QList glyphsList = textLayout.glyphs(); QCOMPARE(glyphsList.size(), 2); -- cgit v0.12 From 29ef46edfd4f01da7d79338c031b237af415be3a Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Jun 2010 16:43:04 +0200 Subject: Fix compilation with RVCT RVCT does not like static template functions --- src/gui/painting/qdrawhelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index bd961a4..a765102 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -675,7 +675,7 @@ static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, i template -static inline void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2) +Q_STATIC_TEMPLATE_FUNCTION inline void fetchTransformedBilinear_pixelBounds(int max, int l1, int l2, int &v1, int &v2) { if (blendType == BlendTransformedBilinearTiled) { v1 %= max; -- cgit v0.12 From 23306a399c0703eea7420231903c850566bfe2f0 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Jun 2010 21:01:36 +0200 Subject: Make tst_image a little bit more tollerent to rounding errors --- tests/auto/qimage/tst_qimage.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 10514d9..2164b05 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -1426,11 +1426,6 @@ static inline int rand8() return int(256. * (qrand() / (RAND_MAX + 1.0))); } -static inline bool compare(int a, int b, int tolerance) -{ - return qAbs(a - b) <= tolerance; -} - // compares img.scale against the bilinear filtering used by QPainter void tst_QImage::smoothScale3() { @@ -1458,6 +1453,7 @@ void tst_QImage::smoothScale3() p.scale(scales[i], scales[i]); p.drawImage(0, 0, img); p.end(); + int err = 0; for (int y = 0; y < a.height(); ++y) { for (int x = 0; x < a.width(); ++x) { @@ -1465,11 +1461,15 @@ void tst_QImage::smoothScale3() QRgb cb = b.pixel(x, y); // tolerate a little bit of rounding errors - QVERIFY(compare(qRed(ca), qRed(cb), 16)); - QVERIFY(compare(qGreen(ca), qGreen(cb), 16)); - QVERIFY(compare(qBlue(ca), qBlue(cb), 16)); + bool r = true; + r &= qAbs(qRed(ca) - qRed(cb)) <= 18; + r &= qAbs(qGreen(ca) - qGreen(cb)) <= 18; + r &= qAbs(qBlue(ca) - qBlue(cb)) <= 18; + if (!r) + err++; } } + QCOMPARE(err, 0); } } -- cgit v0.12 From 8c08c737837389f5ff2641219eb901ad217d3f24 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 9 Jun 2010 09:39:47 +0200 Subject: Add count, at and clear to flickableData Reviewed-by: Aaron Kennedy --- .../graphicsitems/qdeclarativeflickable.cpp | 42 +++++++++++++++++++++- .../graphicsitems/qdeclarativeflickable_p_p.h | 3 ++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 10dc0f8..c487715 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1015,10 +1015,50 @@ void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty o->setParent(prop->object); } +int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty *property) +{ + QDeclarativeItem *viewport = static_cast(property->data)->viewport; + return viewport->childItems().count() + viewport->children().count(); +} + +QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty *property, int index) +{ + QDeclarativeItem *viewport = static_cast(property->data)->viewport; + + int childItemCount = viewport->childItems().count(); + + if (index < 0) + return 0; + + if (index < childItemCount) { + return viewport->childItems().at(index)->toGraphicsObject(); + } else { + return viewport->children().at(index - childItemCount); + } + + return 0; +} + +void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty *property) +{ + QDeclarativeItem *viewport = static_cast(property->data)->viewport; + + const QList graphicsItems = viewport->childItems(); + for (int i = 0; i < graphicsItems.count(); i++) + viewport->scene()->removeItem(graphicsItems[i]); + + const QList objects = viewport->children(); + for (int i = 0; i < objects.count(); i++) + objects[i]->setParent(0); +} + QDeclarativeListProperty QDeclarativeFlickable::flickableData() { Q_D(QDeclarativeFlickable); - return QDeclarativeListProperty(this, (void *)d, QDeclarativeFlickablePrivate::data_append); + return QDeclarativeListProperty(this, (void *)d, QDeclarativeFlickablePrivate::data_append, + QDeclarativeFlickablePrivate::data_count, + QDeclarativeFlickablePrivate::data_at, + QDeclarativeFlickablePrivate::data_clear); } QDeclarativeListProperty QDeclarativeFlickable::flickableChildren() diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h index 66d2678..0b80b1f 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p_p.h @@ -171,6 +171,9 @@ public: // flickableData property static void data_append(QDeclarativeListProperty *, QObject *); + static int data_count(QDeclarativeListProperty *); + static QObject * data_at(QDeclarativeListProperty *, int); + static void data_clear(QDeclarativeListProperty *); }; class QDeclarativeFlickableVisibleArea : public QObject -- cgit v0.12 From ee15568a59f56cd000fd30fe598a90acaee1c670 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 9 Jun 2010 13:08:32 +0200 Subject: Fix regression in popup behavior on Windows Popups without a parent would unintentionally deactivate their parents following af7d2b2127d. In order to avoid this, we do not activate popups when there is an active application window. System tray popups are still activated. Reviewed-by: denis Task-number: QTBUG-11061 --- src/gui/kernel/qwidget_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index a7e66bf..9d96fcb 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1166,7 +1166,7 @@ void QWidgetPrivate::show_sys() // This is to resolve the problem where popups are opened from the // system tray and not being implicitly activated if (q->windowType() == Qt::Popup && - (!q->parentWidget() || !q->parentWidget()->isActiveWindow())) + !q->parentWidget() && !qApp->activeWindow()) q->activateWindow(); } -- cgit v0.12 From c80b6bbb0d1e02c9ba51ca0a6da47df22b0afff8 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 10 Jun 2010 13:03:23 +0200 Subject: Export QDeclarativeAbstractAnimation and QDeclarativeScriptAction This exports are needed by the Qml Designer to deactivate the animations. Reviewed-by: Kai Koehne --- src/declarative/util/qdeclarativeanimation_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qdeclarativeanimation_p.h b/src/declarative/util/qdeclarativeanimation_p.h index e7cd8a8..fd9c050 100644 --- a/src/declarative/util/qdeclarativeanimation_p.h +++ b/src/declarative/util/qdeclarativeanimation_p.h @@ -63,7 +63,7 @@ QT_MODULE(Declarative) class QDeclarativeAbstractAnimationPrivate; class QDeclarativeAnimationGroup; -class Q_AUTOTEST_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus +class Q_DECLARATIVE_EXPORT QDeclarativeAbstractAnimation : public QObject, public QDeclarativePropertyValueSource, public QDeclarativeParserStatus { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeAbstractAnimation) @@ -162,7 +162,7 @@ protected: }; class QDeclarativeScriptActionPrivate; -class QDeclarativeScriptAction : public QDeclarativeAbstractAnimation +class Q_DECLARATIVE_EXPORT QDeclarativeScriptAction : public QDeclarativeAbstractAnimation { Q_OBJECT Q_DECLARE_PRIVATE(QDeclarativeScriptAction) -- cgit v0.12 From 572d13eeaaa7aea7aa09d6c5de420338f742ea4b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 9 Jun 2010 16:55:59 +0200 Subject: Fix warning with gcc in -pedantic Empty marcro arguments throws warning on some compilers. (Correction of 89dfa8d7a46c992b066e5335d64089bf796e2f83) Reviewed-by: Thiago Task-number: QTBUG-11334 --- src/corelib/global/qglobal.h | 6 +++--- src/corelib/tools/qsharedpointer_impl.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 28ac377..6bcc95b 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -2041,8 +2041,7 @@ enum { /* TYPEINFO flags */ Q_DUMMY_TYPE = 0x4 }; -#define Q_DECLARE_TYPEINFO_TEMPLATE(TYPE, FLAGS, TEMPLATE_ARG) \ -template \ +#define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) \ class QTypeInfo \ { \ public: \ @@ -2057,7 +2056,8 @@ public: \ } #define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \ -Q_DECLARE_TYPEINFO_TEMPLATE(TYPE, FLAGS, ) +template<> \ +Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) template diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 9e40bd5..2329470 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -844,8 +844,8 @@ qobject_cast(const QWeakPointer &src) #endif -Q_DECLARE_TYPEINFO_TEMPLATE(QWeakPointer, Q_MOVABLE_TYPE, typename T); -Q_DECLARE_TYPEINFO_TEMPLATE(QSharedPointer, Q_MOVABLE_TYPE, typename T); +template Q_DECLARE_TYPEINFO_BODY(QWeakPointer, Q_MOVABLE_TYPE); +template Q_DECLARE_TYPEINFO_BODY(QSharedPointer, Q_MOVABLE_TYPE); QT_END_NAMESPACE -- cgit v0.12 From 746114fb8a1036e5ccec88fe22e9378925d3a34a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 11 Jun 2010 10:57:21 +0200 Subject: Avoid the incorrect usage of QScopedArrayPointer. Don't allow an array of objects stored as a base class. struct A{int a;}; struct B : public A{int b;}; A *foo = new B[2]; foo[1].a = 0; // crash due to (foo + sizeof(A)) and sizeof(A) != sizeof(B) delete [] foo; Reviewed-by: Olivier Goffart --- src/corelib/tools/qscopedpointer.h | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index bc76a3b..e972d71 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -54,7 +54,7 @@ struct QScopedPointerDeleter static inline void cleanup(T *pointer) { // Enforce a complete type. - // If you get a compile error here, read the secion on forward declared + // If you get a compile error here, read the section on forward declared // classes in the QScopedPointer documentation. typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ]; (void) sizeof(IsIncompleteType); @@ -69,7 +69,7 @@ struct QScopedPointerArrayDeleter static inline void cleanup(T *pointer) { // Enforce a complete type. - // If you get a compile error here, read the secion on forward declared + // If you get a compile error here, read the section on forward declared // classes in the QScopedPointer documentation. typedef char IsIncompleteType[ sizeof(T) ? 1 : -1 ]; (void) sizeof(IsIncompleteType); @@ -186,11 +186,18 @@ template Q_INLINE_TEMPLATE void qSwap(QScopedPointer &p1, QScopedPointer &p2) { p1.swap(p2); } +namespace QtPrivate { + template struct QScopedArrayEnsureSameType; + template struct QScopedArrayEnsureSameType { typedef X* Type; }; + template struct QScopedArrayEnsureSameType { typedef X* Type; }; +} + template > class QScopedArrayPointer : public QScopedPointer { public: - explicit inline QScopedArrayPointer(T *p = 0) + template + explicit inline QScopedArrayPointer(D *p = 0, typename QtPrivate::QScopedArrayEnsureSameType::Type = 0) : QScopedPointer(p) { } @@ -206,6 +213,17 @@ public: } private: + explicit inline QScopedArrayPointer(void *p) { + // Enforce the same type. + + // If you get a compile error here, make sure you declare + // QScopedArrayPointer with the same template type as you pass to the + // constructor. See also the QScopedPointer documentation. + + // Storing a scalar array as a pointer to a different type is not + // allowed and results in undefined behavior. + } + Q_DISABLE_COPY(QScopedArrayPointer) }; -- 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 5d82a49aeba2a4b2608ea114702920ced97faddf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 11 Jun 2010 13:17:43 +0200 Subject: Fix compilation: remove spurious semi-colon --- tools/linguist/lupdate/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 6e3ab5c..a575192 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -63,7 +63,7 @@ static void printOut(const QString & out) } class LU { - Q_DECLARE_TR_FUNCTIONS(LUpdate); + Q_DECLARE_TR_FUNCTIONS(LUpdate) }; static void recursiveFileInfoList(const QDir &dir, -- 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 999caa5d5418cde3bf0cb531fe2c1e15da537dd9 Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Fri, 11 Jun 2010 13:06:38 +0200 Subject: Adjust handling of library .bundle on Mac QLibrary::isLibrary() returns true for files with the sufix .bundle. But we did not use to determine the proper library within the bundle in that case. Reviewed-by: Fabien Freling Task-number: QTBUG-11217 --- src/corelib/plugin/qlibrary_unix.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp index e8f0eae..9ad1c01 100644 --- a/src/corelib/plugin/qlibrary_unix.cpp +++ b/src/corelib/plugin/qlibrary_unix.cpp @@ -223,11 +223,15 @@ bool QLibraryPrivate::load_sys() #ifdef Q_OS_MAC if (!pHnd) { - if (CFBundleRef bundle = CFBundleGetBundleWithIdentifier(QCFString(fileName))) { + QByteArray utf8Bundle = fileName.toUtf8(); + QCFType bundleUrl = CFURLCreateFromFileSystemRepresentation(NULL, reinterpret_cast(utf8Bundle.data()), utf8Bundle.length(), true); + QCFType bundle = CFBundleCreate(NULL, bundleUrl); + if(bundle) { QCFType url = CFBundleCopyExecutableURL(bundle); - QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); - pHnd = dlopen(QFile::encodeName(str), dlFlags); - attempt = str; + char executableFile[FILENAME_MAX]; + CFURLGetFileSystemRepresentation(url, true, reinterpret_cast(executableFile), FILENAME_MAX); + attempt = QString::fromUtf8(executableFile); + pHnd = dlopen(QFile::encodeName(attempt), dlFlags); } } #endif -- cgit v0.12 From f189881fbe6d06051c4c6d86419533ddd9966d2a Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Mon, 14 Jun 2010 10:14:05 +0200 Subject: Finally, remove some trailing whitespace. Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsgridlayout.h | 2 +- src/gui/graphicsview/qgraphicsitem.cpp | 4 ++-- src/gui/graphicsview/qgraphicsitemanimation.cpp | 22 +++++++++++----------- src/gui/graphicsview/qgraphicslayout.cpp | 10 +++++----- src/gui/graphicsview/qgraphicslayout_p.cpp | 12 ++++++------ src/gui/graphicsview/qgraphicslayout_p.h | 8 ++++---- src/gui/graphicsview/qgraphicslayoutitem.cpp | 2 +- src/gui/graphicsview/qgraphicslayoutitem.h | 2 +- src/gui/graphicsview/qgraphicsview.cpp | 2 +- src/gui/graphicsview/qgraphicswidget_p.cpp | 2 +- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.h b/src/gui/graphicsview/qgraphicsgridlayout.h index 6580a02..ddfb447 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.h +++ b/src/gui/graphicsview/qgraphicsgridlayout.h @@ -109,7 +109,7 @@ public: int columnCount() const; QGraphicsLayoutItem *itemAt(int row, int column) const; - + // inherited from QGraphicsLayout int count() const; QGraphicsLayoutItem *itemAt(int index) const; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b867345..d1f6eb3 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7618,9 +7618,9 @@ int QGraphicsItemPrivate::children_count(QDeclarativeListProperty *list, int index) { QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast(list->object)); - if (index >= 0 && index < d->children.count()) + if (index >= 0 && index < d->children.count()) return d->children.at(index)->toGraphicsObject(); - else + else return 0; } diff --git a/src/gui/graphicsview/qgraphicsitemanimation.cpp b/src/gui/graphicsview/qgraphicsitemanimation.cpp index 9cb9a8d..9689616 100644 --- a/src/gui/graphicsview/qgraphicsitemanimation.cpp +++ b/src/gui/graphicsview/qgraphicsitemanimation.cpp @@ -49,20 +49,20 @@ The QGraphicsItemAnimation class animates a QGraphicsItem. You can schedule changes to the item's transformation matrix at - specified steps. The QGraphicsItemAnimation class has a - current step value. When this value changes the transformations - scheduled at that step are performed. The current step of the + specified steps. The QGraphicsItemAnimation class has a + current step value. When this value changes the transformations + scheduled at that step are performed. The current step of the animation is set with the \c setStep() function. QGraphicsItemAnimation will do a simple linear interpolation - between the nearest adjacent scheduled changes to calculate the + between the nearest adjacent scheduled changes to calculate the matrix. For instance, if you set the position of an item at values 0.0 and 1.0, the animation will show the item moving in a straight - line between these positions. The same is true for scaling and + line between these positions. The same is true for scaling and rotation. It is usual to use the class with a QTimeLine. The timeline's - \l{QTimeLine::}{valueChanged()} signal is then connected to the + \l{QTimeLine::}{valueChanged()} signal is then connected to the \c setStep() slot. For example, you can set up an item for rotation by calling \c setRotationAt() for different step values. The animations timeline is set with the setTimeLine() function. @@ -286,7 +286,7 @@ QList > QGraphicsItemAnimation::posList() const QList > list; for (int i = 0; i < d->xPosition.size(); ++i) list << QPair(d->xPosition.at(i).step, QPointF(d->xPosition.at(i).value, d->yPosition.at(i).value)); - + return list; } @@ -343,7 +343,7 @@ QList > QGraphicsItemAnimation::rotationList() const QList > list; for (int i = 0; i < d->rotation.size(); ++i) list << QPair(d->rotation.at(i).step, d->rotation.at(i).value); - + return list; } @@ -395,7 +395,7 @@ QList > QGraphicsItemAnimation::translationList() const QList > list; for (int i = 0; i < d->xTranslation.size(); ++i) list << QPair(d->xTranslation.at(i).step, QPointF(d->xTranslation.at(i).value, d->yTranslation.at(i).value)); - + return list; } @@ -447,7 +447,7 @@ QList > QGraphicsItemAnimation::scaleList() const QList > list; for (int i = 0; i < d->horizontalScale.size(); ++i) list << QPair(d->horizontalScale.at(i).step, QPointF(d->horizontalScale.at(i).value, d->verticalScale.at(i).value)); - + return list; } @@ -499,7 +499,7 @@ QList > QGraphicsItemAnimation::shearList() const QList > list; for (int i = 0; i < d->horizontalShear.size(); ++i) list << QPair(d->horizontalShear.at(i).step, QPointF(d->horizontalShear.at(i).value, d->verticalShear.at(i).value)); - + return list; } diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp index 86b4589..91f386f 100644 --- a/src/gui/graphicsview/qgraphicslayout.cpp +++ b/src/gui/graphicsview/qgraphicslayout.cpp @@ -145,7 +145,7 @@ QT_BEGIN_NAMESPACE /*! Contructs a QGraphicsLayout object. - + \a parent is passed to QGraphicsLayoutItem's constructor and the QGraphicsLayoutItem's isLayout argument is set to \e true. @@ -259,7 +259,7 @@ void QGraphicsLayout::activate() return; d->activateRecursive(this); - + // we don't call activate on a sublayout, but somebody might. // Therefore, we walk to the parentitem of the toplevel layout. QGraphicsLayoutItem *parentItem = this; @@ -270,7 +270,7 @@ void QGraphicsLayout::activate() Q_ASSERT(!parentItem->isLayout()); setGeometry(parentItem->contentsRect()); // relayout children - + // ### bug, should be parentItem ? parentLayoutItem()->updateGeometry(); // bubble up; will set activated to false // ### too many resizes? maybe we should walk up the chain to the @@ -307,7 +307,7 @@ void QGraphicsLayout::invalidate() // does not call the base implementation? In addition, updateGeometry() // does more than we need. layoutItem->d_func()->sizeHintCacheDirty = true; - layoutItem = layoutItem->parentLayoutItem(); + layoutItem = layoutItem->parentLayoutItem(); } if (layoutItem) layoutItem->d_func()->sizeHintCacheDirty = true; @@ -347,7 +347,7 @@ void QGraphicsLayout::updateGeometry() widget. QGraphicsLayout uses this event handler to listen for layout related events such as geometry changes, layout changes or layout direction changes. - + \a e is a pointer to the event. You can reimplement this event handler to track similar events for your diff --git a/src/gui/graphicsview/qgraphicslayout_p.cpp b/src/gui/graphicsview/qgraphicslayout_p.cpp index 88652ec..163fc65 100644 --- a/src/gui/graphicsview/qgraphicslayout_p.cpp +++ b/src/gui/graphicsview/qgraphicslayout_p.cpp @@ -136,13 +136,13 @@ static bool removeLayoutItemFromLayout(QGraphicsLayout *lay, QGraphicsLayoutItem /*! \internal - This function is called from subclasses to add a layout item \a layoutItem + This function is called from subclasses to add a layout item \a layoutItem to a layout. It takes care of automatically reparenting graphics items, if needed. If \a layoutItem is a is already in a layout, it will remove it from that layout. - + */ void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) { @@ -150,14 +150,14 @@ void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) { if (maybeLayout->isLayout()) removeLayoutItemFromLayout(static_cast(maybeLayout), layoutItem); - } + } layoutItem->setParentLayoutItem(q); if (layoutItem->isLayout()) { if (QGraphicsItem *parItem = parentItem()) { static_cast(layoutItem)->d_func()->reparentChildItems(parItem); } } else { - if (QGraphicsItem *item = layoutItem->graphicsItem()) { + if (QGraphicsItem *item = layoutItem->graphicsItem()) { QGraphicsItem *newParent = parentItem(); QGraphicsItem *oldParent = item->parentItem(); if (oldParent == newParent || !newParent) @@ -182,7 +182,7 @@ void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item) QGraphicsLayout *layout = static_cast(item); if (layout->d_func()->activated) layout->invalidate(); - + for (int i = layout->count() - 1; i >= 0; --i) { QGraphicsLayoutItem *childItem = layout->itemAt(i); if (childItem) @@ -194,5 +194,5 @@ void QGraphicsLayoutPrivate::activateRecursive(QGraphicsLayoutItem *item) QT_END_NAMESPACE - + #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicslayout_p.h b/src/gui/graphicsview/qgraphicslayout_p.h index 3083555..5c8e706 100644 --- a/src/gui/graphicsview/qgraphicslayout_p.h +++ b/src/gui/graphicsview/qgraphicslayout_p.h @@ -84,7 +84,7 @@ class QLayoutStyleInfo public: inline QLayoutStyleInfo() { invalidate(); } inline QLayoutStyleInfo(QStyle *style, QWidget *widget) - : m_valid(true), m_style(style), m_widget(widget) + : m_valid(true), m_style(style), m_widget(widget) { Q_ASSERT(style); if (widget) //### @@ -112,7 +112,7 @@ public: return m_defaultSpacing[o - 1]; } - inline qreal perItemSpacing(QSizePolicy::ControlType control1, + inline qreal perItemSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation) const { @@ -132,7 +132,7 @@ class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPriva Q_DECLARE_PUBLIC(QGraphicsLayout) public: - QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0), + QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0), activated(true) { } void reparentChildItems(QGraphicsItem *newParent); @@ -148,7 +148,7 @@ public: QT_END_NAMESPACE - + #endif //QT_NO_GRAPHICSVIEW #endif diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 5a7f1af..f4d77f0 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -648,7 +648,7 @@ void QGraphicsLayoutItem::setMaximumHeight(qreal height) is equivalent to the item's position in parent coordinates). You must reimplement this function in a subclass of QGraphicsLayoutItem to - receive geometry updates. The layout will call this function when it does a + receive geometry updates. The layout will call this function when it does a rearrangement. If \a rect is outside of the bounds of minimumSize and maximumSize, it diff --git a/src/gui/graphicsview/qgraphicslayoutitem.h b/src/gui/graphicsview/qgraphicslayoutitem.h index f707c62..cb894a4 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.h +++ b/src/gui/graphicsview/qgraphicslayoutitem.h @@ -118,7 +118,7 @@ protected: private: QSizeF *effectiveSizeHints(const QSizeF &constraint) const; Q_DECLARE_PRIVATE(QGraphicsLayoutItem) - + friend class QGraphicsLayout; }; diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index a83b528..8076a21 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -3703,7 +3703,7 @@ void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect) } /*! - \obsolete + \obsolete Draws the items \a items in the scene using \a painter, after the background and before the foreground are drawn. \a numItems is the number diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 28070da..d503cff 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -761,7 +761,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new QGraphicsWidget *firstOld = 0; bool wasPreviousNew = true; - + while (w != q) { bool isCurrentNew = q->isAncestorOf(w); if (isCurrentNew) { -- cgit v0.12 From 171ad741fda84384a64ce56c847de7667051914c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 15 Jun 2010 02:49:18 +0200 Subject: Fix tst_QGlyphs to pass on Windows XP Hangul not supported on XP by default, so change the script in the tests to greek instead. --- tests/auto/qglyphs/tst_qglyphs.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index 90309ea..5df5889 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -46,7 +46,7 @@ #include #include -//#define DEBUG_SAVE_IMAGE +#define DEBUG_SAVE_IMAGE class tst_QGlyphs: public QObject { @@ -305,7 +305,7 @@ void tst_QGlyphs::drawNonExistentGlyphs() void tst_QGlyphs::drawMultiScriptText1() { QString text; - text += QChar(0x3131); // Hangul, Kiyeok + text += QChar(0x03D0); // Greek, beta QTextLayout textLayout(text); textLayout.beginLayout(); @@ -349,7 +349,7 @@ void tst_QGlyphs::drawMultiScriptText2() QString text; text += QChar(0x0621); // Arabic, Hamza - text += QChar(0x3131); // Hangul, Kiyeok + text += QChar(0x03D0); // Greek, beta QTextLayout textLayout(text); textLayout.beginLayout(); -- cgit v0.12 From 7b7f3869b15cee6f6815e10d49dcb8209a415edd Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 15 Jun 2010 09:29:57 +0200 Subject: Remove debug info from tst_QGlyphs Mistakenly added in 171ad741fda84384a64ce56c847de7667051914c. --- tests/auto/qglyphs/tst_qglyphs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index 5df5889..54a69dc 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -46,7 +46,7 @@ #include #include -#define DEBUG_SAVE_IMAGE +// #define DEBUG_SAVE_IMAGE class tst_QGlyphs: public QObject { -- 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 4be622995ad6a46b10788f5d62ed2368cffcb3dd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 16 Jun 2010 11:00:15 +0200 Subject: QListView: speedup QListView::setRowHidden() Basically the same optimisation that had been made long ago in the tree view: Use the right data structure for QListViewPrivate::hiddenRows (QSet instead of QVector) Task-number: QTBUG-11438 Reviewed-by: Gabriel --- src/gui/itemviews/qlistview.cpp | 13 ++++++++----- src/gui/itemviews/qlistview_p.h | 7 +++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 846d911..c20e0b1 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -756,10 +756,13 @@ void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int e // if the parent is above d->root in the tree, nothing will happen QAbstractItemView::rowsAboutToBeRemoved(parent, start, end); if (parent == d->root) { - for (int i = d->hiddenRows.count() - 1; i >= 0; --i) { - int hiddenRow = d->hiddenRows.at(i).row(); + QSet::iterator it = d->hiddenRows.begin(); + while (it != d->hiddenRows.end()) { + int hiddenRow = it->row(); if (hiddenRow >= start && hiddenRow <= end) { - d->hiddenRows.remove(i); + it = d->hiddenRows.erase(it); + } else { + ++it; } } } @@ -1849,12 +1852,12 @@ bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QMo void QCommonListViewBase::appendHiddenRow(int row) { - dd->hiddenRows.append(dd->model->index(row, 0, qq->rootIndex())); + dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex())); } void QCommonListViewBase::removeHiddenRow(int row) { - dd->hiddenRows.remove(dd->hiddenRows.indexOf(dd->model->index(row, 0, qq->rootIndex()))); + dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex())); } void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step) diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index 9ae1f50..1b71131 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -378,7 +378,10 @@ public: inline bool isSelectionRectVisible() const { return showElasticBand; } inline QModelIndex modelIndex(int row) const { return model->index(row, column, root); } - inline bool isHidden(int row) const { return hiddenRows.contains(model->index(row, 0, root)); } + inline bool isHidden(int row) const { + QModelIndex idx = model->index(row, 0, root); + return isPersistent(idx) && hiddenRows.contains(idx); + } inline bool isHiddenOrDisabled(int row) const { return isHidden(row) || !isIndexEnabled(modelIndex(row)); } inline void removeCurrentAndDisabled(QVector *indexes, const QModelIndex ¤t) const { @@ -432,7 +435,7 @@ public: QBasicTimer batchLayoutTimer; // used for hidden items - QVector hiddenRows; + QSet hiddenRows; int column; bool uniformItemSizes; -- cgit v0.12 From a4376f3760fae97b3ae45c9ae7b62ed505bfa05d Mon Sep 17 00:00:00 2001 From: kh1 Date: Wed, 16 Jun 2010 12:29:53 +0200 Subject: Fix some kind of race condition while using remote commands. Because of async content loading, we have to cache the url to load. A combination of SetSource and SyncContents would have lead to sync to the old url till loading was finished. So return the cached during loading. Task-number: QTBUG-11342 Reviewed-by: ck --- tools/assistant/tools/assistant/helpviewer.cpp | 7 ++++++- tools/assistant/tools/assistant/helpviewer.h | 2 ++ tools/assistant/tools/assistant/helpviewer_p.h | 4 ++++ tools/assistant/tools/assistant/helpviewer_qtb.cpp | 1 + tools/assistant/tools/assistant/helpviewer_qwv.cpp | 12 ++++++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/helpviewer.cpp b/tools/assistant/tools/assistant/helpviewer.cpp index a448dd4..2e4b60c 100644 --- a/tools/assistant/tools/assistant/helpviewer.cpp +++ b/tools/assistant/tools/assistant/helpviewer.cpp @@ -189,9 +189,14 @@ void HelpViewer::home() // -- private slots +void HelpViewer::setLoadStarted() +{ + d->m_loadFinished = false; +} + void HelpViewer::setLoadFinished(bool ok) { - Q_UNUSED(ok) + d->m_loadFinished = ok; emit sourceChanged(source()); } diff --git a/tools/assistant/tools/assistant/helpviewer.h b/tools/assistant/tools/assistant/helpviewer.h index 847b0ca..939096d 100644 --- a/tools/assistant/tools/assistant/helpviewer.h +++ b/tools/assistant/tools/assistant/helpviewer.h @@ -127,6 +127,7 @@ signals: void highlighted(const QString &link); void printRequested(); #else + void loadStarted(); void loadFinished(bool finished); #endif @@ -138,6 +139,7 @@ protected: private slots: void actionChanged(); + void setLoadStarted(); void setLoadFinished(bool ok); private: diff --git a/tools/assistant/tools/assistant/helpviewer_p.h b/tools/assistant/tools/assistant/helpviewer_p.h index 2772905..d65bab5 100644 --- a/tools/assistant/tools/assistant/helpviewer_p.h +++ b/tools/assistant/tools/assistant/helpviewer_p.h @@ -67,6 +67,7 @@ public: HelpViewerPrivate() #endif { + m_loadFinished = false; } #ifdef QT_NO_WEBKIT @@ -112,6 +113,9 @@ public: bool forceFont; QString lastAnchor; #endif // QT_NO_WEBKIT + +public: + bool m_loadFinished; }; QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/helpviewer_qtb.cpp b/tools/assistant/tools/assistant/helpviewer_qtb.cpp index f6b5022..af744b7 100644 --- a/tools/assistant/tools/assistant/helpviewer_qtb.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qtb.cpp @@ -160,6 +160,7 @@ void HelpViewer::setSource(const QUrl &url) if (launchWithExternalApp(url)) return; + emit loadStarted(); QString string = url.toString(); const HelpEngineWrapper &engine = HelpEngineWrapper::instance(); const QUrl &resolvedUrl = (string == QLatin1String("help") ? LocalHelpFile : diff --git a/tools/assistant/tools/assistant/helpviewer_qwv.cpp b/tools/assistant/tools/assistant/helpviewer_qwv.cpp index f61d6d4..8993ac9 100644 --- a/tools/assistant/tools/assistant/helpviewer_qwv.cpp +++ b/tools/assistant/tools/assistant/helpviewer_qwv.cpp @@ -180,6 +180,7 @@ private: bool closeNewTabIfNeeded; friend class HelpViewer; + QUrl m_loadingUrl; Qt::MouseButtons m_pressedButtons; Qt::KeyboardModifiers m_keyboardModifiers; }; @@ -237,6 +238,11 @@ bool HelpPage::acceptNavigationRequest(QWebFrame *, return false; } + m_loadingUrl = url; // because of async page loading, we will hit some kind + // of race condition while using a remote command, like a combination of + // SetSource; SyncContent. SetSource would be called and SyncContents shortly + // afterwards, but the page might not have finished loading and the old url + // would be returned. return true; } @@ -270,6 +276,7 @@ HelpViewer::HelpViewer(qreal zoom, QWidget *parent) connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this, SIGNAL(highlighted(QString))); connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl))); + connect(this, SIGNAL(loadStarted()), this, SLOT(setLoadStarted())); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool))); connect(this, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged())); connect(page(), SIGNAL(printRequested(QWebFrame*)), this, SIGNAL(printRequested())); @@ -336,6 +343,11 @@ void HelpViewer::setTitle(const QString &title) QUrl HelpViewer::source() const { TRACE_OBJ + HelpPage *currentPage = static_cast (page()); + if (currentPage && !d->m_loadFinished) { + // see HelpPage::acceptNavigationRequest(...) + return currentPage->m_loadingUrl; + } return url(); } -- 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 660145873a05b159b2f96dab8f0eaa75499146ff Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 7 Jun 2010 16:26:52 +0200 Subject: qdrawhelper: Use SSE2 in fetchTransformedBilinear (when scalling up) It is possible to use SSE2 to speedup the smooth scaling of a pixmap Benchmark results: Drawing the home screen of Qt Creator: Qt 4.7: 45fps After last set of patches: 75fps After this patch: 95fps Reviewed-by: Samuel --- src/gui/painting/qdrawhelper.cpp | 85 +++++++++++++++++++++++++++++++++------- 1 file changed, 71 insertions(+), 14 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index a765102..51d841e 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -748,30 +748,87 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * int disty = (fy & 0x0000ffff) >> 8; int idisty = 256 - disty; int count = length * data->m11 + 2; - int x_ = fx >> 16; + int x = fx >> 16; - quint32 intermediate_buffer[buffer_size + 2][2]; + // The idea is first to do the interpolation between the row s1 and the row s2 + // into an intermediate buffer, then we interpolate between two pixel of this buffer. + + // 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); + int f = 0; + int lim = count; if (blendType == BlendTransformedBilinearTiled) { - x_ %= image_width; - if (x_ < 0) x_ += image_width; + x %= image_width; + if (x < 0) x += image_width; + } else { + lim = qMin(count, image_x2-x); + if (x < image_x1) { + Q_ASSERT(x < image_x2); + uint t = fetch(s1, image_x1, data->texture.colorTable); + uint b = fetch(s2, image_x1, data->texture.colorTable); + quint32 rb = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; + quint32 ag = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; + do { + intermediate_buffer[0][f] = rb; + intermediate_buffer[1][f] = ag; + f++; + x++; + } while (x < image_x1 && f < lim); + } } - for (int f = 0; f < count; f++) { - int x; + +#if defined(QT_ALWAYS_HAVE_SSE2) + if (blendType != BlendTransformedBilinearTiled && + (format == QImage::Format_ARGB32_Premultiplied || format == QImage::Format_RGB32)) { + + const __m128i disty_ = _mm_set1_epi16(disty); + const __m128i idisty_ = _mm_set1_epi16(idisty); + const __m128i colorMask = _mm_set1_epi32(0x00ff00ff); + + lim -= 3; + for (; f < lim; x += 4, f += 4) { + // Load 4 pixels from s1, and split the alpha-green and red-blue component + __m128i top = _mm_loadu_si128((__m128i*)((const uint *)(s1)+x)); + __m128i topAG = _mm_srli_epi16(top, 8); + __m128i topRB = _mm_and_si128(top, colorMask); + // Multiplies each colour component by idisty + topAG = _mm_mullo_epi16 (topAG, idisty_); + topRB = _mm_mullo_epi16 (topRB, idisty_); + + // Same for the s2 vector + __m128i bottom = _mm_loadu_si128((__m128i*)((const uint *)(s2)+x)); + __m128i bottomAG = _mm_srli_epi16(bottom, 8); + __m128i bottomRB = _mm_and_si128(bottom, colorMask); + bottomAG = _mm_mullo_epi16 (bottomAG, disty_); + bottomRB = _mm_mullo_epi16 (bottomRB, disty_); + + // Add the values, and shift to only keep 8 significant bits per colors + __m128i rAG =_mm_add_epi16(topAG, bottomAG); + rAG = _mm_srli_epi16(rAG, 8); + _mm_storeu_si128((__m128i*)(&intermediate_buffer[1][f]), rAG); + __m128i rRB =_mm_add_epi16(topRB, bottomRB); + rRB = _mm_srli_epi16(rRB, 8); + _mm_storeu_si128((__m128i*)(&intermediate_buffer[0][f]), rRB); + } + } +#endif + for (; f < count; f++) { // Same as above but without sse2 if (blendType == BlendTransformedBilinearTiled) { - if (x_ >= image_width) x_ -= image_width; - x = x_; + if (x >= image_width) x -= image_width; } else { - x = qBound(image_x1, x_, image_x2 - 1); + x = qMin(x, image_x2 - 1); } uint t = fetch(s1, x, data->texture.colorTable); uint b = fetch(s2, x, data->texture.colorTable); - intermediate_buffer[f][0] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; - intermediate_buffer[f][1] = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; - x_++; + intermediate_buffer[0][f] = (((t & 0xff00ff) * idisty + (b & 0xff00ff) * disty) >> 8) & 0xff00ff; + intermediate_buffer[1][f] = ((((t>>8) & 0xff00ff) * idisty + ((b>>8) & 0xff00ff) * disty) >> 8) & 0xff00ff; + x++; } + // Now interpolate the values from the intermediate_buffer to get the final result. fx &= fixed_scale - 1; Q_ASSERT((fx >> 16) == 0); while (b < end) { @@ -782,8 +839,8 @@ const uint * QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Operator * register int distx = (fx & 0x0000ffff) >> 8; register int idistx = 256 - distx; - int rb = ((intermediate_buffer[x1][0] * idistx + intermediate_buffer[x2][0] * distx) >> 8) & 0xff00ff; - int ag = (intermediate_buffer[x1][1] * idistx + intermediate_buffer[x2][1] * distx) & 0xff00ff00; + int rb = ((intermediate_buffer[0][x1] * idistx + intermediate_buffer[0][x2] * distx) >> 8) & 0xff00ff; + int ag = (intermediate_buffer[1][x1] * idistx + intermediate_buffer[1][x2] * distx) & 0xff00ff00; *b = rb | ag; b++; fx += fdx; -- 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 fb23b6893d5228d3716ed0899ef089aeeafec3bf Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 18 Jun 2010 14:30:37 +0200 Subject: Fix compiler warning --- src/corelib/tools/qscopedpointer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index e972d71..40d3851 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -213,7 +213,7 @@ public: } private: - explicit inline QScopedArrayPointer(void *p) { + explicit inline QScopedArrayPointer(void *) { // Enforce the same type. // If you get a compile error here, make sure you declare -- cgit v0.12 From 4a2ba043ed09375e4d9423def32084ab97ea560a Mon Sep 17 00:00:00 2001 From: Sergey Vidyuk Date: Fri, 18 Jun 2010 14:44:07 +0200 Subject: Added QObject::connect overload taking QMetaMethod as parameter Added QObject::connect() and QObject::disconnect() functions implementations which use QMetaMethod to specify signals and slots to be connected or disconnected. Merge-request: 636 Reviewed-by: Olivier Goffart Task-number: QTBUG-10637 --- src/corelib/kernel/qmetaobject.h | 2 + src/corelib/kernel/qmetaobject_p.h | 2 + src/corelib/kernel/qobject.cpp | 256 +++++++++++++++++++++++++++++++++++-- src/corelib/kernel/qobject.h | 17 +++ tests/auto/qobject/tst_qobject.cpp | 219 +++++++++++++++++++++++++++++++ 5 files changed, 487 insertions(+), 9 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index b700351..8124487 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -138,6 +138,8 @@ private: const QMetaObject *mobj; uint handle; friend struct QMetaObject; + friend struct QMetaObjectPrivate; + friend class QObject; }; Q_DECLARE_TYPEINFO(QMetaMethod, Q_MOVABLE_TYPE); diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h index b538787..23e08c8 100644 --- a/src/corelib/kernel/qmetaobject_p.h +++ b/src/corelib/kernel/qmetaobject_p.h @@ -131,6 +131,8 @@ struct QMetaObjectPrivate #ifndef QT_NO_QOBJECT //defined in qobject.cpp enum DisconnectType { DisconnectAll, DisconnectOne }; + static void memberIndexes(const QObject *obj, const QMetaMethod &member, + int *signalIndex, int *methodIndex); static bool connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type = 0, int *types = 0); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 6187633..dff282e 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2364,6 +2364,71 @@ int QObject::receivers(const char *signal) const } /*! + \internal + + This helper function calculates signal and method index for the given + member in the specified class. + + \li If member.mobj is 0 then both signalIndex and methodIndex are set to -1. + + \li If specified member is not a member of obj instance class (or one of + its parent classes) then both signalIndex and methodIndex are set to -1. + + This function is used by QObject::connect and QObject::disconnect which + are working with QMetaMethod. + + \param[out] signalIndex is set to the signal index of member. If the member + specified is not signal this variable is set to -1. + + \param[out] methodIndex is set to the method index of the member. If the + member is not a method of the object specified by obj param this variable + is set to -1. +*/ +void QMetaObjectPrivate::memberIndexes(const QObject *obj, + const QMetaMethod &member, + int *signalIndex, int *methodIndex) +{ + *signalIndex = -1; + *methodIndex = -1; + if (!obj || !member.mobj) + return; + const QMetaObject *m = obj->metaObject(); + // Check that member is member of obj class + while (m != 0 && m != member.mobj) + m = m->d.superdata; + if (!m) + return; + *signalIndex = *methodIndex = (member.handle - get(member.mobj)->methodData)/5; + + int signalOffset; + int methodOffset; + computeOffsets(m, &signalOffset, &methodOffset); + + *methodIndex += methodOffset; + if (member.methodType() == QMetaMethod::Signal) { + *signalIndex = originalClone(m, *signalIndex); + *signalIndex += signalOffset; + } else { + *signalIndex = -1; + } +} + +static inline void check_and_warn_compat(const QMetaObject *sender, const QMetaMethod &signal, + const QMetaObject *receiver, const QMetaMethod &method) +{ + if (signal.attributes() & QMetaMethod::Compatibility) { + if (!(method.attributes() & QMetaMethod::Compatibility)) + qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)", + sender->className(), signal.signature()); + } else if ((method.attributes() & QMetaMethod::Compatibility) && + method.methodType() == QMetaMethod::Signal) { + qWarning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)", + sender->className(), signal.signature(), + receiver->className(), method.signature()); + } +} + +/*! \threadsafe Creates a connection of the given \a type from the \a signal in @@ -2548,15 +2613,8 @@ bool QObject::connect(const QObject *sender, const char *signal, { QMetaMethod smethod = smeta->method(signal_absolute_index); QMetaMethod rmethod = rmeta->method(method_index); - if (warnCompat) { - if(smethod.attributes() & QMetaMethod::Compatibility) { - if (!(rmethod.attributes() & QMetaMethod::Compatibility)) - qWarning("QObject::connect: Connecting from COMPAT signal (%s::%s)", smeta->className(), signal); - } else if(rmethod.attributes() & QMetaMethod::Compatibility && membcode != QSIGNAL_CODE) { - qWarning("QObject::connect: Connecting from %s::%s to COMPAT slot (%s::%s)", - smeta->className(), signal, rmeta->className(), method); - } - } + if (warnCompat) + check_and_warn_compat(smeta, smethod, rmeta, rmethod); } #endif if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types)) @@ -2565,6 +2623,99 @@ bool QObject::connect(const QObject *sender, const char *signal, return true; } +/*! + \since 4.8 + + Creates a connection of the given \a type from the \a signal in + the \a sender object to the \a method in the \a receiver object. + Returns true if the connection succeeds; otherwise returns false. + + This function works in the same way as + connect(const QObject *sender, const char *signal, + const QObject *receiver, const char *method, + Qt::ConnectionType type) + but it uses QMetaMethod to specify signal and method. + + \see connect(const QObject *sender, const char *signal, + const QObject *receiver, const char *method, + Qt::ConnectionType type) + */ +bool QObject::connect(const QObject *sender, const QMetaMethod &signal, + const QObject *receiver, const QMetaMethod &method, + Qt::ConnectionType type) +{ + +#ifndef QT_NO_DEBUG + bool warnCompat = true; +#endif + if (type == Qt::AutoCompatConnection) { + type = Qt::AutoConnection; +#ifndef QT_NO_DEBUG + warnCompat = false; +#endif + } + + if (sender == 0 + || receiver == 0 + || signal.methodType() != QMetaMethod::Signal + || method.methodType() == QMetaMethod::Constructor) { + qWarning("QObject::connect: Cannot connect %s::%s to %s::%s", + sender ? sender->metaObject()->className() : "(null)", + signal.signature(), + receiver ? receiver->metaObject()->className() : "(null)", + method.signature() ); + return false; + } + + int signal_index; + int method_index; + { + int dummy; + QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy); + QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index); + } + + const QMetaObject *smeta = sender->metaObject(); + const QMetaObject *rmeta = receiver->metaObject(); + if (signal_index == -1) { + qWarning("QObject::connect: Can't find signal %s on instance of class %s", + signal.signature(), smeta->className()); + return false; + } + if (method_index == -1) { + qWarning("QObject::connect: Can't find method %s on instance of class %s", + method.signature(), rmeta->className()); + return false; + } + + if (!QMetaObject::checkConnectArgs(signal.signature(), method.signature())) { + qWarning("QObject::connect: Incompatible sender/receiver arguments" + "\n %s::%s --> %s::%s", + smeta->className(), signal.signature(), + rmeta->className(), method.signature()); + return false; + } + + int *types = 0; + if ((type == Qt::QueuedConnection) + && !(types = queuedConnectionTypes(signal.parameterTypes()))) + return false; + +#ifndef QT_NO_DEBUG + if (warnCompat) + check_and_warn_compat(smeta, signal, rmeta, method); +#endif + if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types)) + return false; + // Reconstructing SIGNAL() macro result for signal.signature() string + QByteArray signalSignature; + signalSignature.reserve(qstrlen(signal.signature())+1); + signalSignature.append((char)(QSIGNAL_CODE + '0')); + signalSignature.append(signal.signature()); + + const_cast(sender)->connectNotify(signalSignature.constData()); + return true; +} /*! \fn bool QObject::connect(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const @@ -2744,6 +2895,93 @@ bool QObject::disconnect(const QObject *sender, const char *signal, return res; } +/*! + \since 4.8 + + Disconnects \a signal in object \a sender from \a method in object + \a receiver. Returns true if the connection is successfully broken; + otherwise returns false. + + This function provides the same posibilities like + disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) + but uses QMetaMethod to represent the signal and the method to be disconnected. + + Additionally this function returnsfalse and no signals and slots disconnected + if: + \list 1 + + \i \a signal is not a member of sender class or one of its parent classes. + + \i \a method is not a member of receiver class or one of its parent classes. + + \i \a signal instance represents not a signal. + + \endlist + + QMetaMethod() may be used as wildcard in the meaning "any signal" or "any slot in receiving object". + In the same way 0 can be used for \a receiver in the meaning "any receiving object". In this case + method shoud also be QMetaMethod(). \a sender parameter should be never 0. + + \see disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) + */ +bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, + const QObject *receiver, const QMetaMethod &method) +{ + if (sender == 0 || (receiver == 0 && method.mobj != 0)) { + qWarning("Object::disconnect: Unexpected null parameter"); + return false; + } + if (signal.mobj) { + if(signal.methodType() != QMetaMethod::Signal) { + qWarning("Object::%s: Attempt to %s non-signal %s::%s", + "disconnect","unbind", + sender->metaObject()->className(), signal.signature()); + return false; + } + } + if (method.mobj) { + if(method.methodType() == QMetaMethod::Constructor) { + qWarning("QObject::disconect: cannot use constructor as argument %s::%s", + receiver->metaObject()->className(), method.signature()); + return false; + } + } + + int signal_index; + int method_index; + { + int dummy; + QMetaObjectPrivate::memberIndexes(sender, signal, &signal_index, &dummy); + QMetaObjectPrivate::memberIndexes(receiver, method, &dummy, &method_index); + } + // If we are here sender is not null. If signal is not null while signal_index + // is -1 then this signal is not a member of sender. + if (signal.mobj && signal_index == -1) { + qWarning("QObject::disconect: signal %s not found on class %s", + signal.signature(), sender->metaObject()->className()); + return false; + } + // If this condition is true then method is not a member of receeiver. + if (receiver && method.mobj && method_index == -1) { + qWarning("QObject::disconect: method %s not found on class %s", + method.signature(), receiver->metaObject()->className()); + return false; + } + + if (!QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index)) + return false; + if (!signal.mobj) { + const_cast(sender)->disconnectNotify(0); + } else { + // Reconstructing SIGNAL() macro result for signal.signature() string + QByteArray signalSignature; + signalSignature.reserve(qstrlen(signal.signature())+1); + signalSignature.append((char)(QSIGNAL_CODE + '0')); + signalSignature.append(signal.signature()); + const_cast(sender)->disconnectNotify(signalSignature.constData()); + } + return true; +} /*! \threadsafe diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 44e7ce5..d26f078 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -207,6 +207,21 @@ public: #endif #endif ); + + static bool connect(const QObject *sender, const QMetaMethod &signal, + const QObject *receiver, const QMetaMethod &method, + Qt::ConnectionType type = +#ifdef qdoc + Qt::AutoConnection +#else +#ifdef QT3_SUPPORT + Qt::AutoCompatConnection +#else + Qt::AutoConnection +#endif +#endif + ); + inline bool connect(const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type = #ifdef qdoc @@ -222,6 +237,8 @@ public: static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member); + static bool disconnect(const QObject *sender, const QMetaMethod &signal, + const QObject *receiver, const QMetaMethod &member); inline bool disconnect(const char *signal = 0, const QObject *receiver = 0, const char *member = 0) { return disconnect(this, signal, receiver, member); } diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 08b7c19..5caac15 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -129,6 +129,12 @@ private slots: void qMetaObjectConnect(); void qMetaObjectDisconnectOne(); void sameName(); + void connectByMetaMethods(); + void connectByMetaMethodSlotInsteadOfSignal(); + void connectConstructorByMetaMethod(); + void disconnectByMetaMethod(); + void disconnectNotSignalMetaMethod(); + protected: }; @@ -727,6 +733,24 @@ void tst_QObject::connectDisconnectNotify() // Test disconnectNotify for a complete disconnect ((SenderObject*)s)->disconnect((ReceiverObject*)r); + // Obtaining meta methods + int signalIndx = ((SenderObject*)s)->metaObject()->indexOfSignal( + QMetaObject::normalizedSignature(a_signal.toLatin1().constData()+1).constData()); + int methodIndx = ((ReceiverObject*)r)->metaObject()->indexOfMethod( + QMetaObject::normalizedSignature(a_slot.toLatin1().constData()+1).constData()); + QMetaMethod signal = ((SenderObject*)s)->metaObject()->method(signalIndx); + QMetaMethod method = ((ReceiverObject*)r)->metaObject()->method(methodIndx); + + // Test connectNotify when connecting by QMetaMethod + connect( (SenderObject*)s, signal, (ReceiverObject*)r, method ); + QCOMPARE( s->org_signal, s->nw_signal ); + QCOMPARE( s->org_signal.toLatin1(), QMetaObject::normalizedSignature(a_signal.toLatin1().constData()) ); + + // Test disconnectNotify when disconnecting by QMetaMethod + QObject::disconnect( (SenderObject*)s, signal, (ReceiverObject*)r, method ); + QCOMPARE( s->org_signal, s->nw_signal ); + QCOMPARE( s->org_signal.toLatin1(), QMetaObject::normalizedSignature(a_signal.toLatin1().constData()) ); + delete s; delete r; } @@ -3610,5 +3634,200 @@ void tst_QObject::sameName() QCOMPARE(c1.s, 4); } +void tst_QObject::connectByMetaMethods() +{ + SenderObject s; + ReceiverObject r; + const QMetaObject *smeta = s.metaObject(); + const QMetaObject *rmeta = r.metaObject(); + int sigIndx = smeta->indexOfSignal(QMetaObject::normalizedSignature("signal1()")); + int slotIndx = rmeta->indexOfSlot(QMetaObject::normalizedSignature("slot1()")); + QVERIFY( sigIndx != -1 ); + QVERIFY( slotIndx != -1 ); + QMetaMethod signal = smeta->method(sigIndx); + QMetaMethod slot = rmeta->method(slotIndx); + + QVERIFY(connect(&s,signal, &r,slot)); + + QVERIFY(!r.called(1)); + s.emitSignal1(); + QVERIFY(r.called(1)); +} + +void tst_QObject::connectByMetaMethodSlotInsteadOfSignal() +{ + SenderObject s; + ReceiverObject r; + const QMetaObject *smeta = s.metaObject(); + const QMetaObject *rmeta = r.metaObject(); + int badIndx = smeta->indexOfSlot(QMetaObject::normalizedSignature("aPublicSlot()")); + int slotIndx = rmeta->indexOfSlot(QMetaObject::normalizedSignature("slot1()")); + QVERIFY( badIndx != -1 ); + QVERIFY( slotIndx != -1 ); + QMetaMethod badMethod = smeta->method(badIndx); + QMetaMethod slot = rmeta->method(slotIndx); + + QTest::ignoreMessage(QtWarningMsg,"QObject::connect: Cannot connect SenderObject::aPublicSlot() to ReceiverObject::slot1()"); + QVERIFY(!connect(&s,badMethod, &r,slot)); +} + +class Constructable: public QObject +{ + Q_OBJECT + +public: + Q_INVOKABLE Constructable(){} + +}; + +void tst_QObject::connectConstructorByMetaMethod() +{ + Constructable sc; + Constructable rc; + SenderObject s; + ReceiverObject r; + + const QMetaObject cmeta = Constructable::staticMetaObject; + const QMetaObject *smeta = s.metaObject(); + const QMetaObject *rmeta = r.metaObject(); + int constructorIndx = cmeta.indexOfConstructor(QMetaObject::normalizedSignature("Constructable()")); + int sigIndx = smeta->indexOfSignal(QMetaObject::normalizedSignature("signal1()")); + int slotIndx = rmeta->indexOfSlot(QMetaObject::normalizedSignature("slot1()")); + QVERIFY( constructorIndx != -1 ); + QVERIFY( sigIndx != -1 ); + QVERIFY( slotIndx != -1 ); + + QMetaMethod constructor = cmeta.constructor(constructorIndx); + QMetaMethod signal = smeta->method(sigIndx); + QMetaMethod slot = rmeta->method(slotIndx); + + QTest::ignoreMessage(QtWarningMsg,"QObject::connect: Cannot connect Constructable::Constructable() to ReceiverObject::slot1()"); + QVERIFY(!connect(&sc,constructor, &r,slot)); + QTest::ignoreMessage(QtWarningMsg,"QObject::connect: Cannot connect SenderObject::signal1() to Constructable::Constructable()"); + QVERIFY(!connect(&s,signal, &rc,constructor)); + QTest::ignoreMessage(QtWarningMsg,"QObject::connect: Cannot connect Constructable::Constructable() to Constructable::Constructable()"); + QVERIFY(!connect(&sc,constructor, &rc,constructor)); +} + +void tst_QObject::disconnectByMetaMethod() +{ + SenderObject *s = new SenderObject; + ReceiverObject *r1 = new ReceiverObject; + ReceiverObject *r2 = new ReceiverObject; + + QMetaMethod signal1 = s->metaObject()->method( + s->metaObject()->indexOfMethod("signal1()")); + QMetaMethod signal2 = s->metaObject()->method( + s->metaObject()->indexOfMethod("signal2()")); + QMetaMethod signal3 = s->metaObject()->method( + s->metaObject()->indexOfMethod("signal3()")); + QMetaMethod signal4 = s->metaObject()->method( + s->metaObject()->indexOfMethod("signal4()")); + + QMetaMethod slot1 = r1->metaObject()->method( + r1->metaObject()->indexOfMethod("slot1()")); + QMetaMethod slot2 = r1->metaObject()->method( + r1->metaObject()->indexOfMethod("slot2()")); + QMetaMethod slot3 = r1->metaObject()->method( + r1->metaObject()->indexOfMethod("slot3()")); + QMetaMethod slot4 = r1->metaObject()->method( + r1->metaObject()->indexOfMethod("slot4()")); + + connect(s, signal1, r1, slot1); + + s->emitSignal1(); + + QVERIFY(r1->called(1)); + r1->reset(); + + // usual disconnect with all parameters given + bool ret = QObject::disconnect(s, signal1, r1, slot1); + + s->emitSignal1(); + + QVERIFY(!r1->called(1)); + r1->reset(); + + QVERIFY(ret); + ret = QObject::disconnect(s, signal1, r1, slot1); + QVERIFY(!ret); + + r1->reset(); + + connect( s, signal1, r1, slot1 ); + connect( s, signal1, r1, slot2 ); + connect( s, signal1, r1, slot3 ); + connect( s, signal2, r1, slot4 ); + + // disconnect s's signal1() from all slots of r1 + QObject::disconnect(s, signal1, r1, QMetaMethod()); + + s->emitSignal1(); + s->emitSignal2(); + + QVERIFY(!r1->called(1)); + QVERIFY(!r1->called(2)); + QVERIFY(!r1->called(3)); + QVERIFY(r1->called(4)); + r1->reset(); + // make sure all is disconnected again + QObject::disconnect(s, 0, r1, 0); + + connect(s, signal1, r1, slot1); + connect(s, signal1, r2, slot1); + connect(s, signal2, r1, slot2); + connect(s, signal2, r2, slot2); + connect(s, signal3, r1, slot3); + connect(s, signal3, r2, slot3); + + // disconnect signal1() from all receivers + QObject::disconnect(s, signal1, 0, QMetaMethod()); + s->emitSignal1(); + s->emitSignal2(); + s->emitSignal3(); + + QVERIFY(!r1->called(1)); + QVERIFY(!r2->called(1)); + QVERIFY(r1->called(2)); + QVERIFY(r2->called(2)); + QVERIFY(r1->called(2)); + QVERIFY(r2->called(2)); + + r1->reset(); + r2->reset(); + + // disconnect all signals of s from all receivers + QObject::disconnect( s, 0, 0, 0 ); + + connect( s, signal1, r1, slot1 ); + connect( s, signal1, r2, slot1 ); + + // disconnect all signals from slot1 of r1 + QObject::disconnect(s, QMetaMethod(), r1, slot1); + + s->emitSignal1(); + + QVERIFY(!r1->called(1)); + QVERIFY(r2->called(1)); + + delete r2; + delete r1; + delete s; +} + +void tst_QObject::disconnectNotSignalMetaMethod() +{ + SenderObject s; + ReceiverObject r; + + connect(&s, SIGNAL(signal1()), &r, SLOT(slot1())); + + QMetaMethod slot = s.metaObject()->method( + s.metaObject()->indexOfMethod("aPublicSlot()")); + + QTest::ignoreMessage(QtWarningMsg,"Object::disconnect: Attempt to unbind non-signal SenderObject::aPublicSlot()"); + QVERIFY(!QObject::disconnect(&s, slot, &r, QMetaMethod())); +} + QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" -- cgit v0.12 From 49831f30f58d08a360d5947ba300aa3a3575d1fa Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 18 Jun 2010 14:53:23 +0200 Subject: Make QObject::connect with QMetaMethod works with Jambi We need to call QInternal::activateCallbacks to the recently added overload of QObject::connect --- src/corelib/kernel/qobject.cpp | 58 ++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index dff282e..ad689ca 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2644,7 +2644,6 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) { - #ifndef QT_NO_DEBUG bool warnCompat = true; #endif @@ -2667,6 +2666,24 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, return false; } + // Reconstructing SIGNAL() macro result for signal.signature() string + QByteArray signalSignature; + signalSignature.reserve(qstrlen(signal.signature())+1); + signalSignature.append((char)(QSIGNAL_CODE + '0')); + signalSignature.append(signal.signature()); + + { + QByteArray methodSignature; + methodSignature.reserve(qstrlen(method.signature())+1); + methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE + : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0')); + methodSignature.append(method.signature()); + const void *cbdata[] = { sender, signalSignature.constData(), receiver, methodSignature.constData(), &type }; + if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata)) + return true; + } + + int signal_index; int method_index; { @@ -2707,11 +2724,6 @@ bool QObject::connect(const QObject *sender, const QMetaMethod &signal, #endif if (!QMetaObjectPrivate::connect(sender, signal_index, receiver, method_index, type, types)) return false; - // Reconstructing SIGNAL() macro result for signal.signature() string - QByteArray signalSignature; - signalSignature.reserve(qstrlen(signal.signature())+1); - signalSignature.append((char)(QSIGNAL_CODE + '0')); - signalSignature.append(signal.signature()); const_cast(sender)->connectNotify(signalSignature.constData()); return true; @@ -2947,6 +2959,28 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, } } + // Reconstructing SIGNAL() macro result for signal.signature() string + QByteArray signalSignature; + if (signal.mobj) { + signalSignature.reserve(qstrlen(signal.signature())+1); + signalSignature.append((char)(QSIGNAL_CODE + '0')); + signalSignature.append(signal.signature()); + } + + { + QByteArray methodSignature; + if (method.mobj) { + methodSignature.reserve(qstrlen(method.signature())+1); + methodSignature.append((char)(method.methodType() == QMetaMethod::Slot ? QSLOT_CODE + : method.methodType() == QMetaMethod::Signal ? QSIGNAL_CODE : 0 + '0')); + methodSignature.append(method.signature()); + } + const void *cbdata[] = { sender, signal.mobj ? signalSignature.constData() : 0, + receiver, method.mobj ? methodSignature.constData() : 0 }; + if (QInternal::activateCallbacks(QInternal::ConnectCallback, (void **) cbdata)) + return true; + } + int signal_index; int method_index; { @@ -2970,16 +3004,8 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, if (!QMetaObjectPrivate::disconnect(sender, signal_index, receiver, method_index)) return false; - if (!signal.mobj) { - const_cast(sender)->disconnectNotify(0); - } else { - // Reconstructing SIGNAL() macro result for signal.signature() string - QByteArray signalSignature; - signalSignature.reserve(qstrlen(signal.signature())+1); - signalSignature.append((char)(QSIGNAL_CODE + '0')); - signalSignature.append(signal.signature()); - const_cast(sender)->disconnectNotify(signalSignature.constData()); - } + + const_cast(sender)->disconnectNotify(method.mobj ? signalSignature.constData() : 0); return true; } -- 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 e5d437d6899904de2596b0ece4914274cff37561 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 17 Jun 2010 14:28:15 +0200 Subject: Refactor QTextureGlyphCache Separate getting the glyph coordinates from actually making and populating the cache. Calling populate() and fillInPendingGlyphs() immediately after should be equivalent to the old code, except it might have fewer reallocations of the texture since you will only create it one per set of glyphs. This mainly enables populating the GL glyph cache outside a GL context and then actually drawing into it later, when the context has actually been established. Reviewed-by: Kim --- src/gui/painting/qpaintengine_raster.cpp | 1 + src/gui/painting/qtextureglyphcache.cpp | 47 ++++++++++++---- src/gui/painting/qtextureglyphcache_p.h | 12 ++++- src/gui/text/qfont_p.h | 5 ++ .../gl2paintengineex/qpaintengineex_opengl2.cpp | 1 + .../gl2paintengineex/qtextureglyphcache_gl.cpp | 62 +++++++++++++++++----- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 13 ++++- 7 files changed, 114 insertions(+), 27 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 48974e8..06effd4 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3009,6 +3009,7 @@ void QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, } cache->populate(fontEngine, numGlyphs, glyphs, positions); + cache->fillInPendingGlyphs(); const QImage &image = cache->image(); int bpl = image.bytesPerLine(); diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 631a9cf..29cd82b 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -126,8 +126,9 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const return; rowHeight += margin * 2 + paddingDoubled; - if (isNull()) - createCache(QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH, qt_next_power_of_two(rowHeight)); + + if (m_w == 0) + m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; // now actually use the coords and paint the wanted glyps into cache. QHash::iterator iter = listItemCoordinates.begin(); @@ -142,26 +143,50 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const m_cy += m_currentRowHeight + paddingDoubled; m_currentRowHeight = 0; // New row } - if (m_cy + c.h > m_h) { - int new_height = m_h*2; - while (new_height < m_cy + c.h) - new_height *= 2; - // if no room in the current texture - realloc a larger texture - resizeTextureData(m_w, new_height); - m_h = new_height; - } c.x = m_cx; c.y = m_cy; - fillTexture(c, iter.key()); coords.insert(iter.key(), c); + m_pendingGlyphs.insert(iter.key(), c); m_cx += c.w + paddingDoubled; ++iter; } +} + +void QTextureGlyphCache::fillInPendingGlyphs() +{ + if (m_pendingGlyphs.isEmpty()) + return; + + int requiredHeight = 0; + { + QHash::iterator iter = m_pendingGlyphs.begin(); + while (iter != m_pendingGlyphs.end()) { + Coord c = iter.value(); + requiredHeight = qMax(requiredHeight, c.y + c.h); + ++iter; + } + } + + if (requiredHeight > m_h) { + if (isNull()) + createCache(m_w, qt_next_power_of_two(requiredHeight)); + else + resizeCache(m_w, qt_next_power_of_two(requiredHeight)); + } + { + QHash::iterator iter = m_pendingGlyphs.begin(); + while (iter != m_pendingGlyphs.end()) { + fillTexture(iter.value(), iter.key()); + + ++iter; + } + } + m_pendingGlyphs.clear(); } QImage QTextureGlyphCache::textureMapForGlyph(glyph_t g) const diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h index a818978..0770ed4 100644 --- a/src/gui/painting/qtextureglyphcache_p.h +++ b/src/gui/painting/qtextureglyphcache_p.h @@ -94,6 +94,7 @@ public: void populate(QFontEngine *fontEngine, int numGlyphs, const glyph_t *glyphs, const QFixedPoint *positions); + void fillInPendingGlyphs(); virtual void createTextureData(int width, int height) = 0; virtual void resizeTextureData(int width, int height) = 0; @@ -108,7 +109,14 @@ public: createTextureData(width, height); } - inline bool isNull() const { return m_w <= 0 || m_h <= 0; } + inline void resizeCache(int width, int height) + { + resizeTextureData(width, height); + m_w = width; + m_h = height; + } + + inline bool isNull() const { return m_h == 0; } QHash coords; @@ -117,6 +125,8 @@ public: protected: QFontEngine *m_current_fontengine; + QHash m_pendingGlyphs; + int m_w; // image width int m_h; // image height int m_cx; // current x diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h index 470c109..646a8b8 100644 --- a/src/gui/text/qfont_p.h +++ b/src/gui/text/qfont_p.h @@ -192,6 +192,11 @@ public: QFont smallCapsFont() const { return QFont(smallCapsFontPrivate()); } QFontPrivate *smallCapsFontPrivate() const; + static QFontPrivate *get(const QFont &font) + { + return font.d.data(); + } + void resolve(uint mask, const QFontPrivate *other); private: QFontPrivate &operator=(const QFontPrivate &) { return *this; } diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index ee49a3d..634b315 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1463,6 +1463,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp cache->setPaintEnginePrivate(this); cache->populate(staticTextItem->fontEngine, staticTextItem->numGlyphs, staticTextItem->glyphs, staticTextItem->glyphPositions); + cache->fillInPendingGlyphs(); if (cache->width() == 0 || cache->height() == 0) return; diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 5371c5e..e2ec8a1 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -52,39 +52,65 @@ QT_BEGIN_NAMESPACE extern Q_GUI_EXPORT bool qt_cleartype_enabled; #endif -QGLTextureGlyphCache::QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) +QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) : QImageTextureGlyphCache(type, matrix) - , ctx(context) + , ctx(0) , m_width(0) , m_height(0) { - // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where - // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The - // workaround is to use a system-memory copy of the glyph cache for this device. - // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and - // be slower, so that is not desireable. - if (!ctx->d_ptr->workaround_brokenFBOReadBack) - glGenFramebuffers(1, &m_fbo); - - connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), - SLOT(contextDestroyed(const QGLContext*))); + if (context != 0) + setContext(context); } QGLTextureGlyphCache::~QGLTextureGlyphCache() { + cleanUpContext(); +} + +void QGLTextureGlyphCache::cleanUpContext() +{ if (ctx) { QGLShareContextScope scope(ctx); if (!ctx->d_ptr->workaround_brokenFBOReadBack) glDeleteFramebuffers(1, &m_fbo); - if (m_width || m_height) + if (m_width || m_height) { glDeleteTextures(1, &m_texture); + m_width = 0; + m_height = 0; + m_h = 0; + } + + ctx = 0; } } +void QGLTextureGlyphCache::setContext(const QGLContext *context) +{ + cleanUpContext(); + + ctx = context; + + // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where + // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The + // workaround is to use a system-memory copy of the glyph cache for this device. + // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and + // be slower, so that is not desireable. + if (!ctx->d_ptr->workaround_brokenFBOReadBack) + glGenFramebuffers(1, &m_fbo); + + connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), + SLOT(contextDestroyed(const QGLContext*))); +} + void QGLTextureGlyphCache::createTextureData(int width, int height) { + if (ctx == 0) { + qWarning("QGLTextureGlyphCache::createTextureData: Called with no context"); + return; + } + // create in QImageTextureGlyphCache baseclass is meant to be called // only to create the initial image and does not preserve the content, // so we don't call when this function is called from resize. @@ -118,6 +144,11 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) void QGLTextureGlyphCache::resizeTextureData(int width, int height) { + if (ctx == 0) { + qWarning("QGLTextureGlyphCache::resizeTextureData: Called with no context"); + return; + } + int oldWidth = m_width; int oldHeight = m_height; @@ -213,6 +244,11 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) { + if (ctx == 0) { + qWarning("QGLTextureGlyphCache::fillTexture: Called with no context"); + return; + } + if (ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::fillTexture(c, glyph); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 84e9021..d291ac3 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -66,7 +66,7 @@ class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QObject, public QImageTextur { Q_OBJECT public: - QGLTextureGlyphCache(QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); + QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); ~QGLTextureGlyphCache(); virtual void createTextureData(int width, int height); @@ -82,6 +82,13 @@ public: inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } + void setContext(const QGLContext *context); + inline const QGLContext *context() const + { + return ctx; + } + + public Q_SLOTS: void contextDestroyed(const QGLContext *context) { @@ -105,7 +112,9 @@ public Q_SLOTS: } private: - QGLContext *ctx; + void cleanUpContext(); + + const QGLContext *ctx; QGL2PaintEngineExPrivate *pex; -- cgit v0.12 From 7113c6d4be87ead4f2be9afe64c6e81e3f6720a3 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sat, 19 Jun 2010 01:54:45 +0200 Subject: QElapsedTimer/Win: use QueryPerformanceCounter if available Added a clock type to reflect this. Merge-request: 697 Reviewed-by: joerg Reviewed-by: thiago --- src/corelib/tools/qelapsedtimer.cpp | 23 ++++++++++---- src/corelib/tools/qelapsedtimer.h | 3 +- src/corelib/tools/qelapsedtimer_win.cpp | 53 +++++++++++++++++++++++++++++---- 3 files changed, 68 insertions(+), 11 deletions(-) diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/tools/qelapsedtimer.cpp index cb5e701..4adddf9 100644 --- a/src/corelib/tools/qelapsedtimer.cpp +++ b/src/corelib/tools/qelapsedtimer.cpp @@ -136,10 +136,11 @@ QT_BEGIN_NAMESPACE implementations, to guarantee that the same reference clock is being used. - \value SystemTime The human-readable system time. This clock is not monotonic. - \value MonotonicClock The system's monotonic clock, usually found in Unix systems. This clock is monotonic and does not overflow. - \value TickCounter The system's tick counter, used on Windows and Symbian systems. This clock may overflow. - \value MachAbsoluteTime The Mach kernel's absolute time (Mac OS X). This clock is monotonic and does not overflow. + \value SystemTime The human-readable system time. This clock is not monotonic. + \value MonotonicClock The system's monotonic clock, usually found in Unix systems. This clock is monotonic and does not overflow. + \value TickCounter The system's tick counter, used on Windows and Symbian systems. This clock may overflow. + \value MachAbsoluteTime The Mach kernel's absolute time (Mac OS X). This clock is monotonic and does not overflow. + \value PerformanceCounter The high-resolution performance counter provided by Windows. This clock is monotonic and does not overflow. \section2 SystemTime @@ -163,7 +164,9 @@ QT_BEGIN_NAMESPACE The tick counter clock type is based on the system's or the processor's tick counter, multiplied by the duration of a tick. This clock type is - used on Windows and Symbian platforms. + used on Windows and Symbian platforms. If the high-precision performance + counter is available on Windows, the \tt{PerformanceCounter} clock type + is used instead. The TickCounter clock type is the only clock type that may overflow. Windows Vista and Windows Server 2008 support the extended 64-bit tick @@ -191,6 +194,16 @@ QT_BEGIN_NAMESPACE This clock is monotonic and does not overflow. + \section2 PerformanceCounter + + This clock uses the Windows functions \tt{QueryPerformanceCounter} and + \tt{QueryPerformanceFrequency} to access the system's high-precision + performance counter. Since this counter may not be available on all + systems, QElapsedTimer will fall back to the \tt{TickCounter} clock + automatically, if this clock cannot be used. + + This clock is monotonic and does not overflow. + \sa clockType(), isMonotonic() */ diff --git a/src/corelib/tools/qelapsedtimer.h b/src/corelib/tools/qelapsedtimer.h index 0d6f0be..b996f6a 100644 --- a/src/corelib/tools/qelapsedtimer.h +++ b/src/corelib/tools/qelapsedtimer.h @@ -57,7 +57,8 @@ public: SystemTime, MonotonicClock, TickCounter, - MachAbsoluteTime + MachAbsoluteTime, + PerformanceCounter }; static ClockType clockType(); static bool isMonotonic(); diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index 135196a..c7c160d 100644 --- a/src/corelib/tools/qelapsedtimer_win.cpp +++ b/src/corelib/tools/qelapsedtimer_win.cpp @@ -42,6 +42,9 @@ #include "qelapsedtimer.h" #include +// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable +static quint64 counterFrequency = 0; + typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void); static PtrGetTickCount64 ptrGetTickCount64 = 0; @@ -65,12 +68,44 @@ static void resolveLibs() ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64"); #endif + // Retrieve the number of high-resolution performance counter ticks per second + LARGE_INTEGER frequency; + if (!QueryPerformanceFrequency(&frequency)) { + counterFrequency = 0; + } else { + counterFrequency = frequency.QuadPart; + } + done = true; } +static qint64 ticksToMilliseconds(qint64 ticks) +{ + if (counterFrequency > 0) { + // QueryPerformanceCounter uses an arbitrary frequency + return ticks * 1000 / counterFrequency; + } else { + // GetTickCount(64) return milliseconds + return ticks; + } +} + static quint64 getTickCount() { resolveLibs(); + + // This avoids a division by zero and disables the high performance counter if it's not available + if (counterFrequency > 0) { + LARGE_INTEGER counter; + + if (QueryPerformanceCounter(&counter)) { + return counter.QuadPart; + } else { + qWarning("QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded."); + return 0; + } + } + if (ptrGetTickCount64) return ptrGetTickCount64(); @@ -85,7 +120,13 @@ static quint64 getTickCount() QElapsedTimer::ClockType QElapsedTimer::clockType() { - return TickCounter; + resolveLibs(); + + if (counterFrequency > 0) { + return PerformanceCounter; + } else { + return TickCounter; + } } bool QElapsedTimer::isMonotonic() @@ -104,22 +145,24 @@ qint64 QElapsedTimer::restart() qint64 oldt1 = t1; t1 = getTickCount(); t2 = 0; - return t1 - oldt1; + return ticksToMilliseconds(t1 - oldt1); } qint64 QElapsedTimer::elapsed() const { - return getTickCount() - t1; + qint64 elapsed = getTickCount() - t1; + return ticksToMilliseconds(elapsed); } qint64 QElapsedTimer::msecsSinceReference() const { - return t1; + return ticksToMilliseconds(t1); } qint64 QElapsedTimer::msecsTo(const QElapsedTimer &other) const { - return other.t1 - t1; + qint64 difference = other.t1 - t1; + return ticksToMilliseconds(difference); } qint64 QElapsedTimer::secsTo(const QElapsedTimer &other) const -- cgit v0.12 From 222d5c3e905a324f5508a0eb16114c5b3274af53 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 21 Jun 2010 17:02:16 +0200 Subject: code style changes applied to MR 697 --- src/corelib/tools/qelapsedtimer_win.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index c7c160d..c77acaa 100644 --- a/src/corelib/tools/qelapsedtimer_win.cpp +++ b/src/corelib/tools/qelapsedtimer_win.cpp @@ -79,7 +79,7 @@ static void resolveLibs() done = true; } -static qint64 ticksToMilliseconds(qint64 ticks) +static inline qint64 ticksToMilliseconds(qint64 ticks) { if (counterFrequency > 0) { // QueryPerformanceCounter uses an arbitrary frequency @@ -122,11 +122,10 @@ QElapsedTimer::ClockType QElapsedTimer::clockType() { resolveLibs(); - if (counterFrequency > 0) { + if (counterFrequency > 0) return PerformanceCounter; - } else { + else return TickCounter; - } } bool QElapsedTimer::isMonotonic() -- 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 13cacbd801e3077ad87d21c9b2607a4d7854308d Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 23 Jun 2010 07:18:19 +0200 Subject: Fix painting of overlines in labels. If the size of the widget is an odd number, the layout rect will be positioned at a 0.5 offset. The clipping set further below will snap this to 1 and thus clip away the anything drawn on the first row of pixels. Fix this by aligning the rectangle we get by layout rect. Reviewed-by: Eskil Task: http://bugreports.qt.nokia.com/browse/QTBUG-9684 --- src/gui/widgets/qlabel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index bdbd0b0..f5393a9 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -1071,7 +1071,7 @@ void QLabel::paintEvent(QPaintEvent *) else #endif if (d->isTextLabel) { - QRectF lr = d->layoutRect(); + QRectF lr = d->layoutRect().toAlignedRect(); QStyleOption opt; opt.initFrom(this); #ifndef QT_NO_STYLE_STYLESHEET -- 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 fea75b0a31fe62289f9732ee2fc07ee69c131eb2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 23 Jun 2010 16:06:57 +0200 Subject: Enablers for external use of QGLTextureGlyphCache In order to enable use of QGLTextureGlyphCache outside of Qt, it can't depend on having an initialized paint engine. We use the simple image fallback for copying the cache texture when it's updated and we need to export the functions for resolving extensions, so that the gl context can be initialized properly without calling begin on a paint engine. Reviewed-by: Kim --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 11 ++++++----- src/opengl/qglextensions_p.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index e2ec8a1..faf4563 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -55,6 +55,7 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) : QImageTextureGlyphCache(type, matrix) , ctx(0) + , pex(0) , m_width(0) , m_height(0) { @@ -72,7 +73,7 @@ void QGLTextureGlyphCache::cleanUpContext() if (ctx) { QGLShareContextScope scope(ctx); - if (!ctx->d_ptr->workaround_brokenFBOReadBack) + if (!ctx->d_ptr->workaround_brokenFBOReadBack && pex != 0) glDeleteFramebuffers(1, &m_fbo); if (m_width || m_height) { @@ -97,7 +98,7 @@ void QGLTextureGlyphCache::setContext(const QGLContext *context) // workaround is to use a system-memory copy of the glyph cache for this device. // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and // be slower, so that is not desireable. - if (!ctx->d_ptr->workaround_brokenFBOReadBack) + if (!ctx->d_ptr->workaround_brokenFBOReadBack && pex != 0) glGenFramebuffers(1, &m_fbo); connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), @@ -114,7 +115,7 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) // create in QImageTextureGlyphCache baseclass is meant to be called // only to create the initial image and does not preserve the content, // so we don't call when this function is called from resize. - if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull()) + if ((pex == 0 || ctx->d_ptr->workaround_brokenFBOReadBack) && image().isNull()) QImageTextureGlyphCache::createTextureData(width, height); // Make the lower glyph texture size 16 x 16. @@ -161,7 +162,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) GLuint oldTexture = m_texture; createTextureData(width, height); - if (ctx->d_ptr->workaround_brokenFBOReadBack) { + if (pex == 0 || ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::resizeTextureData(width, height); Q_ASSERT(image().depth() == 8); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); @@ -249,7 +250,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) return; } - if (ctx->d_ptr->workaround_brokenFBOReadBack) { + if (pex == 0 || ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::fillTexture(c, glyph); glBindTexture(GL_TEXTURE_2D, m_texture); diff --git a/src/opengl/qglextensions_p.h b/src/opengl/qglextensions_p.h index 7597b33..8f80e5a 100644 --- a/src/opengl/qglextensions_p.h +++ b/src/opengl/qglextensions_p.h @@ -872,10 +872,10 @@ struct QGLExtensionFuncs #endif extern bool qt_resolve_framebufferobject_extensions(QGLContext *ctx); -bool qt_resolve_buffer_extensions(QGLContext *ctx); +bool Q_OPENGL_EXPORT qt_resolve_buffer_extensions(QGLContext *ctx); bool qt_resolve_version_1_3_functions(QGLContext *ctx); -bool qt_resolve_version_2_0_functions(QGLContext *ctx); +bool Q_OPENGL_EXPORT qt_resolve_version_2_0_functions(QGLContext *ctx); bool qt_resolve_stencil_face_extension(QGLContext *ctx); bool qt_resolve_frag_program_extensions(QGLContext *ctx); -- 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 b8b1536329534662bddbb1d289529eb2b55f816d Mon Sep 17 00:00:00 2001 From: Jan Arne Petersen Date: Fri, 25 Jun 2010 01:46:55 +0300 Subject: Fix QDir::tempPath() documentation for Unix Mention TMPDIR environment variable for Linux/Unix case and clarify documentation. Fixes: QTBUG-11496 --- src/corelib/io/qdir.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index e54d95e..ed51c5d 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1910,7 +1910,8 @@ QString QDir::homePath() /*! Returns the absolute path of the system's temporary directory. - On Unix/Linux systems this is usually \c{/tmp}; on Windows this is + On Unix/Linux systems this is the path in the \c TMPDIR environment + variable or \c{/tmp} if \c TMPDIR is not defined. On Windows this is usually the path in the \c TEMP or \c TMP environment variable. Whether a directory separator is added to the end or not, depends on the operating system. -- cgit v0.12 From 9acf20771b624132833b2ca1e8bc421f69774f1e Mon Sep 17 00:00:00 2001 From: Zachary Blair Date: Sun, 27 Jun 2010 22:38:16 +0200 Subject: Fix suspicious code found by static code analysis: * Missing break in switch * delete instead of delete[] * Null-pointer check after dereference Merge-request: 716 Reviewed-by: Andreas Kling --- src/gui/styles/qcleanlooksstyle.cpp | 1 + src/gui/styles/qwindowscestyle.cpp | 1 + src/gui/styles/qwindowsxpstyle.cpp | 2 +- src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp | 6 +++--- src/qt3support/text/q3richtext.cpp | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 883f511..cb48def 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -3763,6 +3763,7 @@ int QCleanlooksStyle::pixelMetric(PixelMetric metric, const QStyleOption *option break; case PM_MenuBarItemSpacing: ret = 6; + break; case PM_MenuBarHMargin: ret = 0; break; diff --git a/src/gui/styles/qwindowscestyle.cpp b/src/gui/styles/qwindowscestyle.cpp index b027005..bd7246a 100644 --- a/src/gui/styles/qwindowscestyle.cpp +++ b/src/gui/styles/qwindowscestyle.cpp @@ -2294,6 +2294,7 @@ int QWindowsCEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QW break; case SH_EtchDisabledText: ret = false; + break; case SH_RequestSoftwareInputPanel: ret = RSIP_OnMouseClick; break; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index efb1224..8858475 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -4052,7 +4052,7 @@ void QWindowsXPStylePrivate::dumpNativeDIB(int w, int h) bufferPos += sprintf(bufferPos, "\n};\n\n"); printf(bufferDump); - delete bufferDump; + delete[] bufferDump; ++pCount; } } diff --git a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp index ecd03e5..19f3b3c 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_mac_p.cpp @@ -127,7 +127,7 @@ QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const } } - delete streams; + delete[] streams; } } @@ -201,7 +201,7 @@ QList QAudioDeviceInfoInternal::frequencyList() rc << vr[i].mMaximum; } - delete vr; + delete[] vr; } } @@ -345,7 +345,7 @@ QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) } } - delete audioDevices; + delete[] audioDevices; } } diff --git a/src/qt3support/text/q3richtext.cpp b/src/qt3support/text/q3richtext.cpp index 8614076..625dd95 100644 --- a/src/qt3support/text/q3richtext.cpp +++ b/src/qt3support/text/q3richtext.cpp @@ -8079,9 +8079,9 @@ bool Q3TextTable::down(Q3TextCursor *c, Q3TextDocument *&doc, Q3TextParagraph *& break; } } - doc = cell->richText(); if (!cell) return false; + doc = cell->richText(); parag = doc->firstParagraph(); idx = 0; ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); @@ -8117,9 +8117,9 @@ bool Q3TextTable::up(Q3TextCursor *c, Q3TextDocument *&doc, Q3TextParagraph *&pa break; } } - doc = cell->richText(); if (!cell) return false; + doc = cell->richText(); parag = doc->lastParagraph(); idx = parag->length() - 1; ox += cell->geometry().x() + cell->horizontalAlignmentOffset() + outerborder + parent->x(); -- cgit v0.12 From abb27bbf94900aa335f53e9fb9a1a1ea20a9852c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 28 Jun 2010 14:05:06 +0200 Subject: Makes the splascreen transparent depending on the pixmap Task-Number: QTBUG-3887 --- src/gui/widgets/qsplashscreen.cpp | 54 +++++++++++---------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/src/gui/widgets/qsplashscreen.cpp b/src/gui/widgets/qsplashscreen.cpp index 8be0cf8..c99952e 100644 --- a/src/gui/widgets/qsplashscreen.cpp +++ b/src/gui/widgets/qsplashscreen.cpp @@ -64,7 +64,6 @@ public: int currAlign; inline QSplashScreenPrivate(); - void drawContents(); }; /*! @@ -121,10 +120,9 @@ public: perhaps Qt::WindowStaysOnTopHint. */ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) - : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | f) + : QWidget(*(new QSplashScreenPrivate()), 0, Qt::SplashScreen | Qt::FramelessWindowHint | f) { - d_func()->pixmap = pixmap; - setPixmap(d_func()->pixmap); // Does an implicit repaint + setPixmap(pixmap); // Does an implicit repaint } /*! @@ -165,7 +163,6 @@ void QSplashScreen::mousePressEvent(QMouseEvent *) */ void QSplashScreen::repaint() { - d_func()->drawContents(); QWidget::repaint(); QApplication::flush(); } @@ -234,23 +231,13 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap) { Q_D(QSplashScreen); - if (pixmap.hasAlpha()) { - QPixmap opaque(pixmap.size()); - QPainter p(&opaque); - p.fillRect(0, 0, pixmap.width(), pixmap.height(), palette().background()); - p.drawPixmap(0, 0, pixmap); - p.end(); - d->pixmap = opaque; - } else { - d->pixmap = pixmap; - } + d->pixmap = pixmap; + setAttribute(Qt::WA_TranslucentBackground, pixmap.hasAlpha()); - QRect r(0, 0, d->pixmap.size().width(), d->pixmap.size().height()); - resize(d->pixmap.size()); + QRect r(QPoint(), d->pixmap.size()); + resize(r.size()); move(QApplication::desktop()->screenGeometry().center() - r.center()); - if (!isVisible()) - d->drawContents(); - else + if (isVisible()) repaint(); } @@ -264,23 +251,6 @@ const QPixmap QSplashScreen::pixmap() const } /*! - \internal -*/ -void QSplashScreenPrivate::drawContents() -{ - Q_Q(QSplashScreen); - QPixmap textPix = pixmap; - if (!textPix.isNull()) { - QPainter painter(&textPix); - painter.initFrom(q); - q->drawContents(&painter); - QPalette p = q->palette(); - p.setBrush(q->backgroundRole(), QBrush(textPix)); - q->setPalette(p); - } -} - -/*! \internal */ inline QSplashScreenPrivate::QSplashScreenPrivate() : currAlign(Qt::AlignLeft) @@ -297,8 +267,7 @@ void QSplashScreen::drawContents(QPainter *painter) { Q_D(QSplashScreen); painter->setPen(d->currColor); - QRect r = rect(); - r.setRect(r.x() + 5, r.y() + 5, r.width() - 10, r.height() - 10); + QRect r = rect().adjusted(5, 5, -10, -10); if (Qt::mightBeRichText(d->currStatus)) { QTextDocument doc; #ifdef QT_NO_TEXTHTMLPARSER @@ -339,6 +308,13 @@ void QSplashScreen::drawContents(QPainter *painter) /*! \reimp */ bool QSplashScreen::event(QEvent *e) { + if (e->type() == QEvent::Paint) { + Q_D(QSplashScreen); + QPainter painter(this); + if (!d->pixmap.isNull()) + painter.drawPixmap(QPoint(), d->pixmap); + drawContents(&painter); + } return QWidget::event(e); } -- cgit v0.12 From b1b87a73012342dc1619a8e907ea9954d59ca564 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 28 Jun 2010 14:33:35 +0200 Subject: set currentIndex as USER property for QComboBox Task-Number: QTBUG-5260 --- src/gui/widgets/qcombobox.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qcombobox.h b/src/gui/widgets/qcombobox.h index fb9af9f..81a4389 100644 --- a/src/gui/widgets/qcombobox.h +++ b/src/gui/widgets/qcombobox.h @@ -68,7 +68,7 @@ class Q_GUI_EXPORT QComboBox : public QWidget Q_PROPERTY(bool editable READ isEditable WRITE setEditable) Q_PROPERTY(int count READ count) Q_PROPERTY(QString currentText READ currentText) - Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) + Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged USER true) Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems) Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount) Q_PROPERTY(InsertPolicy insertPolicy READ insertPolicy WRITE setInsertPolicy) -- cgit v0.12 From ace1efa0fb7552de0fbe845543ee9560d8b89a65 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 28 Jun 2010 15:39:54 +0200 Subject: add some QTextLayout subtests Merge-request: 685 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/qtextlayout/tst_qtextlayout.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index 1a5f493..8758092 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -85,6 +85,7 @@ private slots: void cursorToXForSetColumns(); void defaultWordSeparators_data(); void defaultWordSeparators(); + void cursorMovementFromInvalidPositions(); void cursorMovementInsideSpaces(); void charWordStopOnLineSeparator(); void xToCursorAtEndOfLine(); @@ -542,6 +543,10 @@ void tst_QTextLayout::defaultWordSeparators_data() QTest::newRow("lineseparator") << QString::fromLatin1("abcd") + QString(QChar::LineSeparator) + QString::fromLatin1("efgh") << 0 << 5; + + QTest::newRow("empty") + << QString() + << 0 << 0; } void tst_QTextLayout::defaultWordSeparators() @@ -555,12 +560,31 @@ void tst_QTextLayout::defaultWordSeparators() QCOMPARE(layout.previousCursorPosition(endPos, QTextLayout::SkipWords), startPos); } +void tst_QTextLayout::cursorMovementFromInvalidPositions() +{ + int badpos = 10000; + + QTextLayout layout("ABC", testFont); + + QCOMPARE(layout.previousCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos); + QCOMPARE(layout.nextCursorPosition(-badpos, QTextLayout::SkipCharacters), -badpos); + + QCOMPARE(layout.previousCursorPosition(badpos, QTextLayout::SkipCharacters), badpos); + QCOMPARE(layout.nextCursorPosition(badpos, QTextLayout::SkipCharacters), badpos); +} + void tst_QTextLayout::cursorMovementInsideSpaces() { QTextLayout layout("ABC DEF", testFont); QCOMPARE(layout.previousCursorPosition(6, QTextLayout::SkipWords), 0); QCOMPARE(layout.nextCursorPosition(6, QTextLayout::SkipWords), 15); + + + QTextLayout layout2("ABC\t\t\t\t\t\t\t\t\t\t\t\tDEF", testFont); + + QCOMPARE(layout2.previousCursorPosition(6, QTextLayout::SkipWords), 0); + QCOMPARE(layout2.nextCursorPosition(6, QTextLayout::SkipWords), 15); } void tst_QTextLayout::charWordStopOnLineSeparator() -- cgit v0.12 From a80b43baa153e55fe40562604d45f25aad81ab2e Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 28 Jun 2010 15:39:57 +0200 Subject: fix possible crash in nextCursorPosition()/previousCursorPosition() due to boundary overflow when called for invalid cursor position Merge-request: 685 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextlayout.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 8472ec6..eed10d2 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -645,21 +645,19 @@ void QTextLayout::clearLayout() /*! Returns the next valid cursor position after \a oldPos that respects the given cursor \a mode. + Returns value of \a oldPos, if \a oldPos is not a valid cursor position. \sa isValidCursorPosition() previousCursorPosition() */ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const { -// qDebug("looking for next cursor pos for %d", oldPos); const HB_CharAttributes *attributes = d->attributes(); - if (!attributes) - return 0; - int len = d->block.isValid() ? - (d->block.length() - 1) - : d->layoutData->string.length(); - - if (oldPos >= len) + int len = d->block.isValid() ? d->block.length() - 1 + : d->layoutData->string.length(); + Q_ASSERT(len <= d->layoutData->string.length()); + if (!attributes || oldPos < 0 || oldPos >= len) return oldPos; + if (mode == SkipCharacters) { oldPos++; while (oldPos < len && !attributes[oldPos].charStop) @@ -676,22 +674,23 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const while (oldPos < len && d->atSpace(oldPos)) oldPos++; } -// qDebug(" -> %d", oldPos); + return oldPos; } /*! Returns the first valid cursor position before \a oldPos that respects the given cursor \a mode. + Returns value of \a oldPos, if \a oldPos is not a valid cursor position. \sa isValidCursorPosition() nextCursorPosition() */ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const { -// qDebug("looking for previous cursor pos for %d", oldPos); const HB_CharAttributes *attributes = d->attributes(); - if (!attributes || oldPos <= 0) - return 0; + if (!attributes || oldPos <= 0 || oldPos > d->layoutData->string.length()) + return oldPos; + if (mode == SkipCharacters) { oldPos--; while (oldPos && !attributes[oldPos].charStop) @@ -709,7 +708,7 @@ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const oldPos--; } } -// qDebug(" -> %d", oldPos); + return oldPos; } -- cgit v0.12 From e82cb13fdc4b0c779e1d8232b0254f92208d2372 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 28 Jun 2010 15:39:59 +0200 Subject: nano optimizations Merge-request: 685 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 12 ++++++------ src/gui/text/qtextlayout.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index b25795e..054067c 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2293,27 +2293,27 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int if (flags & Qt::TextShowMnemonic) { itemize(); + HB_CharAttributes *attributes = const_cast(this->attributes()); for (int i = 0; i < layoutData->items.size(); ++i) { QScriptItem &si = layoutData->items[i]; if (!si.num_glyphs) shape(i); - HB_CharAttributes *attributes = const_cast(this->attributes()); unsigned short *logClusters = this->logClusters(&si); QGlyphLayout glyphs = shapedGlyphs(&si); const int end = si.position + length(&si); - for (int i = si.position; i < end - 1; ++i) + for (int i = si.position; i < end - 1; ++i) { if (layoutData->string.at(i) == QLatin1Char('&')) { const int gp = logClusters[i - si.position]; glyphs.attributes[gp].dontPrint = true; attributes[i + 1].charStop = false; attributes[i + 1].whiteSpace = false; attributes[i + 1].lineBreakType = HB_NoBreak; - if (i < end - 1 - && layoutData->string.at(i + 1) == QLatin1Char('&')) + if (layoutData->string.at(i + 1) == QLatin1Char('&')) ++i; } + } } } @@ -2373,7 +2373,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int if (mode == Qt::ElideRight) { QFixed currentWidth; - int pos = 0; + int pos; int nextBreak = 0; do { @@ -2393,7 +2393,7 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int return layoutData->string.left(pos) + ellipsisText; } else if (mode == Qt::ElideLeft) { QFixed currentWidth; - int pos = layoutData->string.length(); + int pos; int nextBreak = layoutData->string.length(); do { diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index eed10d2..d8db625 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1769,7 +1769,8 @@ static inline void addNextCluster(int &pos, int end, QScriptLine &line, int &gly ++line.length; } while (pos < end && logClusters[pos] == glyphPosition); do { // calculate the textWidth for the rest of the current cluster. - line.textWidth += glyphs.advances_x[glyphPosition] * !glyphs.attributes[glyphPosition].dontPrint; + if (!glyphs.attributes[glyphPosition].dontPrint) + line.textWidth += glyphs.advances_x[glyphPosition]; ++glyphPosition; } while (glyphPosition < current.num_glyphs && !glyphs.attributes[glyphPosition].clusterStart); @@ -1999,9 +2000,10 @@ found: eng->maxWidth += lbh.spaceData.textWidth; if (eng->option.flags() & QTextOption::IncludeTrailingSpaces) line.textWidth += lbh.spaceData.textWidth; - line.length += lbh.spaceData.length; - if (lbh.spaceData.length) + if (lbh.spaceData.length) { + line.length += lbh.spaceData.length; line.hasTrailingSpaces = true; + } line.justified = false; line.gridfitted = false; -- cgit v0.12 From 0a51846cfbaf8559526e4fbaebbde84c3658da47 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 28 Jun 2010 15:40:02 +0200 Subject: minor documentation improvements Merge-request: 685 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextlayout.cpp | 179 +++++++++++++++++++++++-------------------- 1 file changed, 94 insertions(+), 85 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index d8db625..c1a33e7 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -165,7 +165,7 @@ static QFixed alignLine(QTextEngine *eng, const QScriptLine &line) /*! Returns the inline object's rectangle. - \sa ascent() descent() width() + \sa ascent(), descent(), width() */ QRectF QTextInlineObject::rect() const { @@ -176,7 +176,7 @@ QRectF QTextInlineObject::rect() const /*! Returns the inline object's width. - \sa ascent() descent() rect() + \sa ascent(), descent(), rect() */ qreal QTextInlineObject::width() const { @@ -186,7 +186,7 @@ qreal QTextInlineObject::width() const /*! Returns the inline object's ascent. - \sa descent() width() rect() + \sa descent(), width(), rect() */ qreal QTextInlineObject::ascent() const { @@ -196,7 +196,7 @@ qreal QTextInlineObject::ascent() const /*! Returns the inline object's descent. - \sa ascent() width() rect() + \sa ascent(), width(), rect() */ qreal QTextInlineObject::descent() const { @@ -207,18 +207,17 @@ qreal QTextInlineObject::descent() const Returns the inline object's total height. This is equal to ascent() + descent() + 1. - \sa ascent() descent() width() rect() + \sa ascent(), descent(), width(), rect() */ qreal QTextInlineObject::height() const { return eng->layoutData->items[itm].height().toReal(); } - /*! Sets the inline object's width to \a w. - \sa width() ascent() descent() rect() + \sa width(), ascent(), descent(), rect() */ void QTextInlineObject::setWidth(qreal w) { @@ -228,7 +227,7 @@ void QTextInlineObject::setWidth(qreal w) /*! Sets the inline object's ascent to \a a. - \sa ascent() setDescent() width() rect() + \sa ascent(), setDescent(), width(), rect() */ void QTextInlineObject::setAscent(qreal a) { @@ -238,7 +237,7 @@ void QTextInlineObject::setAscent(qreal a) /*! Sets the inline object's decent to \a d. - \sa descent() setAscent() width() rect() + \sa descent(), setAscent(), width(), rect() */ void QTextInlineObject::setDescent(qreal d) { @@ -246,7 +245,7 @@ void QTextInlineObject::setDescent(qreal d) } /*! - The position of the inline object within the text layout. + The position of the inline object within the text layout. */ int QTextInlineObject::textPosition() const { @@ -254,8 +253,8 @@ int QTextInlineObject::textPosition() const } /*! - Returns an integer describing the format of the inline object - within the text layout. + Returns an integer describing the format of the inline object + within the text layout. */ int QTextInlineObject::formatIndex() const { @@ -263,7 +262,7 @@ int QTextInlineObject::formatIndex() const } /*! - Returns format of the inline object within the text layout. + Returns format of the inline object within the text layout. */ QTextFormat QTextInlineObject::format() const { @@ -273,7 +272,7 @@ QTextFormat QTextInlineObject::format() const } /*! - Returns if the object should be laid out right-to-left or left-to-right. + Returns if the object should be laid out right-to-left or left-to-right. */ Qt::LayoutDirection QTextInlineObject::textDirection() const { @@ -322,7 +321,6 @@ Qt::LayoutDirection QTextInlineObject::textDirection() const itself can be positioned with setPosition(); it has a boundingRect(), and a minimumWidth() and a maximumWidth(). A text layout can be drawn on a painter device using draw(). - */ /*! @@ -395,7 +393,7 @@ QTextLayout::~QTextLayout() Sets the layout's font to the given \a font. The layout is invalidated and must be laid out again. - \sa text() + \sa font() */ void QTextLayout::setFont(const QFont &font) { @@ -405,6 +403,8 @@ void QTextLayout::setFont(const QFont &font) /*! Returns the current font that is used for the layout, or a default font if none is set. + + \sa setFont() */ QFont QTextLayout::font() const { @@ -438,10 +438,10 @@ QString QTextLayout::text() const } /*! - Sets the text option structure that controls the layout process to the - given \a option. + Sets the text option structure that controls the layout process to the + given \a option. - \sa textOption() QTextOption + \sa textOption() */ void QTextLayout::setTextOption(const QTextOption &option) { @@ -449,9 +449,9 @@ void QTextLayout::setTextOption(const QTextOption &option) } /*! - Returns the current text option used to control the layout process. + Returns the current text option used to control the layout process. - \sa setTextOption() QTextOption + \sa setTextOption() */ QTextOption QTextLayout::textOption() const { @@ -461,6 +461,8 @@ QTextOption QTextLayout::textOption() const /*! Sets the \a position and \a text of the area in the layout that is processed before editing occurs. + + \sa preeditAreaPosition(), preeditAreaText() */ void QTextLayout::setPreeditArea(int position, const QString &text) { @@ -489,6 +491,8 @@ void QTextLayout::setPreeditArea(int position, const QString &text) /*! Returns the position of the area in the text layout that will be processed before editing occurs. + + \sa preeditAreaText() */ int QTextLayout::preeditAreaPosition() const { @@ -497,6 +501,8 @@ int QTextLayout::preeditAreaPosition() const /*! Returns the text that is inserted in the layout before editing occurs. + + \sa preeditAreaPosition() */ QString QTextLayout::preeditAreaText() const { @@ -505,8 +511,7 @@ QString QTextLayout::preeditAreaText() const /*! - Sets the additional formats supported by the text layout to \a - formatList. + Sets the additional formats supported by the text layout to \a formatList. \sa additionalFormats(), clearAdditionalFormats() */ @@ -596,6 +601,8 @@ bool QTextLayout::cacheEnabled() const /*! Begins the layout process. + + \sa endLayout() */ void QTextLayout::beginLayout() { @@ -613,6 +620,8 @@ void QTextLayout::beginLayout() /*! Ends the layout process. + + \sa beginLayout() */ void QTextLayout::endLayout() { @@ -631,23 +640,23 @@ void QTextLayout::endLayout() d->freeMemory(); } -/*! \since 4.4 +/*! + \since 4.4 -Clears the line information in the layout. After having called -this function, lineCount() returns 0. - */ + Clears the line information in the layout. After having called + this function, lineCount() returns 0. +*/ void QTextLayout::clearLayout() { d->clearLineData(); } - /*! Returns the next valid cursor position after \a oldPos that respects the given cursor \a mode. Returns value of \a oldPos, if \a oldPos is not a valid cursor position. - \sa isValidCursorPosition() previousCursorPosition() + \sa isValidCursorPosition(), previousCursorPosition() */ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const { @@ -683,7 +692,7 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const respects the given cursor \a mode. Returns value of \a oldPos, if \a oldPos is not a valid cursor position. - \sa isValidCursorPosition() nextCursorPosition() + \sa isValidCursorPosition(), nextCursorPosition() */ int QTextLayout::previousCursorPosition(int oldPos, CursorMode mode) const { @@ -735,7 +744,6 @@ bool QTextLayout::isValidCursorPosition(int pos) const return attributes[pos].charStop; } - /*! Returns a new text line to be laid out if there is text to be inserted into the layout; otherwise returns an invalid text line. @@ -794,7 +802,7 @@ int QTextLayout::lineCount() const /*! Returns the \a{i}-th line of text in this text layout. - \sa lineCount() lineForTextPosition() + \sa lineCount(), lineForTextPosition() */ QTextLine QTextLayout::lineAt(int i) const { @@ -804,7 +812,7 @@ QTextLine QTextLayout::lineAt(int i) const /*! Returns the line that contains the cursor position specified by \a pos. - \sa isValidCursorPosition() lineAt() + \sa isValidCursorPosition(), lineAt() */ QTextLine QTextLayout::lineForTextPosition(int pos) const { @@ -897,7 +905,7 @@ qreal QTextLayout::maximumWidth() const /*! - \internal + \internal */ void QTextLayout::setFlags(int flags) { @@ -1127,8 +1135,7 @@ QList QTextLayout::glyphs() const } /*! - Draws the whole layout on the painter \a p at the position specified by - \a pos. + Draws the whole layout on the painter \a p at the position specified by \a pos. The rendered layout includes the given \a selections and is clipped within the rectangle specified by \a clip. */ @@ -1302,12 +1309,12 @@ void QTextLayout::draw(QPainter *p, const QPointF &pos, const QVectorlines[i].leading.toReal(); } -/*! \since 4.6 +/*! + \since 4.6 - Includes positive leading into the line's height if \a included is true; - otherwise does not include leading. + Includes positive leading into the line's height if \a included is true; + otherwise does not include leading. - By default, leading is not included. + By default, leading is not included. - Note that negative leading is ignored, it must be handled - in the code using the text lines by letting the lines overlap. + Note that negative leading is ignored, it must be handled + in the code using the text lines by letting the lines overlap. - \sa leadingIncluded() + \sa leadingIncluded() */ void QTextLine::setLeadingIncluded(bool included) @@ -1567,20 +1575,21 @@ void QTextLine::setLeadingIncluded(bool included) } -/*! \since 4.6 +/*! + \since 4.6 - Returns true if positive leading is included into the line's height; otherwise returns false. + Returns true if positive leading is included into the line's height; + otherwise returns false. - By default, leading is not included. + By default, leading is not included. - \sa setLeadingIncluded() + \sa setLeadingIncluded() */ bool QTextLine::leadingIncluded() const { return eng->lines[i].leadingIncluded; } - /*! Returns the width of the line that is occupied by text. This is always \<= to width(), and is the minimum width that could be used @@ -1591,14 +1600,15 @@ qreal QTextLine::naturalTextWidth() const return eng->lines[i].textWidth.toReal(); } -/*! \since 4.7 - Returns the horizontal advance of the text. The advance of the text - is the distance from its position to the next position at which - text would naturally be drawn. +/*! + \since 4.7 + Returns the horizontal advance of the text. The advance of the text + is the distance from its position to the next position at which + text would naturally be drawn. - By adding the advance to the position of the text line and using this - as the position of a second text line, you will be able to position - the two lines side-by-side without gaps in-between. + By adding the advance to the position of the text line and using this + as the position of a second text line, you will be able to position + the two lines side-by-side without gaps in-between. */ qreal QTextLine::horizontalAdvance() const { @@ -2468,21 +2478,20 @@ void QTextLine::draw(QPainter *p, const QPointF &pos, const QTextLayout::FormatR } /*! - \fn int QTextLine::cursorToX(int cursorPos, Edge edge) const + \fn int QTextLine::cursorToX(int cursorPos, Edge edge) const - \overload + \overload */ - /*! - Converts the cursor position \a cursorPos to the corresponding x position - inside the line, taking account of the \a edge. + Converts the cursor position \a cursorPos to the corresponding x position + inside the line, taking account of the \a edge. - If \a cursorPos is not a valid cursor position, the nearest valid - cursor position will be used instead, and cpos will be modified to - point to this valid cursor position. + If \a cursorPos is not a valid cursor position, the nearest valid + cursor position will be used instead, and cpos will be modified to + point to this valid cursor position. - \sa xToCursor() + \sa xToCursor() */ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const { @@ -2618,12 +2627,12 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const } /*! - \fn int QTextLine::xToCursor(qreal x, CursorPosition cpos) const + \fn int QTextLine::xToCursor(qreal x, CursorPosition cpos) const - Converts the x-coordinate \a x, to the nearest matching cursor - position, depending on the cursor position type, \a cpos. + Converts the x-coordinate \a x, to the nearest matching cursor + position, depending on the cursor position type, \a cpos. - \sa cursorToX() + \sa cursorToX() */ int QTextLine::xToCursor(qreal _x, CursorPosition cpos) const { -- cgit v0.12 From 18bb0125a246a0cfb4a1856e415624a25adb57ab Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 29 Jun 2010 10:19:30 +0200 Subject: Fixed the itemviews so that the editor is not considered opaque any more The editor was always considered opaque and clipping was set on the painter. This assumption can't be verified. Task-number: QTBUG-11367 --- src/gui/itemviews/qlistview.cpp | 11 +---------- src/gui/itemviews/qtableview.cpp | 9 +-------- src/gui/itemviews/qtreeview.cpp | 9 +-------- 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index c20e0b1..5e70a6a 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1036,16 +1036,7 @@ void QListView::paintEvent(QPaintEvent *e) previousRow = row; } - if (const QWidget *widget = d->editorForIndex(*it).editor) { - QRegion itemGeometry(option.rect); - QRegion widgetGeometry(widget->geometry()); - painter.save(); - painter.setClipRegion(itemGeometry.subtracted(widgetGeometry)); - d->delegateForIndex(*it)->paint(&painter, option, *it); - painter.restore(); - } else { - d->delegateForIndex(*it)->paint(&painter, option, *it); - } + d->delegateForIndex(*it)->paint(&painter, option, *it); } #ifndef QT_NO_DRAGANDDROP diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 4492e53..e9e2e38 100644 --- a/src/gui/itemviews/qtableview.cpp +++ b/src/gui/itemviews/qtableview.cpp @@ -926,14 +926,7 @@ void QTableViewPrivate::drawCell(QPainter *painter, const QStyleOptionViewItemV4 q->style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, q); - if (const QWidget *widget = editorForIndex(index).editor) { - painter->save(); - painter->setClipRect(widget->geometry()); - q->itemDelegate(index)->paint(painter, opt, index); - painter->restore(); - } else { - q->itemDelegate(index)->paint(painter, opt, index); - } + q->itemDelegate(index)->paint(painter, opt, index); } /*! diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index b797776..f953a91 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -1669,14 +1669,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, opt.state = oldState; } - if (const QWidget *widget = d->editorForIndex(modelIndex).editor) { - painter->save(); - painter->setClipRect(widget->geometry()); - d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex); - painter->restore(); - } else { - d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex); - } + d->delegateForIndex(modelIndex)->paint(painter, opt, modelIndex); } if (currentRowHasFocus) { -- cgit v0.12 From e6c6b10bcdfe8954319506aa917e80edf7a8e6d5 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 29 Jun 2010 10:20:55 +0200 Subject: Oops... --- src/gui/widgets/qsplashscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qsplashscreen.cpp b/src/gui/widgets/qsplashscreen.cpp index c99952e..2b6bfeb 100644 --- a/src/gui/widgets/qsplashscreen.cpp +++ b/src/gui/widgets/qsplashscreen.cpp @@ -267,7 +267,7 @@ void QSplashScreen::drawContents(QPainter *painter) { Q_D(QSplashScreen); painter->setPen(d->currColor); - QRect r = rect().adjusted(5, 5, -10, -10); + QRect r = rect().adjusted(5, 5, -5, -5); if (Qt::mightBeRichText(d->currStatus)) { QTextDocument doc; #ifdef QT_NO_TEXTHTMLPARSER -- 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 3e06221c481b73af3a3e16c362bcd8c3fd7b4269 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 30 Jun 2010 11:39:23 +0200 Subject: Code simplification in treeviews --- src/gui/itemviews/qtreeview.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index f953a91..54f8d05 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2462,11 +2462,9 @@ void QTreeView::rowsInserted(const QModelIndex &parent, int start, int end) } const int parentItem = d->viewIndex(parent); - if (((parentItem != -1) && d->viewItems.at(parentItem).expanded && updatesEnabled()) + if (((parentItem != -1) && d->viewItems.at(parentItem).expanded) || (parent == d->root)) { d->doDelayedItemsLayout(); - } else if ((parentItem != -1) && d->viewItems.at(parentItem).expanded) { - d->doDelayedItemsLayout(); } else if (parentItem != -1 && (d->model->rowCount(parent) == end - start + 1)) { // the parent just went from 0 children to more. update to re-paint the decoration d->viewItems[parentItem].hasChildren = true; -- cgit v0.12 From 8aebcf559e42a6e93d343b1bd46f5abb4a10cb7f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 30 Jun 2010 17:11:39 +0200 Subject: QMutex: remove debug warnings. d->owner is not tracked correctly when the new inline (un)lock function are called. And there is no way to make it work reliably as one could mix application compiled in release with Qt in debug. So QMutex could display lots of false warnings. Better to remove them. Reviewed-by: Trond --- src/corelib/thread/qmutex.cpp | 48 ------------------------------------------- 1 file changed, 48 deletions(-) diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index eb6f729..b85a22d 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -159,11 +159,6 @@ void QMutex::lock() bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0; if (!isLocked) { -#ifndef QT_NO_DEBUG - if (d->owner == self) - qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner; -#endif - // didn't get the lock, wait for it isLocked = d->wait(); Q_ASSERT_X(isLocked, "QMutex::lock", @@ -179,18 +174,11 @@ void QMutex::lock() return; } -#ifndef QT_NO_DEBUG - self = QThread::currentThreadId(); -#endif bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1); if (!isLocked) { lockInternal(); } - -#ifndef QT_NO_DEBUG - d->owner = self; -#endif } /*! @@ -236,18 +224,12 @@ bool QMutex::tryLock() return isLocked; } -#ifndef QT_NO_DEBUG - self = QThread::currentThreadId(); -#endif bool isLocked = d->contenders == 0 && d->contenders.testAndSetAcquire(0, 1); if (!isLocked) { // some other thread has the mutex locked, or we tried to // recursively lock an non-recursive mutex return isLocked; } -#ifndef QT_NO_DEBUG - d->owner = self; -#endif return isLocked; } @@ -304,9 +286,6 @@ bool QMutex::tryLock(int timeout) return true; } -#ifndef QT_NO_DEBUG - self = QThread::currentThreadId(); -#endif bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0; if (!isLocked) { // didn't get the lock, wait for it @@ -317,9 +296,6 @@ bool QMutex::tryLock(int timeout) if (!isLocked) return false; } -#ifndef QT_NO_DEBUG - d->owner = self; -#endif return true; } @@ -334,12 +310,6 @@ bool QMutex::tryLock(int timeout) void QMutex::unlock() { QMutexPrivate *d = static_cast(this->d); -#ifndef QT_NO_DEBUG - //note: if the mutex has been locked with (try)lockInline, d->owner could have not been set, and this would be a false warning - if ((d->owner || d->recursive) && d->owner != QThread::currentThreadId()) - qWarning("QMutex::unlock(): A mutex must be unlocked in the same thread that locked it."); -#endif - if (d->recursive) { if (!--d->count) { @@ -348,9 +318,6 @@ void QMutex::unlock() d->wakeUp(); } } else { -#ifndef QT_NO_DEBUG - d->owner = 0; -#endif if (!d->contenders.testAndSetRelease(1, 0)) d->wakeUp(); } @@ -490,19 +457,11 @@ void QMutex::lockInternal() enum { AdditionalSpins = 20, SpinCountPenalizationDivisor = 4 }; const int maximumSpinCount = lastSpinCount + AdditionalSpins; -#ifndef QT_NO_DEBUG - Qt::HANDLE self = QThread::currentThreadId(); -#endif - do { if (spinCount++ > maximumSpinCount) { // puts("spinning useless, sleeping"); bool isLocked = d->contenders.fetchAndAddAcquire(1) == 0; if (!isLocked) { -#ifndef QT_NO_DEBUG - if (d->owner == self) - qWarning() << "QMutex::lock: Deadlock detected in thread" << d->owner; -#endif // didn't get the lock, wait for it isLocked = d->wait(); @@ -523,10 +482,6 @@ void QMutex::lockInternal() d->lastSpinCount = spinCount >= 0 ? qMax(lastSpinCount, spinCount) : lastSpinCount + spinCount; - -#ifndef QT_NO_DEBUG - d->owner = self; -#endif } /*! @@ -534,9 +489,6 @@ void QMutex::lockInternal() */ void QMutex::unlockInternal() { -#ifndef QT_NO_DEBUG - static_cast(d)->owner = 0; -#endif static_cast(d)->wakeUp(); } -- cgit v0.12 From 8accbacddae66a2e2e6d8e2ded51bdfe6800b481 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 30 Jun 2010 18:53:55 +0200 Subject: Fix the blank areas during resize with the raster engine on Mac OS X. This is mainly done by reverting the commit 04e34fe3aecca482abeeabe2e31778e9102eeb08 Task-number: QTBUG-11518 Reviewed-by: Samuel --- src/gui/kernel/qcocoaview_mac.mm | 10 ++++------ src/gui/kernel/qwidget.cpp | 12 ------------ src/gui/painting/qwindowsurface_raster.cpp | 3 +++ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 772016a..10ff365 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -498,13 +498,11 @@ static int qCocoaViewCount = 0; return; if (QApplicationPrivate::graphicsSystem() != 0) { - if (qwidgetprivate->maybeBackingStore()) { - // Drawing is handled on the window level - // See qcocoasharedwindowmethods_mac_p.h - if (!qwidget->testAttribute(Qt::WA_PaintOnScreen)) - return; - } + if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) + bs->markDirty(qwidget->rect(), qwidget); + qwidgetprivate->syncBackingStore(qwidget->rect()); } + CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; qwidgetprivate->hd = cg; CGContextSaveGState(cg); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 77d416b..77e9288 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1767,13 +1767,7 @@ void QWidgetPrivate::syncBackingStore() repaint_sys(dirty); dirty = QRegion(); } else if (QWidgetBackingStore *bs = maybeBackingStore()) { -#ifdef QT_MAC_USE_COCOA - Q_UNUSED(bs); - void qt_mac_set_needs_display(QWidget *, QRegion); - qt_mac_set_needs_display(q_func(), QRegion()); -#else bs->sync(); -#endif } } @@ -1782,13 +1776,7 @@ void QWidgetPrivate::syncBackingStore(const QRegion ®ion) if (paintOnScreen()) repaint_sys(region); else if (QWidgetBackingStore *bs = maybeBackingStore()) { -#ifdef QT_MAC_USE_COCOA - Q_UNUSED(bs); - void qt_mac_set_needs_display(QWidget *, QRegion); - qt_mac_set_needs_display(q_func(), region); -#else bs->sync(q_func(), region); -#endif } } diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index eee6bef..f3e1e4e 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -295,7 +295,10 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi CGContextRestoreGState(context); #ifndef QT_MAC_USE_COCOA QDEndCGContext(port, &context); +#else + CGContextFlush(context); #endif + #endif // Q_WS_MAC #ifdef Q_OS_SYMBIAN -- cgit v0.12 From d33268507b4a5f4a30ee0b24db45d4b79ef8f1c3 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 1 Jul 2010 09:53:19 +0200 Subject: Auto expand of QTreeWidget does not work correctly if animated The problem was that the internal state of the tree was not correctly reset. Patch comes from the task. Task-number: QTBUG-10850 --- src/gui/itemviews/qabstractitemview.cpp | 1 + src/gui/itemviews/qabstractitemview_p.h | 1 + src/gui/itemviews/qtreeview.cpp | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 4fb93fc..15e59ba 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -79,6 +79,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() pressedAlreadySelected(false), viewportEnteredNeeded(false), state(QAbstractItemView::NoState), + stateBeforeAnimation(QAbstractItemView::NoState), editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed), lastTrigger(QAbstractItemView::NoEditTriggers), tabKeyNavigation(false), diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index b9408a5..ee79ee9 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -367,6 +367,7 @@ public: bool viewportEnteredNeeded; QAbstractItemView::State state; + QAbstractItemView::State stateBeforeAnimation; QAbstractItemView::EditTriggers editTriggers; QAbstractItemView::EditTrigger lastTrigger; diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 54f8d05..ccc8e00 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2861,13 +2861,13 @@ void QTreeViewPrivate::expand(int item, bool emitSignal) if (emitSignal && animationsEnabled) prepareAnimatedOperation(item, QVariantAnimation::Forward); #endif //QT_NO_ANIMATION - QAbstractItemView::State oldState = state; + stateBeforeAnimation = state; q->setState(QAbstractItemView::ExpandingState); const QModelIndex index = viewItems.at(item).index; storeExpanded(index); viewItems[item].expanded = true; layout(item); - q->setState(oldState); + q->setState(stateBeforeAnimation); if (model->canFetchMore(index)) model->fetchMore(index); @@ -2936,7 +2936,7 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal) prepareAnimatedOperation(item, QVariantAnimation::Backward); #endif //QT_NO_ANIMATION - QAbstractItemView::State oldState = state; + stateBeforeAnimation = state; q->setState(QAbstractItemView::CollapsingState); expandedIndexes.erase(it); viewItems[item].expanded = false; @@ -2946,7 +2946,7 @@ void QTreeViewPrivate::collapse(int item, bool emitSignal) index = viewItems[index].parentItem; } removeViewItems(item + 1, total); // collapse - q->setState(oldState); + q->setState(stateBeforeAnimation); if (emitSignal) { emit q->collapsed(modelIndex); @@ -3057,7 +3057,7 @@ QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) cons void QTreeViewPrivate::_q_endAnimatedOperation() { Q_Q(QTreeView); - q->setState(QAbstractItemView::NoState); + q->setState(stateBeforeAnimation); q->updateGeometries(); viewport->update(); } -- cgit v0.12 From e9ac791e2afce05be68da5f7b0c00eac00811f29 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 1 Jul 2010 12:48:00 +0200 Subject: Fixed the combobox just adjusting their size without relayouting When adjustSize() is called, we nned to call updateGeometry to notify the layout in which the combobox is to redo the layout. Task-number: QTBUG-2559 --- src/gui/widgets/qcombobox.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 213ca95..fe00173 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -369,6 +369,7 @@ void QComboBoxPrivateContainer::timerEvent(QTimerEvent *timerEvent) if (timerEvent->timerId() == adjustSizeTimer.timerId()) { adjustSizeTimer.stop(); if (combo->sizeAdjustPolicy() == QComboBox::AdjustToContents) { + combo->updateGeometry(); combo->adjustSize(); combo->update(); } -- cgit v0.12 From 9f72c297843459ab22eeb3af048baa9037aa9634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 17 Mar 2010 12:16:57 +0100 Subject: Make qt_gl_paint_engine() thread-safe. --- src/opengl/qgl.cpp | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5c5d3d1..b875fd1 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5031,25 +5031,54 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#ifndef QT_OPENGL_ES_1 -Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_gl_2_engine) +#if !defined(QT_OPENGL_ES_1) +class QtGL2EngineStorage +{ +public: + QPaintEngine *engine() { + QPaintEngine *localEngine = storage.localData(); + if (!localEngine) { + localEngine = new QGL2PaintEngineEx; + storage.setLocalData(localEngine); + } + return localEngine; + } + +private: + QThreadStorage storage; +}; +Q_GLOBAL_STATIC(QtGL2EngineStorage, qt_gl_2_engine) #endif #ifndef QT_OPENGL_ES_2 -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_gl_engine) +class QtGL1EngineStorage +{ +public: + QPaintEngine *engine() { + QPaintEngine *localEngine = storage.localData(); + if (!localEngine) { + localEngine = new QOpenGLPaintEngine; + storage.setLocalData(localEngine); + } + return localEngine; + } +private: + QThreadStorage storage; +}; +Q_GLOBAL_STATIC(QtGL1EngineStorage, qt_gl_engine) #endif Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() { #if defined(QT_OPENGL_ES_1) - return qt_gl_engine(); + return qt_gl_engine()->engine(); #elif defined(QT_OPENGL_ES_2) - return qt_gl_2_engine(); + return qt_gl_2_engine()->engine(); #else if (qt_gl_preferGL2Engine()) - return qt_gl_2_engine(); + return qt_gl_2_engine()->engine(); else - return qt_gl_engine(); + return qt_gl_engine()->engine(); #endif } -- cgit v0.12 From 38922774119817f4bf1595b9651f914e5c3d9f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Jun 2010 12:51:00 +0200 Subject: More work on GL threading. Removed QObject inheritance from QGLEngineSharedShaders and made it thread-local, so that paintengines in different threads can use programs without clashing. Lifted some restrictions on QPixmap so that they may be used in threads when the GL2 engine is active. Made the QGLContextGroup a part of the pixmap and image cache keys. --- src/gui/image/qpixmap.cpp | 1 + src/gui/painting/qpainter.cpp | 11 ++- .../gl2paintengineex/qglengineshadermanager.cpp | 94 +++++++++++++++++----- .../gl2paintengineex/qglengineshadermanager_p.h | 13 ++- src/opengl/qgl.cpp | 12 ++- src/opengl/qgl_p.h | 3 + 6 files changed, 98 insertions(+), 36 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 20e4b50..e630e80 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -94,6 +94,7 @@ Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap) static bool qt_pixmap_thread_test() { + return true; if (!qApp) { qFatal("QPixmap: Must construct a QApplication before a QPaintDevice"); return false; diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 312cc95..ec2aca4 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5252,7 +5252,8 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + if (d->engine->type() != QPaintEngine::OpenGL2) + qt_painter_thread_test(d->device->devType(), "drawPixmap()"); #endif if (d->extended) { @@ -5322,7 +5323,8 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) if (!d->engine || pm.isNull()) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + if (d->engine->type() != QPaintEngine::OpenGL2) + qt_painter_thread_test(d->device->devType(), "drawPixmap()"); #endif qreal x = r.x(); @@ -5926,7 +5928,7 @@ void QPainter::drawStaticText(const QPointF &topLeftPosition, const QStaticText // Recreate the layout of the static text because the matrix or font has changed if (staticTextNeedsReinit) - staticText_d->init(); + staticText_d->init(); if (transformedPosition != staticText_d->position) { // Translate to actual position QFixed fx = QFixed::fromReal(transformedPosition.x()); @@ -6666,7 +6668,8 @@ void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPo return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()"); + if (d->engine->type() != QPaintEngine::OpenGL2) + qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()"); #endif qreal sw = pixmap.width(); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 40b3641..5330706 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -51,19 +51,61 @@ QT_BEGIN_NAMESPACE static void qt_shared_shaders_free(void *data) { + qDebug() << "qt_shared_shaders_free() for thread:" << hex << QThread::currentThread(); delete reinterpret_cast(data); } -Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shared_shaders, (qt_shared_shaders_free)) + +class QGLThreadLocalShaders { +public: + QGLThreadLocalShaders(QGLContextResource *resource) : m_resource(resource), m_shaders(0) {} + ~QGLThreadLocalShaders() { + if (m_shaders) { + qDebug() << "~QGLThreadLocalShaders() for thread:" << hex << QThread::currentThread(); + m_shaders->cleanupBeforeDestruction(); + } + } + QGLContextResource *m_resource; + QGLEngineSharedShaders *m_shaders; +}; + +class QGLThreadShaders +{ +public: + QGLContextResource *shadersForThread() { + QGLThreadLocalShaders *shaders = m_storage.localData(); + if (!shaders) { + // The QGLContextResource is needed because the shaders need to be cleaned up + // when the context is destroyed, not just when a thread exits + QGLContextResource *resource = new QGLContextResource(qt_shared_shaders_free); + qDebug() << "new local resource for thread:" << hex << QThread::currentThread() << resource; + shaders = new QGLThreadLocalShaders(resource); + m_storage.setLocalData(shaders); + } + return shaders->m_resource; + } + + void setShadersForThread(const QGLContext *context, QGLEngineSharedShaders *sharedShaders) { + shadersForThread()->insert(context, sharedShaders); + m_storage.localData()->m_shaders = sharedShaders; + qDebug() << " -> context:" << context; + } + +private: + QThreadStorage m_storage; +}; + +Q_GLOBAL_STATIC(QGLThreadShaders, qt_shared_shaders); QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLContext *context) { - QGLEngineSharedShaders *p = reinterpret_cast(qt_shared_shaders()->value(context)); - if (!p) { + QGLEngineSharedShaders *shaders = reinterpret_cast(qt_shared_shaders()->shadersForThread()->value(context)); + if (!shaders) { QGLShareContextScope scope(context); - qt_shared_shaders()->insert(context, p = new QGLEngineSharedShaders(context)); + shaders = new QGLEngineSharedShaders(context); + qt_shared_shaders()->setShadersForThread(context, shaders); } - return p; + return shaders; } const char* QGLEngineSharedShaders::qShaderSnippets[] = { @@ -170,18 +212,20 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) source.clear(); source.append(qShaderSnippets[MainVertexShader]); source.append(qShaderSnippets[PositionOnlyVertexShader]); - vertexShader = new QGLShader(QGLShader::Vertex, context, this); + vertexShader = new QGLShader(QGLShader::Vertex, context, 0); + shaders.append(vertexShader); if (!vertexShader->compileSourceCode(source)) qWarning("Vertex shader for simpleShaderProg (MainVertexShader & PositionOnlyVertexShader) failed to compile"); source.clear(); source.append(qShaderSnippets[MainFragmentShader]); source.append(qShaderSnippets[ShockingPinkSrcFragmentShader]); - fragShader = new QGLShader(QGLShader::Fragment, context, this); + fragShader = new QGLShader(QGLShader::Fragment, context, 0); + shaders.append(fragShader); if (!fragShader->compileSourceCode(source)) qWarning("Fragment shader for simpleShaderProg (MainFragmentShader & ShockingPinkSrcFragmentShader) failed to compile"); - simpleShaderProg = new QGLShaderProgram(context, this); + simpleShaderProg = new QGLShaderProgram(context, 0); simpleShaderProg->addShader(vertexShader); simpleShaderProg->addShader(fragShader); simpleShaderProg->bindAttributeLocation("vertexCoordsArray", QT_VERTEX_COORDS_ATTR); @@ -198,18 +242,20 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) source.clear(); source.append(qShaderSnippets[MainWithTexCoordsVertexShader]); source.append(qShaderSnippets[UntransformedPositionVertexShader]); - vertexShader = new QGLShader(QGLShader::Vertex, context, this); + vertexShader = new QGLShader(QGLShader::Vertex, context, 0); + shaders.append(vertexShader); if (!vertexShader->compileSourceCode(source)) qWarning("Vertex shader for blitShaderProg (MainWithTexCoordsVertexShader & UntransformedPositionVertexShader) failed to compile"); source.clear(); source.append(qShaderSnippets[MainFragmentShader]); source.append(qShaderSnippets[ImageSrcFragmentShader]); - fragShader = new QGLShader(QGLShader::Fragment, context, this); + fragShader = new QGLShader(QGLShader::Fragment, context, 0); + shaders.append(fragShader); if (!fragShader->compileSourceCode(source)) qWarning("Fragment shader for blitShaderProg (MainFragmentShader & ImageSrcFragmentShader) failed to compile"); - blitShaderProg = new QGLShaderProgram(context, this); + blitShaderProg = new QGLShaderProgram(context, 0); blitShaderProg->addShader(vertexShader); blitShaderProg->addShader(fragShader); blitShaderProg->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR); @@ -224,9 +270,20 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) QGLEngineSharedShaders::~QGLEngineSharedShaders() { - QList::iterator itr; - for (itr = cachedPrograms.begin(); itr != cachedPrograms.end(); ++itr) - delete *itr; + cleanupBeforeDestruction(); +} + + +// This might be called both when a thread exits, or when the a +// context is destroyed + +void QGLEngineSharedShaders::cleanupBeforeDestruction() +{ + qDeleteAll(shaders); + shaders.clear(); + + qDeleteAll(cachedPrograms); + cachedPrograms.clear(); if (blitShaderProg) { delete blitShaderProg; @@ -276,7 +333,8 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS source.append(qShaderSnippets[prog.compositionFragShader]); if (prog.maskFragShader) source.append(qShaderSnippets[prog.maskFragShader]); - fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), this); + fragShader = new QGLShader(QGLShader::Fragment, ctxGuard.context(), 0); + shaders.append(fragShader); QByteArray description; #if defined(QT_DEBUG) // Name the shader for easier debugging @@ -302,7 +360,8 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS source.clear(); source.append(qShaderSnippets[prog.mainVertexShader]); source.append(qShaderSnippets[prog.positionVertexShader]); - vertexShader = new QGLShader(QGLShader::Vertex, ctxGuard.context(), this); + vertexShader = new QGLShader(QGLShader::Vertex, ctxGuard.context(), 0); + shaders.append(vertexShader); #if defined(QT_DEBUG) // Name the shader for easier debugging description.clear(); @@ -320,7 +379,7 @@ QGLEngineShaderProg *QGLEngineSharedShaders::findProgramInCache(const QGLEngineS newProg = new QGLEngineShaderProg(prog); // If the shader program's not found in the cache, create it now. - newProg->program = new QGLShaderProgram(ctxGuard.context(), this); + newProg->program = new QGLShaderProgram(ctxGuard.context(), 0); newProg->program->addShader(vertexShader); newProg->program->addShader(fragShader); @@ -413,7 +472,6 @@ QGLEngineShaderManager::QGLEngineShaderManager(QGLContext* context) currentShaderProg(0) { sharedShaders = QGLEngineSharedShaders::shadersForContext(context); - connect(sharedShaders, SIGNAL(shaderProgNeedsChanging()), this, SLOT(shaderProgNeedsChangingSlot())); } QGLEngineShaderManager::~QGLEngineShaderManager() diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 06b96ae..8d3697b 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -259,9 +259,9 @@ static const GLuint QT_PMV_MATRIX_3_ATTR = 5; class QGLEngineShaderProg; -class QGLEngineSharedShaders : public QObject +class QGLEngineSharedShaders { - Q_OBJECT + Q_GADGET public: enum SnippetName { @@ -364,14 +364,16 @@ public: // full. void cleanupCustomStage(QGLCustomShaderStage* stage); -signals: - void shaderProgNeedsChanging(); + // this is needed so that threads can get a foot in and have a chance to + // clean up the shaders they've created before the thread exits + void cleanupBeforeDestruction(); private: QGLSharedResourceGuard ctxGuard; QGLShaderProgram *blitShaderProg; QGLShaderProgram *simpleShaderProg; QList cachedPrograms; + QList shaders; static const char* qShaderSnippets[TotalSnippetCount]; }; @@ -492,9 +494,6 @@ public: QGLEngineSharedShaders* sharedShaders; -private slots: - void shaderProgNeedsChangingSlot() { shaderProgNeedsChanging = true; } - private: QGLContext* ctx; bool shaderProgNeedsChanging; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index b875fd1..fa6dd37 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2236,7 +2236,7 @@ QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_prem QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) { - const qint64 key = image.cacheKey(); + const qint64 key = image.cacheKey() | (qint64) group; QGLTexture *texture = textureCacheLookup(key, target); if (texture) { glBindTexture(target, texture->id); @@ -2509,7 +2509,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, Q_UNUSED(q); #endif - const qint64 key = pixmap.cacheKey(); + const qint64 key = pixmap.cacheKey() | (qint64) group; QGLTexture *texture = textureCacheLookup(key, target); if (texture) { glBindTexture(target, texture->id); @@ -2532,6 +2532,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, } #endif + printf(" -> bindTexture key: %llx\n", key); if (!texture) { QImage image = pixmap.toImage(); // If the system depth is 16 and the pixmap doesn't have an alpha channel @@ -4061,11 +4062,7 @@ bool QGLWidget::event(QEvent *e) #if defined(Q_WS_X11) // prevents X errors on some systems, where we get a flush to a // hidden widget - if (e->type() == QEvent::Hide) { - makeCurrent(); - glFinish(); - doneCurrent(); - } else if (e->type() == QEvent::ParentChange) { + if (e->type() == QEvent::ParentChange) { // if we've reparented a window that has the current context // bound, we need to rebind that context to the new window id if (d->glcx == QGLContext::currentContext()) @@ -5373,6 +5370,7 @@ void *QGLContextResource::value(const QGLContext *key) void QGLContextResource::cleanup(const QGLContext *ctx, void *value) { + qDebug() << "QGLContextResource::cleanup() this:" << hex << this << "thread:" << QThread::currentThread(); QGLShareContextScope scope(ctx); free(value); active.deref(); diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 16c225f..9b862eb 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -473,6 +473,8 @@ private: QGLContext *m_ctx; }; +#include +#include class QGLTexture { public: QGLTexture(QGLContext *ctx = 0, GLuint tx_id = 0, GLenum tx_target = GL_TEXTURE_2D, @@ -489,6 +491,7 @@ public: ~QGLTexture() { if (options & QGLContext::MemoryManagedBindOption) { Q_ASSERT(context); + qDebug()<< "~QGLTexture: thread:" << hex <thread() << ")" << "context:" << context << "current context:" << QGLContext::currentContext(); QGLShareContextScope scope(context); #if defined(Q_WS_X11) // Although glXReleaseTexImage is a glX call, it must be called while there -- cgit v0.12 From 15ac2bc856735cdd81dde9f3d3dc2c47177ef814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 26 Mar 2010 10:05:16 +0100 Subject: Only use the texture_from_pixmap extension in the main thread. It's not possible to bind several texture ids to the same surface that wraps a native X11 Pixmap, which means we can't use it reliably from more than one thread at a time. For now we limit the usage to the main thread. --- src/opengl/qgl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index fa6dd37..995e753 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2521,7 +2521,8 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, const QX11Info *xinfo = qt_x11Info(paintDevice); if (pd->classId() == QPixmapData::X11Class && pd->pixelType() == QPixmapData::PixmapType && xinfo && xinfo->screen() == pixmap.x11Info().screen() - && target == GL_TEXTURE_2D) + && target == GL_TEXTURE_2D + && QApplication::instance()->thread() == QThread::currentThread()) { texture = bindTextureFromNativePixmap(const_cast(&pixmap), key, options); if (texture) { -- cgit v0.12 From ac2818bef95f1347e80be8ce847f2557339b76e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 7 Apr 2010 14:57:24 +0200 Subject: Make it possible to call QWidget::metric() from a different thread. Under Windows. --- src/gui/kernel/qwidget_win.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 9d96fcb..60ba879 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -1633,8 +1633,6 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) } } -extern Q_GUI_EXPORT HDC qt_win_display_dc(); - int QWidget::metric(PaintDeviceMetric m) const { Q_D(const QWidget); @@ -1644,7 +1642,7 @@ int QWidget::metric(PaintDeviceMetric m) const } else if (m == PdmHeight) { val = data->crect.height(); } else { - HDC gdc = qt_win_display_dc(); + HDC gdc = GetDC(0); switch (m) { case PdmDpiX: case PdmPhysicalDpiX: @@ -1695,6 +1693,7 @@ int QWidget::metric(PaintDeviceMetric m) const val = 0; qWarning("QWidget::metric: Invalid metric command"); } + ReleaseDC(0, gdc); } return val; } -- cgit v0.12 From 7e464e38009f2492a41e9972a75f868cf88d353a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 9 Apr 2010 17:52:38 +0200 Subject: Simplify how the QGLEngineSharedShaders object is cleaned up. There are two things that needs to be done when cleaning up those objects: 1) if the context is destroyed before the specific thread exits, the shaders that is allocated within that context needs to be cleanup before the context is destroyed. 2) if the thread exits before the context is destroyed, the thread needs to clean up the shaders and then delete the QGLEngineSharedShaders object. We can't use a QGLContextResouce for that because a) we don't know if our context ptrs are valid, b) QGLContextResource doesn't remove themselves from the QGLContextGroups internal list when destroyed, so we might get a free() call *after* the resource had been destroyed. Use the contextDestroyed() signal from QGLSignalProxy() instead, which is cleaner and actually works.. --- .../gl2paintengineex/qglengineshadermanager.cpp | 67 +++++++++++----------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 5330706..7d6d8a6 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -46,66 +46,61 @@ #include #endif - QT_BEGIN_NAMESPACE -static void qt_shared_shaders_free(void *data) +class QGLThreadLocalShaders : public QObject { - qDebug() << "qt_shared_shaders_free() for thread:" << hex << QThread::currentThread(); - delete reinterpret_cast(data); -} - - -class QGLThreadLocalShaders { + Q_OBJECT public: - QGLThreadLocalShaders(QGLContextResource *resource) : m_resource(resource), m_shaders(0) {} + QGLThreadLocalShaders(const QGLContext *context, QGLEngineSharedShaders *shaders) + : m_context(context), m_shaders(shaders) + { + connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), + SLOT(contextDestroyed(const QGLContext*))); + } ~QGLThreadLocalShaders() { - if (m_shaders) { - qDebug() << "~QGLThreadLocalShaders() for thread:" << hex << QThread::currentThread(); + qDebug() << "~QGLThreadLocalShaders() for thread:" << hex << QThread::currentThread(); + qDebug() << " -> deleting shader cache:" << hex << m_shaders; + delete m_shaders; + } + const QGLContext *m_context; + QGLEngineSharedShaders *m_shaders; + +private slots: + void contextDestroyed(const QGLContext * context) { + if (context == m_context) { + qDebug() << "QGLThreadLocalShaders::contextDestroyed():"; + qDebug() << " -> cleaning up shader cache for thread:" << hex << QThread::currentThread(); + qDebug() << " -> shaders:" << hex << m_shaders; m_shaders->cleanupBeforeDestruction(); } } - QGLContextResource *m_resource; - QGLEngineSharedShaders *m_shaders; }; -class QGLThreadShaders +class QGLShaderStorage { public: - QGLContextResource *shadersForThread() { + QGLEngineSharedShaders *shadersForThread(const QGLContext *context) { QGLThreadLocalShaders *shaders = m_storage.localData(); if (!shaders) { - // The QGLContextResource is needed because the shaders need to be cleaned up - // when the context is destroyed, not just when a thread exits - QGLContextResource *resource = new QGLContextResource(qt_shared_shaders_free); - qDebug() << "new local resource for thread:" << hex << QThread::currentThread() << resource; - shaders = new QGLThreadLocalShaders(resource); + qDebug() << "new shader cache for thread:" << hex << QThread::currentThread(); + QGLShareContextScope scope(context); + shaders = new QGLThreadLocalShaders(context, new QGLEngineSharedShaders(context)); + qDebug() << " -> context:" << context; m_storage.setLocalData(shaders); } - return shaders->m_resource; - } - - void setShadersForThread(const QGLContext *context, QGLEngineSharedShaders *sharedShaders) { - shadersForThread()->insert(context, sharedShaders); - m_storage.localData()->m_shaders = sharedShaders; - qDebug() << " -> context:" << context; + return shaders->m_shaders; } private: QThreadStorage m_storage; }; -Q_GLOBAL_STATIC(QGLThreadShaders, qt_shared_shaders); +Q_GLOBAL_STATIC(QGLShaderStorage, qt_shader_storage); QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLContext *context) { - QGLEngineSharedShaders *shaders = reinterpret_cast(qt_shared_shaders()->shadersForThread()->value(context)); - if (!shaders) { - QGLShareContextScope scope(context); - shaders = new QGLEngineSharedShaders(context); - qt_shared_shaders()->setShadersForThread(context, shaders); - } - return shaders; + return reinterpret_cast(qt_shader_storage()->shadersForThread(context)); } const char* QGLEngineSharedShaders::qShaderSnippets[] = { @@ -845,3 +840,5 @@ bool QGLEngineShaderManager::useCorrectShaderProg() } QT_END_NAMESPACE + +#include "qglengineshadermanager.moc" -- cgit v0.12 From 4c3ac765b26e56fbf08c9f70cf43aa00a6565cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 16 Apr 2010 11:38:20 +0200 Subject: Don't use the QGLSignalProxy to clean up the thread-local shaders. After much back and forth I think we can use this approach for cleaning up thread-local, shared resources. Main problem has been dealing with dangling pointers and references, but they should be solved now. --- .../gl2paintengineex/qglengineshadermanager.cpp | 49 ++++++++++++++-------- src/opengl/qgl.cpp | 9 ++++ src/opengl/qgl_p.h | 2 + 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 7d6d8a6..0ba324d 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -48,42 +48,59 @@ QT_BEGIN_NAMESPACE -class QGLThreadLocalShaders : public QObject + +// Handling the cleanup and creation of the thread-local shader cache +// differes from other QGLContextResources. The cache needs to be +// cleaned up when the thread exits, or when its group context is +// destroyed. + +static void qt_gl_free_shared_shaders(void *value); + +class QGLThreadLocalShaders { - Q_OBJECT public: QGLThreadLocalShaders(const QGLContext *context, QGLEngineSharedShaders *shaders) : m_context(context), m_shaders(shaders) { - connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), - SLOT(contextDestroyed(const QGLContext*))); + m_resource = new QGLContextResource(qt_gl_free_shared_shaders); + m_resource->insert(context, this); } ~QGLThreadLocalShaders() { + qDebug() << "Thread exit:"; qDebug() << "~QGLThreadLocalShaders() for thread:" << hex << QThread::currentThread(); qDebug() << " -> deleting shader cache:" << hex << m_shaders; delete m_shaders; + // remove the resource from the group's resource list, so that + // the cleanup function is not called when the context is destroyed + m_resource->remove(m_context); + delete m_resource; } const QGLContext *m_context; QGLEngineSharedShaders *m_shaders; - -private slots: - void contextDestroyed(const QGLContext * context) { - if (context == m_context) { - qDebug() << "QGLThreadLocalShaders::contextDestroyed():"; - qDebug() << " -> cleaning up shader cache for thread:" << hex << QThread::currentThread(); - qDebug() << " -> shaders:" << hex << m_shaders; - m_shaders->cleanupBeforeDestruction(); - } - } + QGLContextResource *m_resource; }; +static void qt_gl_free_shared_shaders(void *value) +{ + QGLThreadLocalShaders *local = reinterpret_cast(value); + qDebug() << "Context destroyed:"; + qDebug() << " -> deleting shader cache" << hex << local->m_shaders; + delete local->m_shaders; + local->m_shaders = 0; + + // this function is called when the context group for the context + // we have ref'ed is deleted - that means our context ptr is no + // longer valid + local->m_context = 0; +} + class QGLShaderStorage { public: QGLEngineSharedShaders *shadersForThread(const QGLContext *context) { QGLThreadLocalShaders *shaders = m_storage.localData(); if (!shaders) { - qDebug() << "new shader cache for thread:" << hex << QThread::currentThread(); + qDebug() << "New shader cache for thread:" << hex << QThread::currentThread(); QGLShareContextScope scope(context); shaders = new QGLThreadLocalShaders(context, new QGLEngineSharedShaders(context)); qDebug() << " -> context:" << context; @@ -840,5 +857,3 @@ bool QGLEngineShaderManager::useCorrectShaderProg() } QT_END_NAMESPACE - -#include "qglengineshadermanager.moc" diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 995e753..1223552 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5377,6 +5377,15 @@ void QGLContextResource::cleanup(const QGLContext *ctx, void *value) active.deref(); } +void QGLContextResource::remove(const QGLContext *ctx) +{ + if (ctx) { + QGLContextGroup *group = QGLContextPrivate::contextGroup(ctx); + group->m_resources.remove(this); + active.deref(); + } +} + void QGLContextGroup::cleanupResources(const QGLContext *ctx) { // If there are still shares, then no cleanup to be done yet. diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 9b862eb..d5083e9 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -624,6 +624,8 @@ public: void *value(const QGLContext *key); // Cleanup 'value' in response to a context group being destroyed. void cleanup(const QGLContext *ctx, void *value); + // Remove this resource from the group's resource list. + void remove(const QGLContext *ctx); private: FreeFunc free; QAtomicInt active; -- cgit v0.12 From 80a2ebd93346f885d904e4e1020e112cc635dbaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Jun 2010 13:02:54 +0200 Subject: Redesigned how GL resource management works. The usage of QGLContextResource has changed: You're now have to subclass QGLContextResource and reimplement the freeResource() function and add your cleanup code there instead of using a plain callback function. It's now also possible to delete a QGLContextResource *before* the QGLContextGroup it refers to is destroyed, as the resource will remove itself from the context groups it's a member of. The QGLTextureGlyphCache is no longer a QObject, and it no longer depends on the aboutToDestroyContext() signal. That concept doesn't work in a threaded environment, as it relies on an eventloop to dispatch the signal to the thread. It's common to *not* have an eventloop running in a thread, which means the signal might never be delivered. QGLTextureGlyphCache now inherits from QGLContextResource, and gets cleaned up correctly when the group context is destroyed. Note that up until now the glyph cache has never been shared among sharing contexts for the GL 2 engine. Made the gradient and pixmap blur caches use the new QGLContextResource scheme. Added a template that wraps the common init code for paintEngine() function implementations for QGLWidget, QGLPixelBuffer and QGLFramebufferObject. Fixed a bug in QFontCache where the font caches weren't cleared when a thread other than the main thread exited (backported to 4.6.3), which caused resource leaks. --- .../gl2paintengineex/qglengineshadermanager.cpp | 80 ++++++++-------------- .../gl2paintengineex/qglengineshadermanager_p.h | 4 -- src/opengl/gl2paintengineex/qglgradientcache.cpp | 12 ++-- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 1 + .../gl2paintengineex/qtextureglyphcache_gl.cpp | 47 +++---------- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 31 +++------ src/opengl/qgl.cpp | 61 +++++------------ src/opengl/qgl_p.h | 32 +++++++-- src/opengl/qglframebufferobject.cpp | 8 +-- src/opengl/qglpixelbuffer.cpp | 13 ++-- src/opengl/qglpixmapfilter.cpp | 12 ++-- 11 files changed, 116 insertions(+), 185 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 0ba324d..888bac9 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -48,65 +48,54 @@ QT_BEGIN_NAMESPACE +class QGLSharedShaderResource : public QGLContextResource +{ +public: + ~QGLSharedShaderResource() { + qDebug() << "~QGLSharedShaderResource cleaned up" << hex << this; + } -// Handling the cleanup and creation of the thread-local shader cache -// differes from other QGLContextResources. The cache needs to be -// cleaned up when the thread exits, or when its group context is -// destroyed. - -static void qt_gl_free_shared_shaders(void *value); + void freeResource(void *value) + { + qDebug() << "Context destroyed:"; + qDebug() << " -> deleting shader cache" << hex << value; + delete reinterpret_cast(value); + } +}; class QGLThreadLocalShaders { public: - QGLThreadLocalShaders(const QGLContext *context, QGLEngineSharedShaders *shaders) - : m_context(context), m_shaders(shaders) - { - m_resource = new QGLContextResource(qt_gl_free_shared_shaders); - m_resource->insert(context, this); + QGLEngineSharedShaders *shadersForContext(const QGLContext *context) { + QGLEngineSharedShaders *shaders = reinterpret_cast(m_resource.value(context)); + if (!shaders) { + QGLShareContextScope scope(context); + shaders = new QGLEngineSharedShaders(context); + qDebug() << " -> new shader cache for context:" << hex << context << "cache:" << shaders; + m_resource.insert(context, shaders); + } + return shaders; } + ~QGLThreadLocalShaders() { qDebug() << "Thread exit:"; qDebug() << "~QGLThreadLocalShaders() for thread:" << hex << QThread::currentThread(); - qDebug() << " -> deleting shader cache:" << hex << m_shaders; - delete m_shaders; - // remove the resource from the group's resource list, so that - // the cleanup function is not called when the context is destroyed - m_resource->remove(m_context); - delete m_resource; } - const QGLContext *m_context; - QGLEngineSharedShaders *m_shaders; - QGLContextResource *m_resource; -}; -static void qt_gl_free_shared_shaders(void *value) -{ - QGLThreadLocalShaders *local = reinterpret_cast(value); - qDebug() << "Context destroyed:"; - qDebug() << " -> deleting shader cache" << hex << local->m_shaders; - delete local->m_shaders; - local->m_shaders = 0; - - // this function is called when the context group for the context - // we have ref'ed is deleted - that means our context ptr is no - // longer valid - local->m_context = 0; -} +private: + QGLSharedShaderResource m_resource; +}; class QGLShaderStorage { public: QGLEngineSharedShaders *shadersForThread(const QGLContext *context) { - QGLThreadLocalShaders *shaders = m_storage.localData(); + QGLThreadLocalShaders *&shaders = m_storage.localData(); if (!shaders) { - qDebug() << "New shader cache for thread:" << hex << QThread::currentThread(); - QGLShareContextScope scope(context); - shaders = new QGLThreadLocalShaders(context, new QGLEngineSharedShaders(context)); - qDebug() << " -> context:" << context; - m_storage.setLocalData(shaders); + qDebug() << "New thread storage for:" << hex << QThread::currentThread(); + shaders = new QGLThreadLocalShaders; } - return shaders->m_shaders; + return shaders->shadersForContext(context); } private: @@ -282,15 +271,6 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) QGLEngineSharedShaders::~QGLEngineSharedShaders() { - cleanupBeforeDestruction(); -} - - -// This might be called both when a thread exits, or when the a -// context is destroyed - -void QGLEngineSharedShaders::cleanupBeforeDestruction() -{ qDeleteAll(shaders); shaders.clear(); diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h index 8d3697b..e5ababf 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager_p.h +++ b/src/opengl/gl2paintengineex/qglengineshadermanager_p.h @@ -364,10 +364,6 @@ public: // full. void cleanupCustomStage(QGLCustomShaderStage* stage); - // this is needed so that threads can get a foot in and have a chance to - // clean up the shaders they've created before the thread exits - void cleanupBeforeDestruction(); - private: QGLSharedResourceGuard ctxGuard; QGLShaderProgram *blitShaderProg; diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp index a1495dd..a0a3f8f 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp @@ -46,12 +46,16 @@ QT_BEGIN_NAMESPACE -static void QGL2GradientCache_free(void *ptr) +class QGLGradientCacheResource : public QGLContextResource { - delete reinterpret_cast(ptr); -} +public: + void freeResource(void *value) + { + delete reinterpret_cast(value); + } +}; -Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_gradient_caches, (QGL2GradientCache_free)) +Q_GLOBAL_STATIC(QGLGradientCacheResource, qt_gradient_caches) QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) { diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 634b315..260e797 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1457,6 +1457,7 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp (QGLTextureGlyphCache *) staticTextItem->fontEngine->glyphCache(ctx, glyphType, QTransform()); if (!cache || cache->cacheType() != glyphType) { cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); + cache->insert(ctx, cache); staticTextItem->fontEngine->setGlyphCache(ctx, cache); } diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index faf4563..001a09e 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -54,45 +54,10 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) : QImageTextureGlyphCache(type, matrix) - , ctx(0) - , pex(0) + , ctx(context) , m_width(0) , m_height(0) { - if (context != 0) - setContext(context); -} - -QGLTextureGlyphCache::~QGLTextureGlyphCache() -{ - cleanUpContext(); -} - -void QGLTextureGlyphCache::cleanUpContext() -{ - if (ctx) { - QGLShareContextScope scope(ctx); - - if (!ctx->d_ptr->workaround_brokenFBOReadBack && pex != 0) - glDeleteFramebuffers(1, &m_fbo); - - if (m_width || m_height) { - glDeleteTextures(1, &m_texture); - m_width = 0; - m_height = 0; - m_h = 0; - } - - ctx = 0; - } -} - -void QGLTextureGlyphCache::setContext(const QGLContext *context) -{ - cleanUpContext(); - - ctx = context; - // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The // workaround is to use a system-memory copy of the glyph cache for this device. @@ -101,8 +66,12 @@ void QGLTextureGlyphCache::setContext(const QGLContext *context) if (!ctx->d_ptr->workaround_brokenFBOReadBack && pex != 0) glGenFramebuffers(1, &m_fbo); - connect(QGLSignalProxy::instance(), SIGNAL(aboutToDestroyContext(const QGLContext*)), - SLOT(contextDestroyed(const QGLContext*))); + fprintf(stderr, "## QGLTextureGlyphCache(): ctx: %p - this: %p\n", ctx, this); +} + +QGLTextureGlyphCache::~QGLTextureGlyphCache() +{ + fprintf(stderr, "## ~QGLTextureGlyphCache(): context: %p - this: %p\n", ctx, this); } void QGLTextureGlyphCache::createTextureData(int width, int height) @@ -161,7 +130,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) GLuint oldTexture = m_texture; createTextureData(width, height); - + if (pex == 0 || ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::resizeTextureData(width, height); Q_ASSERT(image().depth() == 8); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index d291ac3..710a12d 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -62,9 +62,8 @@ QT_BEGIN_NAMESPACE class QGL2PaintEngineExPrivate; -class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QObject, public QImageTextureGlyphCache +class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QGLContextResource, public QImageTextureGlyphCache { - Q_OBJECT public: QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); ~QGLTextureGlyphCache(); @@ -82,33 +81,21 @@ public: inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } - void setContext(const QGLContext *context); inline const QGLContext *context() const { return ctx; } + void freeResource(void *) { + qDebug() << "QGLTextureGlyphCache::freeResource():" << this << "ctx:" << ctx; + // At this point, the context group is made current, so it's safe to + // release resources without a makeCurrent() call + if (!ctx->d_ptr->workaround_brokenFBOReadBack) + glDeleteFramebuffers(1, &m_fbo); -public Q_SLOTS: - void contextDestroyed(const QGLContext *context) { - if (context == ctx) { - const QGLContext *nextCtx = qt_gl_transfer_context(ctx); - if (!nextCtx) { - // the context may not be current, so we cannot directly - // destroy the fbo and texture here, but since the context - // is about to be destroyed, the GL server will do the - // clean up for us anyway - m_fbo = 0; - m_texture = 0; - ctx = 0; - } else { - // since the context holding the texture is shared, and - // about to be destroyed, we have to transfer ownership - // of the texture to one of the share contexts - ctx = const_cast(nextCtx); - } - } + if (m_width || m_height) + glDeleteTextures(1, &m_texture); } private: diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 1223552..753a984 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2028,6 +2028,7 @@ QGLContext::~QGLContext() // remove any textures cached in this context QGLTextureCache::instance()->removeContextTextures(this); + qDebug() << "~QGLContext(): about to clean up" << hex << this; d_ptr->group->cleanupResources(this); QGLSignalProxy::instance()->emitAboutToDestroyContext(this); @@ -2533,7 +2534,6 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, } #endif - printf(" -> bindTexture key: %llx\n", key); if (!texture) { QImage image = pixmap.toImage(); // If the system depth is 16 and the pixmap doesn't have an alpha channel @@ -5029,41 +5029,12 @@ void QGLWidget::drawTexture(const QPointF &point, QMacCompatGLuint textureId, QM } #endif -#if !defined(QT_OPENGL_ES_1) -class QtGL2EngineStorage -{ -public: - QPaintEngine *engine() { - QPaintEngine *localEngine = storage.localData(); - if (!localEngine) { - localEngine = new QGL2PaintEngineEx; - storage.setLocalData(localEngine); - } - return localEngine; - } - -private: - QThreadStorage storage; -}; -Q_GLOBAL_STATIC(QtGL2EngineStorage, qt_gl_2_engine) +#ifndef QT_OPENGL_ES_1 +Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_gl_2_engine) #endif #ifndef QT_OPENGL_ES_2 -class QtGL1EngineStorage -{ -public: - QPaintEngine *engine() { - QPaintEngine *localEngine = storage.localData(); - if (!localEngine) { - localEngine = new QOpenGLPaintEngine; - storage.setLocalData(localEngine); - } - return localEngine; - } -private: - QThreadStorage storage; -}; -Q_GLOBAL_STATIC(QtGL1EngineStorage, qt_gl_engine) +Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_gl_engine) #endif Q_OPENGL_EXPORT QPaintEngine* qt_qgl_paint_engine() @@ -5339,13 +5310,17 @@ void QGLContextGroup::removeShare(const QGLContext *context) { group->m_shares.clear(); } -QGLContextResource::QGLContextResource(FreeFunc f) - : free(f), active(0) +QGLContextResource::QGLContextResource() + : active(0) { } QGLContextResource::~QGLContextResource() { + for (int i = 0; i < m_groups.size(); ++i) { + m_groups.at(i)->m_resources.remove(this); + active.deref(); + } #ifndef QT_NO_DEBUG if (active != 0) { qWarning("QtOpenGL: Resources are still available at program shutdown.\n" @@ -5360,6 +5335,7 @@ void QGLContextResource::insert(const QGLContext *key, void *value) QGLContextGroup *group = QGLContextPrivate::contextGroup(key); Q_ASSERT(!group->m_resources.contains(this)); group->m_resources.insert(this, value); + m_groups.append(group); active.ref(); } @@ -5371,23 +5347,18 @@ void *QGLContextResource::value(const QGLContext *key) void QGLContextResource::cleanup(const QGLContext *ctx, void *value) { - qDebug() << "QGLContextResource::cleanup() this:" << hex << this << "thread:" << QThread::currentThread(); + qDebug() << "QGLContextResource::cleanup() this:" << hex << this << "ctx:" << ctx << "thread:" << (void *)QThread::currentThread(); QGLShareContextScope scope(ctx); - free(value); + freeResource(value); active.deref(); -} -void QGLContextResource::remove(const QGLContext *ctx) -{ - if (ctx) { - QGLContextGroup *group = QGLContextPrivate::contextGroup(ctx); - group->m_resources.remove(this); - active.deref(); - } + QGLContextGroup *group = QGLContextPrivate::contextGroup(ctx); + m_groups.removeOne(group); } void QGLContextGroup::cleanupResources(const QGLContext *ctx) { + qDebug() << "QGLContextGroup::cleanupResources() for ctx:" << hex << ctx << "shares:" << m_shares.size() << "res:" << m_resources.size(); // If there are still shares, then no cleanup to be done yet. if (m_shares.size() > 1) return; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index d5083e9..1399359 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -229,6 +229,7 @@ public: static void addShare(const QGLContext *context, const QGLContext *share); static void removeShare(const QGLContext *context); + private: QGLContextGroup(const QGLContext *context); @@ -491,7 +492,6 @@ public: ~QGLTexture() { if (options & QGLContext::MemoryManagedBindOption) { Q_ASSERT(context); - qDebug()<< "~QGLTexture: thread:" << hex <thread() << ")" << "context:" << context << "current context:" << QGLContext::currentContext(); QGLShareContextScope scope(context); #if defined(Q_WS_X11) // Although glXReleaseTexImage is a glX call, it must be called while there @@ -615,19 +615,17 @@ inline GLenum qt_gl_preferredTextureTarget() class Q_OPENGL_EXPORT QGLContextResource { public: - typedef void (*FreeFunc)(void *); - QGLContextResource(FreeFunc f); - ~QGLContextResource(); + QGLContextResource(); + virtual ~QGLContextResource(); // Set resource 'value' for 'key' and all its shared contexts. void insert(const QGLContext *key, void *value); // Return resource for 'key' or a shared context. void *value(const QGLContext *key); // Cleanup 'value' in response to a context group being destroyed. void cleanup(const QGLContext *ctx, void *value); - // Remove this resource from the group's resource list. - void remove(const QGLContext *ctx); + virtual void freeResource(void *value) = 0; private: - FreeFunc free; + QList m_groups; QAtomicInt active; }; @@ -720,6 +718,26 @@ private: int gl_extensions_length; }; + +// this is a class that wraps a QThreadStorage object for storing +// thread local instances of the GL 1 and GL 2 paint engines + +template +class QGLEngineThreadStorage +{ +public: + QPaintEngine *engine() { + QPaintEngine *localEngine = storage.localData(); + if (!localEngine) { + localEngine = new T; + storage.setLocalData(localEngine); + } + return localEngine; + } + +private: + QThreadStorage storage; +}; QT_END_NAMESPACE #endif // QGL_P_H diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index deffc20..fe60e83 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -984,11 +984,11 @@ QImage QGLFramebufferObject::toImage() const } #if !defined(QT_OPENGL_ES_1) -Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine) +Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_buffer_2_engine) #endif #ifndef QT_OPENGL_ES_2 -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) +Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_buffer_engine) #endif /*! \reimp */ @@ -1002,7 +1002,7 @@ QPaintEngine *QGLFramebufferObject::paintEngine() const #if !defined (QT_OPENGL_ES_2) if (qt_gl_preferGL2Engine()) { #endif - QPaintEngine *engine = qt_buffer_2_engine(); + QPaintEngine *engine = qt_buffer_2_engine()->engine(); if (engine->isActive() && engine->paintDevice() != this) { d->engine = new QGL2PaintEngineEx; return d->engine; @@ -1014,7 +1014,7 @@ QPaintEngine *QGLFramebufferObject::paintEngine() const #endif #if !defined(QT_OPENGL_ES_2) - QPaintEngine *engine = qt_buffer_engine(); + QPaintEngine *engine = qt_buffer_engine()->engine(); if (engine->isActive() && engine->paintDevice() != this) { d->engine = new QOpenGLPaintEngine; return d->engine; diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index 9a8b243..e5aed44 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -388,25 +388,26 @@ bool QGLPixelBuffer::isValid() const } #if !defined(QT_OPENGL_ES_1) -Q_GLOBAL_STATIC(QGL2PaintEngineEx, qt_buffer_2_engine) +Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_buffer_2_engine) #endif #ifndef QT_OPENGL_ES_2 -Q_GLOBAL_STATIC(QOpenGLPaintEngine, qt_buffer_engine) +Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_buffer_engine) #endif /*! \reimp */ QPaintEngine *QGLPixelBuffer::paintEngine() const { + return qt_qgl_paint_engine(); #if defined(QT_OPENGL_ES_1) - return qt_buffer_engine(); + return qt_buffer_engine()->engine(); #elif defined(QT_OPENGL_ES_2) - return qt_buffer_2_engine(); + return qt_buffer_2_engine()->engine(); #else if (qt_gl_preferGL2Engine()) - return qt_buffer_2_engine(); + return qt_buffer_2_engine()->engine(); else - return qt_buffer_engine(); + return qt_buffer_engine()->engine(); #endif } diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index bfa5ef1..011869e 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -337,12 +337,16 @@ private: QList QGLBlurTextureCache::blurTextureCaches; -static void QGLBlurTextureCache_free(void *ptr) +class QGLBlurCacheResource : public QGLContextResource { - delete reinterpret_cast(ptr); -} +public: + void freeResource(void *value) + { + delete reinterpret_cast(value); + } +}; -Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_blur_texture_caches, (QGLBlurTextureCache_free)) +Q_GLOBAL_STATIC(QGLBlurCacheResource, qt_blur_texture_caches) QGLBlurTextureCache::QGLBlurTextureCache() : timerId(0) -- cgit v0.12 From 83abd5b9c8cf2b069c6b065ad37c93afe59d5d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Jun 2010 13:12:13 +0200 Subject: Make the GL texture cache share textures between shared contexts. Up until now the GL 2 engine texture cache did not share glyph textures between sharing contexts, which is bad. Fix this by using the context group's context as the cache key. --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 260e797..fe0d6c9 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1453,12 +1453,13 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp QOpenGL2PaintEngineState *s = q->state(); + void *cacheKey = const_cast(QGLContextPrivate::contextGroup(ctx)->context()); QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) staticTextItem->fontEngine->glyphCache(ctx, glyphType, QTransform()); + (QGLTextureGlyphCache *) staticTextItem->fontEngine->glyphCache(cacheKey, glyphType, QTransform()); if (!cache || cache->cacheType() != glyphType) { cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); cache->insert(ctx, cache); - staticTextItem->fontEngine->setGlyphCache(ctx, cache); + staticTextItem->fontEngine->setGlyphCache(cacheKey, cache); } cache->setPaintEnginePrivate(this); -- cgit v0.12 From 0441db10ddf2bd9141d7801e1e53c9cbdde2ebc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 28 Apr 2010 14:36:25 +0200 Subject: Remove the DDS texture cache. It has no practical use and is a leftover from when pixmap/image textures and dds textures used the same cache. --- src/opengl/qgl.cpp | 26 -------------------------- src/opengl/qgl_p.h | 3 --- 2 files changed, 29 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 753a984..3e556e0 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2089,20 +2089,10 @@ void QGLContextPrivate::syncGlState() GLuint QGLContext::bindTexture(const QString &fileName) { - Q_D(QGLContext); - QGLDDSCache *dds_cache = &(d->group->m_dds_cache); - QGLDDSCache::const_iterator it = dds_cache->constFind(fileName); - if (it != dds_cache->constEnd()) { - glBindTexture(GL_TEXTURE_2D, it.value()); - return it.value(); - } - QGLTexture texture(this); QSize size = texture.bindCompressedTexture(fileName); if (!size.isValid()) return 0; - - dds_cache->insert(fileName, texture.id); return texture.id; } @@ -2728,24 +2718,8 @@ GLuint QGLContext::bindTexture(const QPixmap &pixmap, QMacCompatGLenum target, Q */ void QGLContext::deleteTexture(GLuint id) { - Q_D(QGLContext); - if (QGLTextureCache::instance()->remove(this, id)) return; - - // check the DDS cache if the texture wasn't found in the pixmap/image - // cache - QGLDDSCache *dds_cache = &(d->group->m_dds_cache); - QList ddsKeys = dds_cache->keys(); - for (int i = 0; i < ddsKeys.size(); ++i) { - GLuint texture = dds_cache->value(ddsKeys.at(i)); - if (id == texture) { - dds_cache->remove(ddsKeys.at(i)); - break; - } - } - - // Finally, actually delete the texture ID glDeleteTextures(1, &id); } diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 1399359..9b1856e 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -209,8 +209,6 @@ public: class QGLContextResource; class QGLSharedResourceGuard; -typedef QHash QGLDDSCache; - // QGLContextPrivate has the responsibility of creating context groups. // QGLContextPrivate maintains the reference counter and destroys // context groups when needed. @@ -239,7 +237,6 @@ private: QHash m_resources; QGLSharedResourceGuard *m_guards; // double-linked list of active guards. QAtomicInt m_refs; - QGLDDSCache m_dds_cache; void cleanupResources(const QGLContext *ctx); -- cgit v0.12 From 6451874792f515e5e30597e815a21a3a6cc325bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 30 Apr 2010 13:03:12 +0200 Subject: QGLPixelBuffer should manage its own paint engines. --- src/opengl/qgl.cpp | 2 -- src/opengl/qglpixelbuffer.cpp | 1 - 2 files changed, 3 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3e556e0..74efb34 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -4035,8 +4035,6 @@ bool QGLWidget::event(QEvent *e) } #if defined(Q_WS_X11) - // prevents X errors on some systems, where we get a flush to a - // hidden widget if (e->type() == QEvent::ParentChange) { // if we've reparented a window that has the current context // bound, we need to rebind that context to the new window id diff --git a/src/opengl/qglpixelbuffer.cpp b/src/opengl/qglpixelbuffer.cpp index e5aed44..3d9cd21 100644 --- a/src/opengl/qglpixelbuffer.cpp +++ b/src/opengl/qglpixelbuffer.cpp @@ -398,7 +398,6 @@ Q_GLOBAL_STATIC(QGLEngineThreadStorage, qt_buffer_engine) /*! \reimp */ QPaintEngine *QGLPixelBuffer::paintEngine() const { - return qt_qgl_paint_engine(); #if defined(QT_OPENGL_ES_1) return qt_buffer_engine()->engine(); #elif defined(QT_OPENGL_ES_2) -- cgit v0.12 From decda7ea196b610ab1d70345cb89a4a67bfd1e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 30 Apr 2010 13:17:14 +0200 Subject: Unnecessary alloc + remove unused headers. --- src/opengl/qgl_p.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 9b1856e..acd799a 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -471,8 +471,6 @@ private: QGLContext *m_ctx; }; -#include -#include class QGLTexture { public: QGLTexture(QGLContext *ctx = 0, GLuint tx_id = 0, GLenum tx_target = GL_TEXTURE_2D, @@ -724,11 +722,9 @@ class QGLEngineThreadStorage { public: QPaintEngine *engine() { - QPaintEngine *localEngine = storage.localData(); - if (!localEngine) { + QPaintEngine *&localEngine = storage.localData(); + if (!localEngine) localEngine = new T; - storage.setLocalData(localEngine); - } return localEngine; } -- cgit v0.12 From 778ee2e9a2db3f3a1bc9d282356798baa77f6efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 30 Apr 2010 15:33:26 +0200 Subject: Add an application attribute to control XInitThreads(). In order to make Xlib thread-safe XInitThreads() needs to be the first Xlib call issued. This attribute controls this behavior. Having Xlib thread-safe will most likely incur some overhead, which is why this is not done by default. --- src/corelib/global/qnamespace.h | 1 + src/corelib/global/qnamespace.qdoc | 4 ++++ src/gui/image/qpixmap.cpp | 3 +-- src/gui/kernel/qapplication_x11.cpp | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index a9c56f6..84ab567 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -530,6 +530,7 @@ public: AA_DontUseNativeMenuBar = 6, AA_MacDontSwapCtrlAndMeta = 7, AA_S60DontConstructApplicationPanes = 8, + AA_X11InitThreads = 9, // Add new attributes before this line AA_AttributeCount diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 7eae3a5..ce1176d 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -170,6 +170,10 @@ whole lifetime. This attribute must be set before QApplication is constructed. + \value AA_X11InitThreads Calls XInitThreads() as part of the QApplication + construction in order to make Xlib calls thread-safe. + + \omitvalue AA_AttributeCount */ diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index e630e80..a2b0b95 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -94,13 +94,12 @@ Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap) static bool qt_pixmap_thread_test() { - return true; if (!qApp) { qFatal("QPixmap: Must construct a QApplication before a QPaintDevice"); return false; } #ifndef Q_WS_WIN - if (qApp->thread() != QThread::currentThread()) { + if (!QApplication::testAttribute(Qt::AA_X11InitThreads) && qApp->thread() != QThread::currentThread()) { qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread"); return false; } diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 9d5a7c0..5e212ca 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -1710,6 +1710,9 @@ void qt_init(QApplicationPrivate *priv, int, } else { // Qt controls everything (default) + if (QApplication::testAttribute(Qt::AA_X11InitThreads)) + XInitThreads(); + // Set application name and class char *app_class = 0; if (argv && argv[0]) { -- cgit v0.12 From 76a14c8254f4f8beb16de897f31bab13dc7609a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 30 Apr 2010 15:53:06 +0200 Subject: Check Qt::AA_X11InitThreads to determine pixmap usage in threads. --- src/gui/painting/qpainter.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index ec2aca4..8ac40ee 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -155,6 +155,10 @@ static bool qt_painter_thread_test(int devType, const char *what, bool extraCond #endif break; default: +#ifdef Q_WS_X11 + if (QApplication::testAttribute(Qt::AA_X11InitThreads)) + return true; +#endif if (!extraCondition && QThread::currentThread() != qApp->thread()) { qWarning("QPainter: It is not safe to use %s outside the GUI thread", what); return false; @@ -5252,8 +5256,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) return; #ifndef QT_NO_DEBUG - if (d->engine->type() != QPaintEngine::OpenGL2) - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), "drawPixmap()"); #endif if (d->extended) { @@ -5323,8 +5326,7 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) if (!d->engine || pm.isNull()) return; #ifndef QT_NO_DEBUG - if (d->engine->type() != QPaintEngine::OpenGL2) - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), "drawPixmap()"); #endif qreal x = r.x(); @@ -6668,8 +6670,7 @@ void QPainter::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPo return; #ifndef QT_NO_DEBUG - if (d->engine->type() != QPaintEngine::OpenGL2) - qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()"); + qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()"); #endif qreal sw = pixmap.width(); -- cgit v0.12 From b2de72a51124333b639fdfbda829f54088dff838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 17 Jun 2010 14:46:27 +0200 Subject: Rework the internal GL resource system yet again. Instead of having to sub-class QGLContextResource, we now have two template classes: 1. 'QGLContextResource' to handle context specific resources that are *not* shared in a group, even though the context itself is in a sharing group 2. 'QGLContextGroupResource' to handle resources shared in a context group. Classes used as the template class type must have a constructor with the following signature: T(const QGLContext *); The resources that the templates wrap are freed up when the context or context group it is tied to is destroyed. The resource is also freed when the QGLContextResource object is destroyed, which might lead to context switches, depending on where and in how many non-sharing contexts the resource is used. The templates wrap some boiler plate code that were common for all the use cases. --- .../gl2paintengineex/qglengineshadermanager.cpp | 49 +------- src/opengl/gl2paintengineex/qglgradientcache.cpp | 19 +-- src/opengl/gl2paintengineex/qglgradientcache_p.h | 4 +- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 2 +- src/opengl/qgl.cpp | 34 +++-- src/opengl/qgl.h | 1 + src/opengl/qgl_p.h | 137 ++++++++++++++++++--- src/opengl/qglpixmapfilter.cpp | 23 +--- 8 files changed, 161 insertions(+), 108 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 888bac9..c06bb3c 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -48,65 +48,27 @@ QT_BEGIN_NAMESPACE -class QGLSharedShaderResource : public QGLContextResource -{ -public: - ~QGLSharedShaderResource() { - qDebug() << "~QGLSharedShaderResource cleaned up" << hex << this; - } - - void freeResource(void *value) - { - qDebug() << "Context destroyed:"; - qDebug() << " -> deleting shader cache" << hex << value; - delete reinterpret_cast(value); - } -}; - -class QGLThreadLocalShaders -{ -public: - QGLEngineSharedShaders *shadersForContext(const QGLContext *context) { - QGLEngineSharedShaders *shaders = reinterpret_cast(m_resource.value(context)); - if (!shaders) { - QGLShareContextScope scope(context); - shaders = new QGLEngineSharedShaders(context); - qDebug() << " -> new shader cache for context:" << hex << context << "cache:" << shaders; - m_resource.insert(context, shaders); - } - return shaders; - } - - ~QGLThreadLocalShaders() { - qDebug() << "Thread exit:"; - qDebug() << "~QGLThreadLocalShaders() for thread:" << hex << QThread::currentThread(); - } - -private: - QGLSharedShaderResource m_resource; -}; - class QGLShaderStorage { public: QGLEngineSharedShaders *shadersForThread(const QGLContext *context) { - QGLThreadLocalShaders *&shaders = m_storage.localData(); + QGLContextGroupResource *&shaders = m_storage.localData(); if (!shaders) { qDebug() << "New thread storage for:" << hex << QThread::currentThread(); - shaders = new QGLThreadLocalShaders; + shaders = new QGLContextGroupResource(); } - return shaders->shadersForContext(context); + return shaders->value(context); } private: - QThreadStorage m_storage; + QThreadStorage *> m_storage; }; Q_GLOBAL_STATIC(QGLShaderStorage, qt_shader_storage); QGLEngineSharedShaders *QGLEngineSharedShaders::shadersForContext(const QGLContext *context) { - return reinterpret_cast(qt_shader_storage()->shadersForThread(context)); + return qt_shader_storage()->shadersForThread(context); } const char* QGLEngineSharedShaders::qShaderSnippets[] = { @@ -271,6 +233,7 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) QGLEngineSharedShaders::~QGLEngineSharedShaders() { + qDebug() << "####### ~QGLEngineSharedShaders() ##########"; qDeleteAll(shaders); shaders.clear(); diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp index a0a3f8f..f1b095d 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp @@ -46,26 +46,11 @@ QT_BEGIN_NAMESPACE -class QGLGradientCacheResource : public QGLContextResource -{ -public: - void freeResource(void *value) - { - delete reinterpret_cast(value); - } -}; - -Q_GLOBAL_STATIC(QGLGradientCacheResource, qt_gradient_caches) +Q_GLOBAL_STATIC(QGLContextGroupResource, qt_gradient_caches) QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) { - QGL2GradientCache *p = reinterpret_cast(qt_gradient_caches()->value(context)); - if (!p) { - QGLShareContextScope scope(context); - p = new QGL2GradientCache; - qt_gradient_caches()->insert(context, p); - } - return p; + return qt_gradient_caches()->value(context); } void QGL2GradientCache::cleanCache() { diff --git a/src/opengl/gl2paintengineex/qglgradientcache_p.h b/src/opengl/gl2paintengineex/qglgradientcache_p.h index 0a5f846..8ecb34e 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache_p.h +++ b/src/opengl/gl2paintengineex/qglgradientcache_p.h @@ -75,8 +75,8 @@ class QGL2GradientCache public: static QGL2GradientCache *cacheForContext(const QGLContext *context); - QGL2GradientCache() { } - ~QGL2GradientCache() {cleanCache();} + QGL2GradientCache(const QGLContext *) {} + ~QGL2GradientCache() { cleanCache(); } GLuint getBuffer(const QGradient &gradient, qreal opacity); inline int paletteSize() const { return 1024; } diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 710a12d..1a78eed 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE class QGL2PaintEngineExPrivate; -class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QGLContextResource, public QImageTextureGlyphCache +class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QGLContextGroupResourceBase, public QImageTextureGlyphCache { public: QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 74efb34..6755d93 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2029,6 +2029,9 @@ QGLContext::~QGLContext() QGLTextureCache::instance()->removeContextTextures(this); qDebug() << "~QGLContext(): about to clean up" << hex << this; + // clean up resources specific to this context + d_ptr->cleanup(); + // clean up resources belonging to this context's group d_ptr->group->cleanupResources(this); QGLSignalProxy::instance()->emitAboutToDestroyContext(this); @@ -2037,6 +2040,10 @@ QGLContext::~QGLContext() void QGLContextPrivate::cleanup() { + QHash::ConstIterator it; + for (it = m_resources.begin(); it != m_resources.end(); ++it) + it.key()->freeResource(it.value()); + m_resources.clear(); } #define ctx q_ptr @@ -5282,15 +5289,17 @@ void QGLContextGroup::removeShare(const QGLContext *context) { group->m_shares.clear(); } -QGLContextResource::QGLContextResource() +QGLContextGroupResourceBase::QGLContextGroupResourceBase() : active(0) { } -QGLContextResource::~QGLContextResource() +QGLContextGroupResourceBase::~QGLContextGroupResourceBase() { + qDebug() << "~QGLContextGroupResourceBase()" << hex << this << "group size:" << m_groups.size(); for (int i = 0; i < m_groups.size(); ++i) { m_groups.at(i)->m_resources.remove(this); + qDebug() << " ->removing from group resource list:" << hex << this; active.deref(); } #ifndef QT_NO_DEBUG @@ -5302,24 +5311,24 @@ QGLContextResource::~QGLContextResource() #endif } -void QGLContextResource::insert(const QGLContext *key, void *value) +void QGLContextGroupResourceBase::insert(const QGLContext *context, void *value) { - QGLContextGroup *group = QGLContextPrivate::contextGroup(key); + QGLContextGroup *group = QGLContextPrivate::contextGroup(context); Q_ASSERT(!group->m_resources.contains(this)); group->m_resources.insert(this, value); m_groups.append(group); active.ref(); } -void *QGLContextResource::value(const QGLContext *key) +void *QGLContextGroupResourceBase::value(const QGLContext *context) { - QGLContextGroup *group = QGLContextPrivate::contextGroup(key); + QGLContextGroup *group = QGLContextPrivate::contextGroup(context); return group->m_resources.value(this, 0); } -void QGLContextResource::cleanup(const QGLContext *ctx, void *value) +void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx, void *value) { - qDebug() << "QGLContextResource::cleanup() this:" << hex << this << "ctx:" << ctx << "thread:" << (void *)QThread::currentThread(); + qDebug() << "QGLContextGroupResourceBase::cleanup() this:" << hex << this << "ctx:" << ctx << "thread:" << (void *)QThread::currentThread(); QGLShareContextScope scope(ctx); freeResource(value); active.deref(); @@ -5328,17 +5337,18 @@ void QGLContextResource::cleanup(const QGLContext *ctx, void *value) m_groups.removeOne(group); } -void QGLContextGroup::cleanupResources(const QGLContext *ctx) +void QGLContextGroup::cleanupResources(const QGLContext *context) { - qDebug() << "QGLContextGroup::cleanupResources() for ctx:" << hex << ctx << "shares:" << m_shares.size() << "res:" << m_resources.size(); + qDebug() << "QGLContextGroup::cleanupResources() for ctx:" << hex << context + << "shares:" << m_shares.size() << "res:" << m_resources.size(); // If there are still shares, then no cleanup to be done yet. if (m_shares.size() > 1) return; // Iterate over all resources and free each in turn. - QHash::ConstIterator it; + QHash::ConstIterator it; for (it = m_resources.begin(); it != m_resources.end(); ++it) - it.key()->cleanup(ctx, it.value()); + it.key()->cleanup(context, it.value()); } QGLSharedResourceGuard::~QGLSharedResourceGuard() diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index f0b36f7..d354f92 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -436,6 +436,7 @@ private: friend class QGLWidgetGLPaintDevice; friend class QX11GLPixmapData; friend class QX11GLSharedContexts; + friend class QGLContextResourceBase; private: Q_DISABLE_COPY(QGLContext) }; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index acd799a..3be30de 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -206,7 +206,7 @@ public: #endif }; -class QGLContextResource; +class QGLContextGroupResourceBase; class QGLSharedResourceGuard; // QGLContextPrivate has the responsibility of creating context groups. @@ -234,7 +234,7 @@ private: QGLExtensionFuncs m_extensionFuncs; const QGLContext *m_context; // context group's representative QList m_shares; - QHash m_resources; + QHash m_resources; QGLSharedResourceGuard *m_guards; // double-linked list of active guards. QAtomicInt m_refs; @@ -242,7 +242,7 @@ private: friend class QGLContext; friend class QGLContextPrivate; - friend class QGLContextResource; + friend class QGLContextGroupResourceBase; }; // Get the context that resources for "ctx" will transfer to once @@ -307,6 +307,8 @@ class QGLTexture; // all the GL2 engine uses: #define QT_GL_VERTEX_ARRAY_TRACKED_COUNT 3 +class QGLContextResourceBase; + class QGLContextPrivate { Q_DECLARE_PUBLIC(QGLContext) @@ -398,6 +400,7 @@ public: GLuint current_fbo; GLuint default_fbo; QPaintEngine *active_engine; + QHash m_resources; bool vertexAttributeArraysEnabledState[QT_GL_VERTEX_ARRAY_TRACKED_COUNT]; @@ -606,24 +609,130 @@ inline GLenum qt_gl_preferredTextureTarget() #endif } -// One resource per group of shared contexts. -class Q_OPENGL_EXPORT QGLContextResource +/* + Base for resources that are shared in a context group. +*/ +class QGLContextGroupResourceBase { public: - QGLContextResource(); - virtual ~QGLContextResource(); - // Set resource 'value' for 'key' and all its shared contexts. - void insert(const QGLContext *key, void *value); - // Return resource for 'key' or a shared context. - void *value(const QGLContext *key); - // Cleanup 'value' in response to a context group being destroyed. - void cleanup(const QGLContext *ctx, void *value); + QGLContextGroupResourceBase(); + virtual ~QGLContextGroupResourceBase(); + void insert(const QGLContext *context, void *value); + void *value(const QGLContext *context); + void cleanup(const QGLContext *context, void *value); virtual void freeResource(void *value) = 0; -private: + +protected: QList m_groups; + +private: QAtomicInt active; }; +/* + The QGLContextGroupResource template is used to manage a resource + for a group of sharing GL contexts. When the last context in the + group is destroyed, or when the QGLContextGroupResource object + itself is destroyed (implies potential context switches), the + resource will be freed. + + The class used as the template class type needs to have a + constructor with the following signature: + T(const QGLContext *); +*/ +template +class QGLContextGroupResource : public QGLContextGroupResourceBase +{ +public: + ~QGLContextGroupResource() { + for (int i = 0; i < m_groups.size(); ++i) { + const QGLContext *context = m_groups.at(i)->context(); + T *resource = reinterpret_cast(QGLContextGroupResourceBase::value(context)); + if (resource) { + QGLShareContextScope scope(context); + delete resource; + } + } + } + + T *value(const QGLContext *context) { + T *resource = reinterpret_cast(QGLContextGroupResourceBase::value(context)); + if (!resource) { + resource = new T(context); + insert(context, resource); + } + return resource; + } + +protected: + void freeResource(void *resource) { + delete reinterpret_cast(resource); + } +}; + +/* + Base for resources that are context specific. +*/ +class QGLContextResourceBase +{ +public: + virtual ~QGLContextResourceBase() { + for (int i = 0; i < m_contexts.size(); ++i) + m_contexts.at(i)->d_ptr->m_resources.remove(this); + } + + void insert(const QGLContext *context, void *value) { + context->d_ptr->m_resources.insert(this, value); + } + + void *value(const QGLContext *context) { + return context->d_ptr->m_resources.value(this, 0); + } + virtual void freeResource(void *value) = 0; + +protected: + QList m_contexts; +}; + +/* + The QGLContextResource template is used to manage a resource for a + single GL context. Just before the context is destroyed (while it's + still the current context), or when the QGLContextResource object + itself is destroyed (implies potential context switches), the + resource will be freed. The class used as the template class type + needs to have a constructor with the following signature: T(const + QGLContext *); +*/ +template +class QGLContextResource : public QGLContextResourceBase +{ +public: + ~QGLContextResource() { + for (int i = 0; i < m_contexts.size(); ++i) { + const QGLContext *context = m_contexts.at(i); + T *resource = reinterpret_cast(QGLContextResourceBase::value(context)); + if (resource) { + QGLShareContextScope scope(context); + delete resource; + } + } + } + + T *value(const QGLContext *context) { + T *resource = reinterpret_cast(QGLContextResourceBase::value(context)); + if (!resource) { + resource = new T(context); + insert(context, resource); + } + return resource; + } + +protected: + void freeResource(void *resource) { + delete reinterpret_cast(resource); + } +}; + // Put a guard around a GL object identifier and its context. // When the context goes away, a shared context will be used // in its place. If there are no more shared contexts, then diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp index 011869e..68586c1 100644 --- a/src/opengl/qglpixmapfilter.cpp +++ b/src/opengl/qglpixmapfilter.cpp @@ -315,7 +315,7 @@ class QGLBlurTextureCache : public QObject public: static QGLBlurTextureCache *cacheForContext(const QGLContext *context); - QGLBlurTextureCache(); + QGLBlurTextureCache(const QGLContext *); ~QGLBlurTextureCache(); QGLBlurTextureInfo *takeBlurTextureInfo(const QPixmap &pixmap); @@ -336,19 +336,9 @@ private: }; QList QGLBlurTextureCache::blurTextureCaches; +Q_GLOBAL_STATIC(QGLContextGroupResource, qt_blur_texture_caches) -class QGLBlurCacheResource : public QGLContextResource -{ -public: - void freeResource(void *value) - { - delete reinterpret_cast(value); - } -}; - -Q_GLOBAL_STATIC(QGLBlurCacheResource, qt_blur_texture_caches) - -QGLBlurTextureCache::QGLBlurTextureCache() +QGLBlurTextureCache::QGLBlurTextureCache(const QGLContext *) : timerId(0) { cache.setMaxCost(4 * 1024 * 1024); @@ -370,12 +360,7 @@ void QGLBlurTextureCache::timerEvent(QTimerEvent *) QGLBlurTextureCache *QGLBlurTextureCache::cacheForContext(const QGLContext *context) { - QGLBlurTextureCache *p = reinterpret_cast(qt_blur_texture_caches()->value(context)); - if (!p) { - p = new QGLBlurTextureCache; - qt_blur_texture_caches()->insert(context, p); - } - return p; + return qt_blur_texture_caches()->value(context); } QGLBlurTextureInfo *QGLBlurTextureCache::takeBlurTextureInfo(const QPixmap &pixmap) -- cgit v0.12 From 7348a762379bbc615194281806949e7fbac503a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 17 Jun 2010 15:57:03 +0200 Subject: Clarification regarding the WA_X11InitThreads flag. --- src/corelib/global/qnamespace.qdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index ce1176d..19742e7 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -171,7 +171,8 @@ constructed. \value AA_X11InitThreads Calls XInitThreads() as part of the QApplication - construction in order to make Xlib calls thread-safe. + construction in order to make Xlib calls thread-safe. This + attribute must be set before QApplication is constructed. \omitvalue AA_AttributeCount -- cgit v0.12 From 35f0729a36f1562abc4b3bb12e35d86afdd19a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Jun 2010 13:15:49 +0200 Subject: Clean up debug output. --- .../gl2paintengineex/qglengineshadermanager.cpp | 13 +++++++++---- .../gl2paintengineex/qtextureglyphcache_gl.cpp | 8 ++++++-- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 5 ++++- src/opengl/qgl.cpp | 20 ++++++++++++++------ 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index c06bb3c..4b5f53e 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -46,6 +46,8 @@ #include #endif +// #define QT_GL_SHARED_SHADER_DEBUG + QT_BEGIN_NAMESPACE class QGLShaderStorage @@ -53,10 +55,8 @@ class QGLShaderStorage public: QGLEngineSharedShaders *shadersForThread(const QGLContext *context) { QGLContextGroupResource *&shaders = m_storage.localData(); - if (!shaders) { - qDebug() << "New thread storage for:" << hex << QThread::currentThread(); + if (!shaders) shaders = new QGLContextGroupResource(); - } return shaders->value(context); } @@ -229,11 +229,16 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) << simpleShaderProg->log(); } +#ifdef QT_GL_SHARED_SHADER_DEBUG + qDebug(" -> QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread()); +#endif } QGLEngineSharedShaders::~QGLEngineSharedShaders() { - qDebug() << "####### ~QGLEngineSharedShaders() ##########"; +#ifdef QT_GL_SHARED_SHADER_DEBUG + qDebug(" -> ~QGLEngineSharedShaders() %p for thread %p.", this, QThread::currentThread()); +#endif qDeleteAll(shaders); shaders.clear(); diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 001a09e..290c57e 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -66,12 +66,16 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngin if (!ctx->d_ptr->workaround_brokenFBOReadBack && pex != 0) glGenFramebuffers(1, &m_fbo); - fprintf(stderr, "## QGLTextureGlyphCache(): ctx: %p - this: %p\n", ctx, this); +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, ctx); +#endif } QGLTextureGlyphCache::~QGLTextureGlyphCache() { - fprintf(stderr, "## ~QGLTextureGlyphCache(): context: %p - this: %p\n", ctx, this); +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug(" -> ~QGLTextureGlyphCache() %p.", this); +#endif } void QGLTextureGlyphCache::createTextureData(int width, int height) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 1a78eed..04d1354 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -57,6 +57,7 @@ #include #include +// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG QT_BEGIN_NAMESPACE @@ -87,7 +88,9 @@ public: } void freeResource(void *) { - qDebug() << "QGLTextureGlyphCache::freeResource():" << this << "ctx:" << ctx; +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug("Freeing glyph cache resource %p for context %p.", this, ctx); +#endif // At this point, the context group is made current, so it's safe to // release resources without a makeCurrent() call diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 6755d93..19ab51d 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -94,6 +94,8 @@ #include +// #define QT_GL_CONTEXT_RESOURCE_DEBUG + QT_BEGIN_NAMESPACE #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) @@ -2028,7 +2030,6 @@ QGLContext::~QGLContext() // remove any textures cached in this context QGLTextureCache::instance()->removeContextTextures(this); - qDebug() << "~QGLContext(): about to clean up" << hex << this; // clean up resources specific to this context d_ptr->cleanup(); // clean up resources belonging to this context's group @@ -5292,14 +5293,18 @@ void QGLContextGroup::removeShare(const QGLContext *context) { QGLContextGroupResourceBase::QGLContextGroupResourceBase() : active(0) { +#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG + qDebug("Creating context group resource object %p.", this); +#endif } QGLContextGroupResourceBase::~QGLContextGroupResourceBase() { - qDebug() << "~QGLContextGroupResourceBase()" << hex << this << "group size:" << m_groups.size(); +#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG + qDebug("Deleting context group resource %p. Group size: %d.", this, m_groups.size()); +#endif for (int i = 0; i < m_groups.size(); ++i) { m_groups.at(i)->m_resources.remove(this); - qDebug() << " ->removing from group resource list:" << hex << this; active.deref(); } #ifndef QT_NO_DEBUG @@ -5313,6 +5318,9 @@ QGLContextGroupResourceBase::~QGLContextGroupResourceBase() void QGLContextGroupResourceBase::insert(const QGLContext *context, void *value) { +#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG + qDebug("Inserting context group resource %p for context %p, managed by %p.", value, context, this); +#endif QGLContextGroup *group = QGLContextPrivate::contextGroup(context); Q_ASSERT(!group->m_resources.contains(this)); group->m_resources.insert(this, value); @@ -5328,7 +5336,9 @@ void *QGLContextGroupResourceBase::value(const QGLContext *context) void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx, void *value) { - qDebug() << "QGLContextGroupResourceBase::cleanup() this:" << hex << this << "ctx:" << ctx << "thread:" << (void *)QThread::currentThread(); +#ifdef QT_GL_CONTEXT_RESOURCE_DEBUG + qDebug("Cleaning up context group resource %p, for context %p in thread %p.", this, ctx, QThread::currentThread()); +#endif QGLShareContextScope scope(ctx); freeResource(value); active.deref(); @@ -5339,8 +5349,6 @@ void QGLContextGroupResourceBase::cleanup(const QGLContext *ctx, void *value) void QGLContextGroup::cleanupResources(const QGLContext *context) { - qDebug() << "QGLContextGroup::cleanupResources() for ctx:" << hex << context - << "shares:" << m_shares.size() << "res:" << m_resources.size(); // If there are still shares, then no cleanup to be done yet. if (m_shares.size() > 1) return; -- cgit v0.12 From 48ecc50d1d5cb698749df97e4ecee0f096904618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 21 Jun 2010 17:04:09 +0200 Subject: Make qt_pixmap_serial thread-safe. --- src/gui/image/qpixmap_x11.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp index 6bebefc..d61f21d 100644 --- a/src/gui/image/qpixmap_x11.cpp +++ b/src/gui/image/qpixmap_x11.cpp @@ -310,7 +310,7 @@ static int defaultScreen = -1; QPixmap member functions *****************************************************************************/ -static int qt_pixmap_serial = 0; +QBasicAtomicInt qt_pixmap_serial = Q_BASIC_ATOMIC_INITIALIZER(0); int Q_GUI_EXPORT qt_x11_preferred_pixmap_depth = 0; QX11PixmapData::QX11PixmapData(PixelType type) @@ -327,7 +327,7 @@ QPixmapData *QX11PixmapData::createCompatiblePixmapData() const void QX11PixmapData::resize(int width, int height) { - setSerialNumber(++qt_pixmap_serial); + setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1)); w = width; h = height; @@ -410,7 +410,7 @@ struct QX11AlphaDetector void QX11PixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags) { - setSerialNumber(++qt_pixmap_serial); + setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1)); w = img.width(); h = img.height(); @@ -1950,7 +1950,7 @@ QPixmap QX11PixmapData::transformed(const QTransform &transform, x11Data->hd = (Qt::HANDLE)XCreatePixmap(X11->display, RootWindow(X11->display, xinfo.screen()), w, h, d); - x11Data->setSerialNumber(++qt_pixmap_serial); + x11Data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1)); #ifndef QT_NO_XRENDER if (X11->use_xrender) { @@ -2201,7 +2201,7 @@ void QX11PixmapData::copy(const QPixmapData *data, const QRect &rect) const QX11PixmapData *x11Data = static_cast(data); - setSerialNumber(++qt_pixmap_serial); + setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1)); flags &= ~Uninitialized; xinfo = x11Data->xinfo; @@ -2321,7 +2321,7 @@ QPixmap QPixmap::fromX11Pixmap(Qt::HANDLE pixmap, QPixmap::ShareMode mode) } QX11PixmapData *data = new QX11PixmapData(depth == 1 ? QPixmapData::BitmapType : QPixmapData::PixmapType); - data->setSerialNumber(++qt_pixmap_serial); + data->setSerialNumber(qt_pixmap_serial.fetchAndAddRelaxed(1)); data->flags = QX11PixmapData::Readonly; data->share_mode = mode; data->w = width; -- cgit v0.12 From de7a1e3780c145b8721f42bb9477224b5a8ae93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 21 Jun 2010 17:04:43 +0200 Subject: Enable glyph uploads from a thread in the X11 font engine. Note: this doesn't necessarily mean it's thread-safe yet. --- src/gui/text/qfontengine_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontengine_x11.cpp b/src/gui/text/qfontengine_x11.cpp index b7e4be2..aee21f6 100644 --- a/src/gui/text/qfontengine_x11.cpp +++ b/src/gui/text/qfontengine_x11.cpp @@ -992,7 +992,7 @@ QFontEngineX11FT::QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int s face_id.filename = file_name; face_id.index = face_index; - canUploadGlyphsToServer = qApp->thread() == QThread::currentThread(); + canUploadGlyphsToServer = QApplication::testAttribute(Qt::AA_X11InitThreads) || (qApp->thread() == QThread::currentThread()); subpixelType = Subpixel_None; if (antialias) { -- cgit v0.12 From 10ac24c98ea7f2738662be91fda7feec7f322dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 22 Jun 2010 12:34:07 +0200 Subject: The group pointer should no longer be a part of the 64 bit int. The group is now a proper part of the QGLTextureCacheKey, and it's no longer necessary with this hack. --- src/opengl/qgl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 19ab51d..1f2a886 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -2235,7 +2235,7 @@ QImage QGLContextPrivate::convertToGLFormat(const QImage &image, bool force_prem QGLTexture *QGLContextPrivate::bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) { - const qint64 key = image.cacheKey() | (qint64) group; + const qint64 key = image.cacheKey(); QGLTexture *texture = textureCacheLookup(key, target); if (texture) { glBindTexture(target, texture->id); @@ -2508,7 +2508,7 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target, Q_UNUSED(q); #endif - const qint64 key = pixmap.cacheKey() | (qint64) group; + const qint64 key = pixmap.cacheKey(); QGLTexture *texture = textureCacheLookup(key, target); if (texture) { glBindTexture(target, texture->id); -- cgit v0.12 From e11af338a0d0e96a8100d0e78cc42e67e1447864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 23 Jun 2010 16:04:28 +0200 Subject: Rework how QGLTextureGlyphCache makes use of the resource system. Separate out the GL objects (the texture and the fbo) that needs to be tracked into a QGLGlyphTexture structure and make that accessible via a QGLContextGroupResource object. --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 1 - .../gl2paintengineex/qtextureglyphcache_gl.cpp | 45 ++++++----- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 86 ++++++++++++++-------- src/opengl/qgl.h | 1 + 4 files changed, 77 insertions(+), 56 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fe0d6c9..756180f 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1458,7 +1458,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp (QGLTextureGlyphCache *) staticTextItem->fontEngine->glyphCache(cacheKey, glyphType, QTransform()); if (!cache || cache->cacheType() != glyphType) { cache = new QGLTextureGlyphCache(ctx, glyphType, QTransform()); - cache->insert(ctx, cache); staticTextItem->fontEngine->setGlyphCache(cacheKey, cache); } diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 290c57e..b4dc4fa 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -54,21 +54,12 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) : QImageTextureGlyphCache(type, matrix) - , ctx(context) - , m_width(0) - , m_height(0) + , ctx(0) { - // broken FBO readback is a bug in the SGX 1.3 and 1.4 drivers for the N900 where - // copying between FBO's is broken if the texture is either GL_ALPHA or POT. The - // workaround is to use a system-memory copy of the glyph cache for this device. - // Switching to NPOT and GL_RGBA would both cost a lot more graphics memory and - // be slower, so that is not desireable. - if (!ctx->d_ptr->workaround_brokenFBOReadBack && pex != 0) - glGenFramebuffers(1, &m_fbo); - #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, ctx); #endif + setContext(context); } QGLTextureGlyphCache::~QGLTextureGlyphCache() @@ -78,6 +69,12 @@ QGLTextureGlyphCache::~QGLTextureGlyphCache() #endif } +void QGLTextureGlyphCache::setContext(const QGLContext *context) +{ + ctx = context; + m_h = 0; +} + void QGLTextureGlyphCache::createTextureData(int width, int height) { if (ctx == 0) { @@ -97,11 +94,12 @@ void QGLTextureGlyphCache::createTextureData(int width, int height) if (height < 16) height = 16; - glGenTextures(1, &m_texture); - glBindTexture(GL_TEXTURE_2D, m_texture); + QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx); + glGenTextures(1, &glyphTexture->m_texture); + glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture); - m_width = width; - m_height = height; + glyphTexture->m_width = width; + glyphTexture->m_height = height; QVarLengthArray data(width * height); for (int i = 0; i < data.size(); ++i) @@ -122,9 +120,10 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) qWarning("QGLTextureGlyphCache::resizeTextureData: Called with no context"); return; } + QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx); - int oldWidth = m_width; - int oldHeight = m_height; + int oldWidth = glyphTexture->m_width; + int oldHeight = glyphTexture->m_height; // Make the lower glyph texture size 16 x 16. if (width < 16) @@ -132,7 +131,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) if (height < 16) height = 16; - GLuint oldTexture = m_texture; + GLuint oldTexture = glyphTexture->m_texture; createTextureData(width, height); if (pex == 0 || ctx->d_ptr->workaround_brokenFBOReadBack) { @@ -146,7 +145,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) // ### the QTextureGlyphCache API needs to be reworked to allow // ### resizeTextureData to fail - glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, glyphTexture->m_fbo); GLuint tmp_texture; glGenTextures(1, &tmp_texture); @@ -201,7 +200,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - glBindTexture(GL_TEXTURE_2D, m_texture); + glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWidth, oldHeight); @@ -223,10 +222,11 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) return; } + QGLGlyphTexture *glyphTexture = m_textureResource.value(ctx); if (pex == 0 || ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::fillTexture(c, glyph); - glBindTexture(GL_TEXTURE_2D, m_texture); + glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture); const QImage &texture = image(); const uchar *bits = texture.constBits(); bits += c.y * texture.bytesPerLine() + c.x; @@ -234,7 +234,6 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y + i, c.w, 1, GL_ALPHA, GL_UNSIGNED_BYTE, bits); bits += texture.bytesPerLine(); } - return; } @@ -264,7 +263,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph) } } - glBindTexture(GL_TEXTURE_2D, m_texture); + glBindTexture(GL_TEXTURE_2D, glyphTexture->m_texture); if (mask.format() == QImage::Format_RGB32) { glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, GL_BGRA, GL_UNSIGNED_BYTE, mask.bits()); } else { diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 04d1354..66aed91 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -63,7 +63,42 @@ QT_BEGIN_NAMESPACE class QGL2PaintEngineExPrivate; -class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QGLContextGroupResourceBase, public QImageTextureGlyphCache +struct QGLGlyphTexture +{ + QGLGlyphTexture(const QGLContext *ctx) + : m_width(0) + , m_height(0) + { + if (ctx && !ctx->d_ptr->workaround_brokenFBOReadBack) + glGenFramebuffers(1, &m_fbo); + +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug(" -> QGLGlyphTexture() %p for context %p.", this, ctx); +#endif + } + + ~QGLGlyphTexture() { + const QGLContext *ctx = QGLContext::currentContext(); +#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG + qDebug("~QGLGlyphTexture() %p for context %p.", this, ctx); +#endif + // At this point, the context group is made current, so it's safe to + // release resources without a makeCurrent() call + if (ctx) { + if (!ctx->d_ptr->workaround_brokenFBOReadBack) + glDeleteFramebuffers(1, &m_fbo); + if (m_width || m_height) + glDeleteTextures(1, &m_texture); + } + } + + GLuint m_texture; + GLuint m_fbo; + int m_width; + int m_height; +}; + +class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QImageTextureGlyphCache { public: QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix); @@ -75,46 +110,33 @@ public: virtual int glyphMargin() const; virtual int glyphPadding() const; - inline GLuint texture() const { return m_texture; } - - inline int width() const { return m_width; } - inline int height() const { return m_height; } - - inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } - - inline const QGLContext *context() const - { - return ctx; + inline GLuint texture() const { + QGLTextureGlyphCache *that = const_cast(this); + QGLGlyphTexture *glyphTexture = that->m_textureResource.value(ctx); + return glyphTexture ? glyphTexture->m_texture : 0; } - void freeResource(void *) { -#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG - qDebug("Freeing glyph cache resource %p for context %p.", this, ctx); -#endif + inline int width() const { + QGLTextureGlyphCache *that = const_cast(this); + QGLGlyphTexture *glyphTexture = that->m_textureResource.value(ctx); + return glyphTexture ? glyphTexture->m_width : 0; + } + inline int height() const { + QGLTextureGlyphCache *that = const_cast(this); + QGLGlyphTexture *glyphTexture = that->m_textureResource.value(ctx); + return glyphTexture ? glyphTexture->m_height : 0; + } - // At this point, the context group is made current, so it's safe to - // release resources without a makeCurrent() call - if (!ctx->d_ptr->workaround_brokenFBOReadBack) - glDeleteFramebuffers(1, &m_fbo); + inline void setPaintEnginePrivate(QGL2PaintEngineExPrivate *p) { pex = p; } - if (m_width || m_height) - glDeleteTextures(1, &m_texture); - } + void setContext(const QGLContext *context); + inline const QGLContext *context() const { return ctx; } private: - void cleanUpContext(); + QGLContextGroupResource m_textureResource; const QGLContext *ctx; - QGL2PaintEngineExPrivate *pex; - - GLuint m_texture; - GLuint m_fbo; - - int m_width; - int m_height; - - QGLShaderProgram *m_program; }; QT_END_NAMESPACE diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index d354f92..1bef33d 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -417,6 +417,7 @@ private: friend class QGLPixmapData; friend class QGLPixmapFilterBase; friend class QGLTextureGlyphCache; + friend class QGLGlyphTexture; friend class QGLContextGroup; friend class QGLSharedResourceGuard; friend class QGLPixmapBlurFilter; -- cgit v0.12 From 449cbdfd1b8523e721d8b86e49647495b67005e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 2 Jul 2010 15:38:07 +0200 Subject: Fix the tests for the internal GL resource system. --- src/opengl/qgl_p.h | 4 ++-- tests/auto/qgl/tst_qgl.cpp | 26 +++++++++----------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 3be30de..fd6b7f0 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -612,7 +612,7 @@ inline GLenum qt_gl_preferredTextureTarget() /* Base for resources that are shared in a context group. */ -class QGLContextGroupResourceBase +class Q_OPENGL_EXPORT QGLContextGroupResourceBase { public: QGLContextGroupResourceBase(); @@ -673,7 +673,7 @@ protected: /* Base for resources that are context specific. */ -class QGLContextResourceBase +class Q_OPENGL_EXPORT QGLContextResourceBase { public: virtual ~QGLContextResourceBase() { diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 8ee494f..c05f730 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1871,11 +1871,10 @@ void tst_QGL::destroyFBOAfterContext() #ifdef QT_BUILD_INTERNAL -class tst_QGLResource : public QObject +class tst_QGLResource { - Q_OBJECT public: - tst_QGLResource(QObject *parent = 0) : QObject(parent) {} + tst_QGLResource(const QGLContext * = 0) {} ~tst_QGLResource() { ++deletions; } static int deletions; @@ -1883,12 +1882,7 @@ public: int tst_QGLResource::deletions = 0; -static void qt_shared_test_free(void *data) -{ - delete reinterpret_cast(data); -} - -Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_shared_test, (qt_shared_test_free)) +Q_GLOBAL_STATIC(QGLContextGroupResource, qt_shared_test) #endif @@ -1908,10 +1902,9 @@ void tst_QGL::shareRegister() guard.setId(3); QVERIFY(guard.id() == 3); - // Add a resource to the first context. - tst_QGLResource *res1 = new tst_QGLResource(); - QVERIFY(!qt_shared_test()->value(glw1->context())); - qt_shared_test()->insert(glw1->context(), res1); + // Request a tst_QGLResource object for the first context. + tst_QGLResource *res1 = qt_shared_test()->value(glw1->context()); + QVERIFY(res1); QVERIFY(qt_shared_test()->value(glw1->context()) == res1); // Create another context that shares with the first. @@ -1950,10 +1943,9 @@ void tst_QGL::shareRegister() QGLSharedResourceGuard guard3(glw3->context()); guard3.setId(5); - // Add a resource to the third context. - tst_QGLResource *res3 = new tst_QGLResource(); - QVERIFY(!qt_shared_test()->value(glw3->context())); - qt_shared_test()->insert(glw3->context(), res3); + // Request a resource to the third context. + tst_QGLResource *res3 = qt_shared_test()->value(glw3->context()); + QVERIFY(res3); QVERIFY(qt_shared_test()->value(glw1->context()) == res1); QVERIFY(qt_shared_test()->value(glw2->context()) == res1); QVERIFY(qt_shared_test()->value(glw3->context()) == res3); -- cgit v0.12 From 6f0597a198912628c52f22ece63cb5d169dcaed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 2 Jul 2010 16:35:44 +0200 Subject: Remove warning. --- src/opengl/qgl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 1bef33d..b6a95e7 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -417,7 +417,7 @@ private: friend class QGLPixmapData; friend class QGLPixmapFilterBase; friend class QGLTextureGlyphCache; - friend class QGLGlyphTexture; + friend struct QGLGlyphTexture; friend class QGLContextGroup; friend class QGLSharedResourceGuard; friend class QGLPixmapBlurFilter; -- cgit v0.12 From 21158f7b31b6053b4c704f434f3f480328a0ba65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 2 Jul 2010 17:55:49 +0200 Subject: Initialize pex. This got lost in a conflict resolving session. --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index b4dc4fa..9ce5d55 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -55,6 +55,7 @@ extern Q_GUI_EXPORT bool qt_cleartype_enabled; QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngineGlyphCache::Type type, const QTransform &matrix) : QImageTextureGlyphCache(type, matrix) , ctx(0) + , pex(0) { #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, ctx); -- cgit v0.12 From 40c8aba524831dd0d2f8dfcdf07797f5c2c47f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Mon, 5 Jul 2010 14:15:57 +0200 Subject: QGLPixelBuffer should not rely on temporary QGLWidgets. Use QGLTemporaryContext instead. Also, to re-use already registered window classes for the temporary native window, make qt_reg_wndclass() register a QWidget default class if it's passed a 0 pointer. Reviewed-by: Gunnar --- src/gui/kernel/qapplication_win.cpp | 25 +++++++++++++++++-------- src/gui/painting/qpainter.cpp | 10 +++++----- src/opengl/qglpixelbuffer_win.cpp | 8 ++------ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index e10a6b0..c5340c0 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -944,26 +944,33 @@ bool qt_nograb() // application no-grab option typedef QHash WinClassNameHash; Q_GLOBAL_STATIC(WinClassNameHash, winclassNames) +// +// If 0 is passed as the widget pointer, register a window class +// for QWidget as default. This is used in QGLTemporaryContext +// during GL initialization, where we don't want to use temporary +// QWidgets or QGLWidgets, neither do we want to have separate code +// to register window classes. +// const QString qt_reg_winclass(QWidget *w) // register window class { - int flags = w->windowFlags(); + int flags = w ? w->windowFlags() : 0; int type = flags & Qt::WindowType_Mask; uint style; bool icon; QString cname; - if (qt_widget_private(w)->isGLWidget) { + if (w && qt_widget_private(w)->isGLWidget) { cname = QLatin1String("QGLWidget"); style = CS_DBLCLKS; icon = true; - } else if (flags & Qt::MSWindowsOwnDC) { + } else if (w && (flags & Qt::MSWindowsOwnDC)) { cname = QLatin1String("QWidgetOwnDC"); style = CS_DBLCLKS; #ifndef Q_WS_WINCE style |= CS_OWNDC; #endif icon = true; - } else if (type == Qt::Tool || type == Qt::ToolTip){ + } else if (w && (type == Qt::Tool || type == Qt::ToolTip)) { style = CS_DBLCLKS; if (w->inherits("QTipLabel") || w->inherits("QAlphaWidget")) { if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP @@ -978,7 +985,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class style |= CS_SAVEBITS; #endif icon = false; - } else if (type == Qt::Popup) { + } else if (w && (type == Qt::Popup)) { cname = QLatin1String("QPopup"); style = CS_DBLCLKS; #ifndef Q_WS_WINCE @@ -1049,7 +1056,10 @@ const QString qt_reg_winclass(QWidget *w) // register window class } wc.hCursor = 0; #ifndef Q_WS_WINCE - wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW); + HBRUSH brush = 0; + if (w && !qt_widget_private(w)->isGLWidget) + brush = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); + wc.hbrBackground = brush; #else wc.hbrBackground = 0; #endif @@ -1071,8 +1081,7 @@ const QString qt_reg_winclass(QWidget *w) // register window class Q_GUI_EXPORT const QString qt_getRegisteredWndClass() { - QWidget w; - return qt_reg_winclass(&w); + return qt_reg_winclass(0); } static void unregWinClasses() diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 8ac40ee..0911d4f 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -5256,7 +5256,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), "drawPixmap()", true); #endif if (d->extended) { @@ -5326,7 +5326,7 @@ void QPainter::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) if (!d->engine || pm.isNull()) return; #ifndef QT_NO_DEBUG - qt_painter_thread_test(d->device->devType(), "drawPixmap()"); + qt_painter_thread_test(d->device->devType(), "drawPixmap()", true); #endif qreal x = r.x(); @@ -5733,7 +5733,7 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) int count = qMin(glyphIndexes.size(), glyphPositions.size()); QVarLengthArray fixedPointPositions(count); for (int i=0; idrawGlyphs(glyphIndexes.data(), fixedPointPositions.data(), count); @@ -5742,7 +5742,7 @@ void QPainter::drawGlyphs(const QPointF &position, const QGlyphs &glyphs) void qt_draw_glyphs(QPainter *painter, const quint32 *glyphArray, const QPointF *positionArray, int glyphCount) -{ +{ QVarLengthArray positions(glyphCount); for (int i=0; idevice->devType(), "drawTiledPixmap()"); + qt_painter_thread_test(d->device->devType(), "drawTiledPixmap()", true); #endif qreal sw = pixmap.width(); diff --git a/src/opengl/qglpixelbuffer_win.cpp b/src/opengl/qglpixelbuffer_win.cpp index 8d0d105..df83566 100644 --- a/src/opengl/qglpixelbuffer_win.cpp +++ b/src/opengl/qglpixelbuffer_win.cpp @@ -239,8 +239,7 @@ static void qt_format_to_attrib_list(bool has_render_texture, const QGLFormat &f bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget) { - QGLWidget dmy; - dmy.makeCurrent(); // needed for wglGetProcAddress() to succeed + QGLTemporaryContext tempContext; PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC) wglGetProcAddress("wglCreatePbufferARB"); @@ -254,7 +253,7 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge if (!wglCreatePbufferARB) // assumes that if one can be resolved, all of them can return false; - dc = GetDC(dmy.winId()); + dc = wglGetCurrentDC(); Q_ASSERT(dc); PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = @@ -284,7 +283,6 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge if (num_formats == 0) { qWarning("QGLPixelBuffer: Unable to find a pixel format with pbuffer - giving up."); - ReleaseDC(dmy.winId(), dc); return false; } format = pfiToQGLFormat(dc, pixel_format); @@ -303,12 +301,10 @@ bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidge has_render_texture = false; if (!pbuf) { qWarning("QGLPixelBuffer: Unable to create pbuffer [w=%d, h=%d] - giving up.", size.width(), size.height()); - ReleaseDC(dmy.winId(), dc); return false; } } - ReleaseDC(dmy.winId(), dc); dc = wglGetPbufferDCARB(pbuf); ctx = wglCreateContext(dc); -- cgit v0.12 From 7629184953898416c5ffa302b761e1ee3f65d9ee Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 6 Jul 2010 13:28:30 +0200 Subject: Make QScriptAnalysis fit in two bytes again When the size of the "flags" variable was increased, the bit field was expanded to be three bytes. Since the "script" variable does not use its full eight bits, we reduce it by one to compensate. Reviewed-by: Simon Hausmann --- src/gui/text/qtextengine_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 908a0ec..1ec3791 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -128,7 +128,7 @@ struct Q_AUTOTEST_EXPORT QScriptAnalysis TabOrObject = Tab, Object = 7 }; - unsigned short script : 8; + unsigned short script : 7; unsigned short bidiLevel : 6; // Unicode Bidi algorithm embedding level (0-61) unsigned short flags : 3; inline bool operator == (const QScriptAnalysis &other) const { -- cgit v0.12 From 591e2a1e096618979250f062648b731367e60710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 6 Jul 2010 16:18:02 +0200 Subject: Don't call GetDC() nedlessly. It seems that the CS_OWNDC class style flag only returns the same DC when GetDC() is called in the same thread that created the window. This in turn generates a bad DC resource leak if you have a rendering thread with one or more GL context switches, so just call GetDC() when you actually need to. Reviewed-by: Kim --- src/opengl/qgl_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp index 5ab944a..52988b6 100644 --- a/src/opengl/qgl_win.cpp +++ b/src/opengl/qgl_win.cpp @@ -1283,7 +1283,7 @@ void QGLContext::makeCurrent() if (d->rc == wglGetCurrentContext() || !d->valid) // already current return; - if (d->win) { + if (d->win && !d->dc) { d->dc = GetDC(d->win); if (!d->dc) { qwglError("QGLContext::makeCurrent()", "GetDC()"); -- cgit v0.12 From e3e288fea0616126148a73a03e6fcf638a9d35bf Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Tue, 6 Jul 2010 16:59:13 +0200 Subject: fix qtconfig builds with drag and drop disabled Reviewed By: Christian --- src/gui/itemviews/qabstractitemview_p.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index ee79ee9..969553a 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -135,8 +135,9 @@ public: } void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;} - +#ifndef QT_NO_DRAGANDDROP virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index); +#endif bool droppingOnItself(QDropEvent *event, const QModelIndex &index); QWidget *editor(const QModelIndex &index, const QStyleOptionViewItem &options); -- cgit v0.12 From ab5ddda87e66e2f286ec28707ca9d1e0df94d4d8 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 7 Jul 2010 09:56:21 +1000 Subject: Make the QScriptLine bit field fit in 4 bytes again. When "leadingIncluded" was introduced, "length" was mistakenly not decremented. This commit also changes a bool in QTextEngine::LayoutData to make it part of a 1 byte bit field. Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine_p.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 908a0ec..5588cbc 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -385,7 +385,7 @@ struct Q_AUTOTEST_EXPORT QScriptLine QFixed textWidth; QFixed textAdvance; int from; - signed int length : 29; + signed int length : 28; mutable uint justified : 1; mutable uint gridfitted : 1; uint hasTrailingSpaces : 1; @@ -430,7 +430,7 @@ public: uint hasBidi : 1; uint inLayout : 1; uint memory_on_stack : 1; - bool haveCharAttributes; + uint haveCharAttributes : 1; QString string; void reallocate(int totalGlyphs); }; -- cgit v0.12 From 6d337a3dd715597aa8ec797f6aeb8f42db129a00 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 14 Jun 2010 13:23:15 +0200 Subject: Add QItemSelectionRange::operator<() Reviewed-by: Olivier Goffart Merge-Request: 688 --- src/gui/itemviews/qitemselectionmodel.h | 24 ++++ .../tst_qitemselectionmodel.cpp | 159 +++++++++++++++++++++ 2 files changed, 183 insertions(+) diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h index 436514f..e2bd06b 100644 --- a/src/gui/itemviews/qitemselectionmodel.h +++ b/src/gui/itemviews/qitemselectionmodel.h @@ -101,6 +101,30 @@ public: { return (tl == other.tl && br == other.br); } inline bool operator!=(const QItemSelectionRange &other) const { return !operator==(other); } + inline bool operator<(const QItemSelectionRange &other) const + { + // Comparing parents will compare the models, but if two equivalent ranges + // in two different models have invalid parents, they would appear the same + if (other.tl.model() == tl.model()) { + // parent has to be calculated, so we only do so once. + const QModelIndex topLeftParent = tl.parent(); + const QModelIndex otherTopLeftParent = other.tl.parent(); + if (topLeftParent == otherTopLeftParent) { + if (other.tl.row() == tl.row()) { + if (other.tl.column() == tl.column()) { + if (other.br.row() == br.row()) { + return br.column() < other.br.column(); + } + return br.row() < other.br.row(); + } + return tl.column() < other.tl.column(); + } + return tl.row() < other.tl.row(); + } + return topLeftParent < otherTopLeftParent; + } + return tl.model() < other.tl.model(); + } inline bool isValid() const { diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index bfe306d..46bd4a2 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -95,6 +95,8 @@ private slots: void QTBUG5671_layoutChangedWithAllSelected(); void QTBUG2804_layoutChangedTreeSelection(); void deselectRemovedMiddleRange(); + void rangeOperatorLessThan_data(); + void rangeOperatorLessThan(); private: QAbstractItemModel *model; @@ -2401,6 +2403,163 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange() QVERIFY(spy.size() == 1); } +static QStandardItemModel* getModel(QObject *parent) +{ + QStandardItemModel *model = new QStandardItemModel(parent); + + for (int i = 0; i < 4; ++i) { + QStandardItem *parentItem = model->invisibleRootItem(); + QList list; + for (int j = 0; j < 4; ++j) { + list.append(new QStandardItem(QString("item %1, %2").arg(i).arg(j))); + } + parentItem->appendRow(list); + parentItem = list.first(); + for (int j = 0; j < 4; ++j) { + QList list; + for (int k = 0; k < 4; ++k) { + list.append(new QStandardItem(QString("item %1, %2").arg(i).arg(j))); + } + parentItem->appendRow(list); + } + } + return model; +} + +enum Result { + LessThan, + NotLessThan, + NotEqual +}; + +Q_DECLARE_METATYPE(Result); + +void tst_QItemSelectionModel::rangeOperatorLessThan_data() +{ + QTest::addColumn("parent1"); + QTest::addColumn("top1"); + QTest::addColumn("left1"); + QTest::addColumn("bottom1"); + QTest::addColumn("right1"); + QTest::addColumn("parent2"); + QTest::addColumn("top2"); + QTest::addColumn("left2"); + QTest::addColumn("bottom2"); + QTest::addColumn("right2"); + QTest::addColumn("result"); + + QTest::newRow("lt01") << -1 << 0 << 0 << 3 << 3 + << -1 << 0 << 0 << 3 << 3 << NotLessThan; + + QTest::newRow("lt02") << -1 << 0 << 0 << 2 << 3 + << -1 << 0 << 0 << 3 << 3 << LessThan; + QTest::newRow("lt03") << -1 << 0 << 0 << 3 << 2 + << -1 << 0 << 0 << 3 << 3 << LessThan; + QTest::newRow("lt04") << -1 << 0 << 0 << 2 << 2 + << -1 << 0 << 0 << 3 << 3 << LessThan; + + QTest::newRow("lt05") << -1 << 0 << 0 << 3 << 3 + << -1 << 0 << 0 << 2 << 3 << NotLessThan; + QTest::newRow("lt06") << -1 << 0 << 0 << 3 << 3 + << -1 << 0 << 0 << 3 << 2 << NotLessThan; + QTest::newRow("lt07") << -1 << 0 << 0 << 3 << 3 + << -1 << 0 << 0 << 2 << 2 << NotLessThan; + + QTest::newRow("lt08") << -1 << 0 << 0 << 3 << 3 + << 0 << 0 << 0 << 3 << 3 << NotEqual; + QTest::newRow("lt09") << 1 << 0 << 0 << 3 << 3 + << 0 << 0 << 0 << 3 << 3 << NotEqual; + QTest::newRow("lt10") << 1 << 0 << 0 << 1 << 1 + << 0 << 2 << 2 << 3 << 3 << NotEqual; + QTest::newRow("lt11") << 1 << 2 << 2 << 3 << 3 + << 0 << 0 << 0 << 1 << 1 << NotEqual; + + QTest::newRow("lt12") << -1 << 0 << 0 << 1 << 1 + << -1 << 2 << 2 << 3 << 3 << LessThan; + QTest::newRow("lt13") << -1 << 2 << 2 << 3 << 3 + << -1 << 0 << 0 << 1 << 1 << NotLessThan; + QTest::newRow("lt14") << 1 << 0 << 0 << 1 << 1 + << 1 << 2 << 2 << 3 << 3 << LessThan; + QTest::newRow("lt15") << 1 << 2 << 2 << 3 << 3 + << 1 << 0 << 0 << 1 << 1 << NotLessThan; + + QTest::newRow("lt16") << -1 << 0 << 0 << 2 << 2 + << -1 << 1 << 1 << 3 << 3 << LessThan; + QTest::newRow("lt17") << -1 << 1 << 1 << 3 << 3 + << -1 << 0 << 0 << 2 << 2 << NotLessThan; + QTest::newRow("lt18") << 1 << 0 << 0 << 2 << 2 + << 1 << 1 << 1 << 3 << 3 << LessThan; + QTest::newRow("lt19") << 1 << 1 << 1 << 3 << 3 + << 1 << 0 << 0 << 2 << 2 << NotLessThan; +} + +void tst_QItemSelectionModel::rangeOperatorLessThan() +{ + QStandardItemModel *model1 = getModel(this); + QStandardItemModel *model2 = getModel(this); + + QFETCH(int, parent1); + QFETCH(int, top1); + QFETCH(int, left1); + QFETCH(int, bottom1); + QFETCH(int, right1); + QFETCH(int, parent2); + QFETCH(int, top2); + QFETCH(int, left2); + QFETCH(int, bottom2); + QFETCH(int, right2); + QFETCH(Result, result); + + QModelIndex p1 = model1->index(parent1, 0); + + QModelIndex tl1 = model1->index(top1, left1, p1); + QModelIndex br1 = model1->index(bottom1, right1, p1); + + QItemSelectionRange r1(tl1, br1); + + QModelIndex p2 = model1->index(parent2, 0); + + QModelIndex tl2 = model1->index(top2, left2, p2); + QModelIndex br2 = model1->index(bottom2, right2, p2); + + QItemSelectionRange r2(tl2, br2); + + if (result == LessThan) + QVERIFY(r1 < r2); + else if (result == NotLessThan) + QVERIFY(!(r1 < r2)); + else if (result == NotEqual) + if (!(r1 < r2)) + QVERIFY(r2 < r1); + + // Ranges in different models are always non-equal + + QModelIndex p3 = model2->index(parent1, 0); + + QModelIndex tl3 = model2->index(top1, left1, p3); + QModelIndex br3 = model2->index(bottom1, right1, p3); + + QItemSelectionRange r3(tl3, br3); + + if (!(r1 < r3)) + QVERIFY(r3 < r1); + + if (!(r2 < r3)) + QVERIFY(r3 < r2); + + QModelIndex p4 = model2->index(parent2, 0); + + QModelIndex tl4 = model2->index(top2, left2, p4); + QModelIndex br4 = model2->index(bottom2, right2, p4); + + QItemSelectionRange r4(tl4, br4); + + if (!(r1 < r4)) + QVERIFY(r4 < r1); + + if (!(r2 < r4)) + QVERIFY(r4 < r2); +} QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" -- 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 f2077762cffba8c66cc3880c486161201421e074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Wed, 7 Jul 2010 15:10:13 +0200 Subject: Made QGL2GradientCache thread safe. This can be improved by using a QReadWriteLocker, but it means restructuring the find/insert code. Use a QMutex for now. --- src/opengl/gl2paintengineex/qglgradientcache.cpp | 28 +++++++++++++++++++----- src/opengl/gl2paintengineex/qglgradientcache_p.h | 5 +++-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/opengl/gl2paintengineex/qglgradientcache.cpp b/src/opengl/gl2paintengineex/qglgradientcache.cpp index f1b095d..cbd5eb8 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache.cpp +++ b/src/opengl/gl2paintengineex/qglgradientcache.cpp @@ -42,18 +42,33 @@ #include "qglgradientcache_p.h" #include #include - +#include QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC(QGLContextGroupResource, qt_gradient_caches) +class QGL2GradientCacheWrapper +{ +public: + QGL2GradientCache *cacheForContext(const QGLContext *context) { + QMutexLocker lock(&m_mutex); + return m_resource.value(context); + } + +private: + QGLContextGroupResource m_resource; + QMutex m_mutex; +}; + +Q_GLOBAL_STATIC(QGL2GradientCacheWrapper, qt_gradient_caches) QGL2GradientCache *QGL2GradientCache::cacheForContext(const QGLContext *context) { - return qt_gradient_caches()->value(context); + return qt_gradient_caches()->cacheForContext(context); } -void QGL2GradientCache::cleanCache() { +void QGL2GradientCache::cleanCache() +{ + QMutexLocker lock(&m_mutex); QGLGradientColorTableHash::const_iterator it = cache.constBegin(); for (; it != cache.constEnd(); ++it) { const CacheInfo &cache_info = it.value(); @@ -64,6 +79,7 @@ void QGL2GradientCache::cleanCache() { GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity) { + QMutexLocker lock(&m_mutex); quint64 hash_val = 0; QGradientStops stops = gradient.stops(); @@ -77,7 +93,9 @@ GLuint QGL2GradientCache::getBuffer(const QGradient &gradient, qreal opacity) else { do { const CacheInfo &cache_info = it.value(); - if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode()) { + if (cache_info.stops == stops && cache_info.opacity == opacity + && cache_info.interpolationMode == gradient.interpolationMode()) + { return cache_info.texId; } ++it; diff --git a/src/opengl/gl2paintengineex/qglgradientcache_p.h b/src/opengl/gl2paintengineex/qglgradientcache_p.h index 8ecb34e..7e93d87 100644 --- a/src/opengl/gl2paintengineex/qglgradientcache_p.h +++ b/src/opengl/gl2paintengineex/qglgradientcache_p.h @@ -54,6 +54,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -81,16 +82,16 @@ public: GLuint getBuffer(const QGradient &gradient, qreal opacity); inline int paletteSize() const { return 1024; } -protected: +private: inline int maxCacheSize() const { return 60; } inline void generateGradientColorTable(const QGradient& gradient, uint *colorTable, int size, qreal opacity) const; GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity); - void cleanCache(); QGLGradientColorTableHash cache; + QMutex m_mutex; }; QT_END_NAMESPACE -- cgit v0.12 From 96507cedbc6007bd8db81d82c051da86da5b0e4b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 7 Jul 2010 17:11:39 +0200 Subject: Fixes the double spinbox not updating geometry when suffix is changed patch was found in the task and looks good. Task-number: QTBUG-9530 --- src/gui/widgets/qspinbox.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/widgets/qspinbox.cpp b/src/gui/widgets/qspinbox.cpp index 2d871d0..10ce144 100644 --- a/src/gui/widgets/qspinbox.cpp +++ b/src/gui/widgets/qspinbox.cpp @@ -697,6 +697,9 @@ void QDoubleSpinBox::setSuffix(const QString &suffix) d->suffix = suffix; d->updateEdit(); + + d->cachedSizeHint = QSize(); + updateGeometry(); } /*! -- 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 c4179a0e29dab5034c1980622df88a05724706e4 Mon Sep 17 00:00:00 2001 From: James Perrett Date: Thu, 8 Jul 2010 15:06:10 +0200 Subject: Add eglnullws QScreen driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This QScreen driver can be used for embedded Qt applications that draw everything within a single full-screen QGLWidget. It uses underlying support for a null window system (NullWS) such as is present in PowerVR systems. It offers performance and stability improvements over the powervr QScreen driver for applications that do not need full QWS windowing support. Reviewed-by: Jørgen Lind --- src/plugins/gfxdrivers/eglnullws/README | 48 +++++++ src/plugins/gfxdrivers/eglnullws/eglnullws.pro | 18 +++ .../gfxdrivers/eglnullws/eglnullwsscreen.cpp | 141 +++++++++++++++++++++ src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h | 28 ++++ .../gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp | 25 ++++ .../gfxdrivers/eglnullws/eglnullwsscreenplugin.h | 6 + .../eglnullws/eglnullwswindowsurface.cpp | 43 +++++++ .../gfxdrivers/eglnullws/eglnullwswindowsurface.h | 22 ++++ src/plugins/gfxdrivers/gfxdrivers.pro | 1 + 9 files changed, 332 insertions(+) create mode 100644 src/plugins/gfxdrivers/eglnullws/README create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullws.pro create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp create mode 100644 src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h diff --git a/src/plugins/gfxdrivers/eglnullws/README b/src/plugins/gfxdrivers/eglnullws/README new file mode 100644 index 0000000..80b88c7 --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/README @@ -0,0 +1,48 @@ +EGL NullWS QScreen Driver +========================= + +If your application draws everything within a single full-screen QGLWidget then +you may wish to use this QScreen plugin driver. This driver simply returns 0 +(as a EGLNativeWindowType value) when asked by the QtOpenGl module to create a +native window. Some OpenGL ES implementations (including PowerVR) interpret this +to mean that a full-screen OpenGL context is desired without any windowing +support (NullWS). + +To tell a Qt/Embedded application to use this driver use the -display command +line option or the QWS_DISPLAY environment variable. The following driver +options are supported: + +size=WIDTHxHEIGHT Screen size reported by the driver +format=FORMAT Screen format + +Run with '-display eglnullws:help' to get a full list of options (including a +list of supported format strings). + +If you choose a screen format that is not supported by the hardware then the +QtOpenGl module will write out a list of supported EGL configurations. Use +one of the supported screen formats from this list. + +Using this driver with PowerVR hardware +--------------------------------------- + +Using this plugin with PowerVR hardware should give a significant speedup +compared to running with the Qt powervr driver (with a full-screen QGLWidget). +This is because sacrificing the window system allows less work to be done in +order to get graphics on the screen. Using this driver also avoids the memory +fragmentation issues present in the powervr driver and avoids any direct +dependencies on the deprecated PVR2D API from Imagination Technologies. + +To use this driver ensure you have /etc/powervr.ini with contents similar to +this: + +[default] +WindowSystem=libpvrPVR2D_FLIPWSEGL.so + +This driver will also function with libpvrPVR2D_FRONTWSEGL.so, but that draws +straight into the framebuffer and will therefore cause flickering (it can be +useful for performance testing though). The flip plugin uses triple buffering, +so you will need to set the virtual vertical resolution of your framebuffer to +be three times the physical vertical resolution of your screen. This can be +done with 'fbset -vyres'. Failure to do this can cause system crashes. You +should also ensure that the plugin you choose in powervr.ini is in your library +path (it may just silently default to the flip plugin if not). diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro new file mode 100644 index 0000000..242ab07 --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro @@ -0,0 +1,18 @@ +TARGET = qeglnullws +include(../../qpluginbase.pri) + +CONFIG += warn_on +QT += opengl + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/gfxdrivers + +target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers +INSTALLS += target + +HEADERS = eglnullwsscreen.h \ + eglnullwsscreenplugin.h \ + eglnullwswindowsurface.h + +SOURCES = eglnullwsscreen.cpp \ + eglnullwsscreenplugin.cpp \ + eglnullwswindowsurface.cpp diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp new file mode 100644 index 0000000..9a21447 --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp @@ -0,0 +1,141 @@ +#include "eglnullwsscreen.h" +#include "eglnullwswindowsurface.h" +#include "eglnullwsscreenplugin.h" + +#include +#include + +namespace +{ + class EGLNullWSScreenSurfaceFunctions : public QGLScreenSurfaceFunctions + { + public: + virtual bool createNativeWindow(QWidget *, EGLNativeWindowType *native) + { *native = 0; return true; } + }; +} + +EGLNullWSScreen::EGLNullWSScreen(int displayId) : QGLScreen(displayId) {} + +EGLNullWSScreen::~EGLNullWSScreen() {} + +bool EGLNullWSScreen::initDevice() +{ + setSurfaceFunctions(new EGLNullWSScreenSurfaceFunctions); + return true; +} + +static const QHash & formatDictionary() +{ + static QHash dictionary; + if (dictionary.isEmpty()) { + dictionary["rgb32"] = QImage::Format_RGB32; + dictionary["argb32"] = QImage::Format_ARGB32; + dictionary["rgb16"] = QImage::Format_RGB16; + dictionary["rgb666"] = QImage::Format_RGB666; + dictionary["rgb555"] = QImage::Format_RGB555; + dictionary["rgb888"] = QImage::Format_RGB888; + dictionary["rgb444"] = QImage::Format_RGB444; + } + return dictionary; +} + +static int depthForFormat(QImage::Format format) +{ + switch (format) { + case QImage::Format_RGB32: return 32; + case QImage::Format_ARGB32: return 32; + case QImage::Format_RGB16: return 16; + case QImage::Format_RGB666: return 24; + case QImage::Format_RGB555: return 16; + case QImage::Format_RGB888: return 24; + case QImage::Format_RGB444: return 16; + default: + Q_ASSERT(!"Unknown format"); + return -1; + } +} + +static void printHelp() +{ + QByteArray formatsBuf; + QTextStream(&formatsBuf) << QStringList(formatDictionary().keys()).join(", "); + qWarning( + "%s: Valid options are:\n" + "size=WIDTHxHEIGHT Screen size reported by this driver\n" + "format=FORMAT Screen format, where FORMAT is one of the following:\n" + " %s\n", + PluginName, + formatsBuf.constData()); +} + +bool EGLNullWSScreen::connect(const QString &displaySpec) +{ + const QStringList args = displaySpec.section(':', 1).split(':', QString::SkipEmptyParts); + Q_FOREACH(const QString arg, args) { + const QString optionName = arg.section('=', 0, 0); + const QString optionArg = arg.section('=', 1); + if (optionName == QLatin1String("size")) { + w = optionArg.section('x', 0, 0).toInt(); + h = optionArg.section('x', 1, 1).toInt(); + } else if (optionName == QLatin1String("format")) { + if (formatDictionary().contains(optionArg)) + setPixelFormat(formatDictionary().value(optionArg)); + else + printHelp(); + } else { + printHelp(); + } + } + + if (w == 0 || h == 0) { + w = 640; + h = 480; + qWarning("%s: Using default screen size %dx%d", PluginName, w, h); + } + dw = w; + dh = h; + + if (pixelFormat() == QImage::Format_Invalid) { + qWarning("%s: Using default screen format argb32", PluginName); + setPixelFormat(QImage::Format_ARGB32); + } + d = depthForFormat(pixelFormat()); + + static const int Dpi = 120; + static const qreal ScalingFactor = static_cast(25.4) / Dpi; + physWidth = qRound(dw * ScalingFactor); + physHeight = qRound(dh * ScalingFactor); + + return true; +} + +void EGLNullWSScreen::disconnect() {} + +void EGLNullWSScreen::shutdownDevice() {} + +void EGLNullWSScreen::setMode(int /*width*/, int /*height*/, int /*depth*/) {} + +void EGLNullWSScreen::blank(bool /*on*/) {} + +void EGLNullWSScreen::exposeRegion(QRegion /*r*/, int /*changing*/) {} + +QWSWindowSurface* EGLNullWSScreen::createSurface(QWidget *widget) const +{ + if (qobject_cast(widget)) { + return new EGLNullWSWindowSurface(widget); + } else { + qWarning("%s: Creating non-GL surface", PluginName); + return QScreen::createSurface(widget); + } +} + +QWSWindowSurface* EGLNullWSScreen::createSurface(const QString &key) const +{ + if (key == QLatin1String("eglnullws")) { + return new EGLNullWSWindowSurface; + } else { + qWarning("%s: Creating non-GL surface", PluginName); + return QScreen::createSurface(key); + } +} diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h new file mode 100644 index 0000000..9b620a4 --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h @@ -0,0 +1,28 @@ +#ifndef EGLNULLWSSCREEN +#define EGLNULLWSSCREEN + +#include + +class EGLNullWSScreen : public QGLScreen +{ +public: + EGLNullWSScreen(int displayId); + virtual ~EGLNullWSScreen(); + + virtual bool initDevice(); + virtual bool connect(const QString &displaySpec); + virtual void disconnect(); + virtual void shutdownDevice(); + + virtual void setMode(int width, int height, int depth); + virtual void blank(bool on); + + virtual void exposeRegion(QRegion r, int changing); + + virtual QWSWindowSurface* createSurface(QWidget *widget) const; + virtual QWSWindowSurface* createSurface(const QString &key) const; + + virtual bool hasOpenGL() { return true; } +}; + +#endif // EGLNULLWSSCREEN diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp new file mode 100644 index 0000000..354ddef --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp @@ -0,0 +1,25 @@ +#include "eglnullwsscreenplugin.h" +#include "eglnullwsscreen.h" + +#include +#include + +class EGLNullWSScreenPlugin : public QScreenDriverPlugin +{ +public: + virtual QStringList keys() const; + virtual QScreen *create(const QString& driver, int displayId); +}; + +QStringList EGLNullWSScreenPlugin::keys() const +{ + return QStringList() << QLatin1String(PluginName); +} + +QScreen *EGLNullWSScreenPlugin::create(const QString& driver, int displayId) +{ + return (driver.toLower() == QLatin1String(PluginName) ? + new EGLNullWSScreen(displayId) : 0); +} + +Q_EXPORT_PLUGIN2(qeglnullws, EGLNullWSScreenPlugin) diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h new file mode 100644 index 0000000..14e2a82 --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h @@ -0,0 +1,6 @@ +#ifndef EGLNULLWSSCREENPLUGIN_H +#define EGLNULLWSSCREENPLUGIN_H + +const char *const PluginName = "eglnullws"; + +#endif // EGLNULLWSSCREENPLUGIN_H diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp new file mode 100644 index 0000000..016748e --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp @@ -0,0 +1,43 @@ +#include "eglnullwswindowsurface.h" +#include "eglnullwsscreenplugin.h" + +#include + +static const QWSWindowSurface::SurfaceFlags Flags + = QWSWindowSurface::RegionReserved | QWSWindowSurface::RegionReserved; + +EGLNullWSWindowSurface::EGLNullWSWindowSurface(QWidget *w) + : + QWSGLWindowSurface(w), + widget(w) +{ + setSurfaceFlags(Flags); +} + +EGLNullWSWindowSurface::EGLNullWSWindowSurface() + : widget(0) +{ + setSurfaceFlags(Flags); +} + +EGLNullWSWindowSurface::~EGLNullWSWindowSurface() {} + +QString EGLNullWSWindowSurface::key() const +{ + return QLatin1String(PluginName); +} + +QPaintDevice *EGLNullWSWindowSurface::paintDevice() +{ + return widget; +} + +bool EGLNullWSWindowSurface::isValid() const +{ + return qobject_cast(window()); +} + +QImage EGLNullWSWindowSurface::image() const +{ + return QImage(); +} diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h new file mode 100644 index 0000000..7e5d2fa --- /dev/null +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h @@ -0,0 +1,22 @@ +#ifndef EGLNULLWSWINDOWSURFACE_H +#define EGLNULLWSWINDOWSURFACE_H + +#include + +class EGLNullWSWindowSurface : public QWSGLWindowSurface +{ +public: + EGLNullWSWindowSurface(QWidget *widget); + EGLNullWSWindowSurface(); + virtual ~EGLNullWSWindowSurface(); + + virtual QString key() const; + virtual QPaintDevice *paintDevice(); + virtual bool isValid() const; + virtual QImage image() const; + +private: + QWidget *widget; +}; + +#endif // EGLNULLWSWINDOWSURFACE_H diff --git a/src/plugins/gfxdrivers/gfxdrivers.pro b/src/plugins/gfxdrivers/gfxdrivers.pro index d1ee3f2..1f38942 100644 --- a/src/plugins/gfxdrivers/gfxdrivers.pro +++ b/src/plugins/gfxdrivers/gfxdrivers.pro @@ -7,3 +7,4 @@ contains(gfx-plugins, vnc) :SUBDIRS += vnc contains(gfx-plugins, transformed) :SUBDIRS += transformed contains(gfx-plugins, svgalib) :SUBDIRS += svgalib contains(gfx-plugins, powervr) :SUBDIRS += powervr +contains(gfx-plugins, eglnullws) :SUBDIRS += eglnullws -- cgit v0.12 From eb7c795a9172bf3ee643e72cbd67db062c9883a3 Mon Sep 17 00:00:00 2001 From: James Perrett Date: Thu, 8 Jul 2010 15:06:12 +0200 Subject: Use Q_ASSERT_X() rather than Q_ASSERT(!"message") idiom MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids warnings on some compilers. Reviewed-by: Jørgen Lind --- src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp index 9a21447..341caff 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp @@ -51,7 +51,7 @@ static int depthForFormat(QImage::Format format) case QImage::Format_RGB888: return 24; case QImage::Format_RGB444: return 16; default: - Q_ASSERT(!"Unknown format"); + Q_ASSERT_X(false, "EGLNullWSScreen", "Unknown format"); return -1; } } -- cgit v0.12 From 9b0ab2254f09d7c465e7f92cb2a41eddce83a84b Mon Sep 17 00:00:00 2001 From: James Perrett Date: Thu, 8 Jul 2010 15:06:13 +0200 Subject: Remove explicit 'virtual' specifiers to conform to Qt coding standard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen Lind --- src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h index 9b620a4..a9cb64c 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h @@ -7,22 +7,22 @@ class EGLNullWSScreen : public QGLScreen { public: EGLNullWSScreen(int displayId); - virtual ~EGLNullWSScreen(); + ~EGLNullWSScreen(); - virtual bool initDevice(); - virtual bool connect(const QString &displaySpec); - virtual void disconnect(); - virtual void shutdownDevice(); + bool initDevice(); + bool connect(const QString &displaySpec); + void disconnect(); + void shutdownDevice(); - virtual void setMode(int width, int height, int depth); - virtual void blank(bool on); + void setMode(int width, int height, int depth); + void blank(bool on); - virtual void exposeRegion(QRegion r, int changing); + void exposeRegion(QRegion r, int changing); - virtual QWSWindowSurface* createSurface(QWidget *widget) const; - virtual QWSWindowSurface* createSurface(const QString &key) const; + QWSWindowSurface* createSurface(QWidget *widget) const; + QWSWindowSurface* createSurface(const QString &key) const; - virtual bool hasOpenGL() { return true; } + bool hasOpenGL() { return true; } }; #endif // EGLNULLWSSCREEN -- cgit v0.12 From 0bad059e4120b6e6c25427a19e3da942c1ff3151 Mon Sep 17 00:00:00 2001 From: James Perrett Date: Thu, 8 Jul 2010 15:06:15 +0200 Subject: Avoid static local QHash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change formatDictionary() to return a QHash by-value rather than a const reference to a static local QHash. This avoids memory being permanently allocated on the heap for a dictionary that is only needed during startup. Reviewed-by: Jørgen Lind --- .../gfxdrivers/eglnullws/eglnullwsscreen.cpp | 33 +++++++++++----------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp index 341caff..4213097 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp @@ -25,18 +25,16 @@ bool EGLNullWSScreen::initDevice() return true; } -static const QHash & formatDictionary() +static const QHash formatDictionary() { - static QHash dictionary; - if (dictionary.isEmpty()) { - dictionary["rgb32"] = QImage::Format_RGB32; - dictionary["argb32"] = QImage::Format_ARGB32; - dictionary["rgb16"] = QImage::Format_RGB16; - dictionary["rgb666"] = QImage::Format_RGB666; - dictionary["rgb555"] = QImage::Format_RGB555; - dictionary["rgb888"] = QImage::Format_RGB888; - dictionary["rgb444"] = QImage::Format_RGB444; - } + QHash dictionary; + dictionary["rgb32"] = QImage::Format_RGB32; + dictionary["argb32"] = QImage::Format_ARGB32; + dictionary["rgb16"] = QImage::Format_RGB16; + dictionary["rgb666"] = QImage::Format_RGB666; + dictionary["rgb555"] = QImage::Format_RGB555; + dictionary["rgb888"] = QImage::Format_RGB888; + dictionary["rgb444"] = QImage::Format_RGB444; return dictionary; } @@ -56,10 +54,10 @@ static int depthForFormat(QImage::Format format) } } -static void printHelp() +static void printHelp(const QHash &formatDictionary) { QByteArray formatsBuf; - QTextStream(&formatsBuf) << QStringList(formatDictionary().keys()).join(", "); + QTextStream(&formatsBuf) << QStringList(formatDictionary.keys()).join(", "); qWarning( "%s: Valid options are:\n" "size=WIDTHxHEIGHT Screen size reported by this driver\n" @@ -72,6 +70,7 @@ static void printHelp() bool EGLNullWSScreen::connect(const QString &displaySpec) { const QStringList args = displaySpec.section(':', 1).split(':', QString::SkipEmptyParts); + const QHash formatDict = formatDictionary(); Q_FOREACH(const QString arg, args) { const QString optionName = arg.section('=', 0, 0); const QString optionArg = arg.section('=', 1); @@ -79,12 +78,12 @@ bool EGLNullWSScreen::connect(const QString &displaySpec) w = optionArg.section('x', 0, 0).toInt(); h = optionArg.section('x', 1, 1).toInt(); } else if (optionName == QLatin1String("format")) { - if (formatDictionary().contains(optionArg)) - setPixelFormat(formatDictionary().value(optionArg)); + if (formatDict.contains(optionArg)) + setPixelFormat(formatDict.value(optionArg)); else - printHelp(); + printHelp(formatDict); } else { - printHelp(); + printHelp(formatDict); } } -- cgit v0.12 From 1441c74b89fa6b8b1368888413d5763f81cf733b Mon Sep 17 00:00:00 2001 From: James Perrett Date: Thu, 8 Jul 2010 15:06:16 +0200 Subject: Add copyright header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Jørgen Lind --- .../gfxdrivers/eglnullws/eglnullwsscreen.cpp | 41 ++++++++++++++++++++++ src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h | 41 ++++++++++++++++++++++ .../gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp | 41 ++++++++++++++++++++++ .../gfxdrivers/eglnullws/eglnullwsscreenplugin.h | 41 ++++++++++++++++++++++ .../eglnullws/eglnullwswindowsurface.cpp | 41 ++++++++++++++++++++++ .../gfxdrivers/eglnullws/eglnullwswindowsurface.h | 41 ++++++++++++++++++++++ 6 files changed, 246 insertions(+) diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp index 4213097..b8ea5d5 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.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 "eglnullwsscreen.h" #include "eglnullwswindowsurface.h" #include "eglnullwsscreenplugin.h" diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h index a9cb64c..7f794bc 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.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 EGLNULLWSSCREEN #define EGLNULLWSSCREEN diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp index 354ddef..67b3f56 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.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 "eglnullwsscreenplugin.h" #include "eglnullwsscreen.h" diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h index 14e2a82..84f0699 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.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 EGLNULLWSSCREENPLUGIN_H #define EGLNULLWSSCREENPLUGIN_H diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp index 016748e..da4b728 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.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 "eglnullwswindowsurface.h" #include "eglnullwsscreenplugin.h" diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h index 7e5d2fa..b730415 100644 --- a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h +++ b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.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 EGLNULLWSWINDOWSURFACE_H #define EGLNULLWSWINDOWSURFACE_H -- cgit v0.12 From e02d97c50cee8bdc662bb1183ed01aa0dac53f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Thu, 8 Jul 2010 17:31:16 +0200 Subject: Track the GL DCs we use across different threads under Windows. A DC returned by GetDC() is only valid within the context of the calling thread, so we need to track which tread a DC belongs to. Reviewed-by: Kim --- src/opengl/qgl.cpp | 1 + src/opengl/qgl_p.h | 1 + src/opengl/qgl_win.cpp | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 3f2af9d..05dae60 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1655,6 +1655,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) #if defined(Q_WS_WIN) dc = 0; win = 0; + threadId = 0; pixelFormatId = 0; cmap = 0; hbitmap = 0; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index eca4a29..dfbc926 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -347,6 +347,7 @@ public: QGLCmap* cmap; HBITMAP hbitmap; HDC hbitmap_hdc; + Qt::HANDLE threadId; #endif #ifndef QT_NO_EGL uint ownsEglContext : 1; diff --git a/src/opengl/qgl_win.cpp b/src/opengl/qgl_win.cpp index 52988b6..3f13ac4 100644 --- a/src/opengl/qgl_win.cpp +++ b/src/opengl/qgl_win.cpp @@ -1261,6 +1261,7 @@ void QGLContext::reset() } d->dc = 0; d->win = 0; + d->threadId = 0; d->pixelFormatId = 0; d->sharing = false; d->valid = false; @@ -1283,8 +1284,9 @@ void QGLContext::makeCurrent() if (d->rc == wglGetCurrentContext() || !d->valid) // already current return; - if (d->win && !d->dc) { + if (d->win && (!d->dc || d->threadId != QThread::currentThreadId())) { d->dc = GetDC(d->win); + d->threadId = QThread::currentThreadId(); if (!d->dc) { qwglError("QGLContext::makeCurrent()", "GetDC()"); return; @@ -1322,6 +1324,7 @@ void QGLContext::doneCurrent() if (d->win && d->dc) { ReleaseDC(d->win, d->dc); d->dc = 0; + d->threadId = 0; } } -- cgit v0.12 From 0c56bef89b6e3fe4c9fb32eb8b51a6ea316a89fa Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 9 Jul 2010 11:33:56 +1000 Subject: Optimize text layout. When laying out text, a significant amount of time was being spent querying for the font engine. This patch: * changes the layout to only query for the engine when a new script item is encountered. * adds an internal cache of the previous result to QTextEngine::fontEngine(). This catches the important case of multiline text with few font engine changes. With these changes layout costs are now approximately 60% of what they were previously, as measured by the text layout benchmarks. Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 65 +++++++++++++++++++++++++++++++------------- src/gui/text/qtextengine_p.h | 17 ++++++++++++ src/gui/text/qtextlayout.cpp | 14 ++++++---- 3 files changed, 71 insertions(+), 25 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index f892adc..a79ce2e 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1366,6 +1366,7 @@ void QTextEngine::invalidate() maxWidth = 0; if (specialData) specialData->resolvedFormatIndices.clear(); + feCache.reset(); } void QTextEngine::clearLineData() @@ -1762,6 +1763,13 @@ QFont QTextEngine::font(const QScriptItem &si) const return font; } +QTextEngine::FontEngineCache::FontEngineCache() +{ + reset(); +} + +//we cache the previous results of this function, as calling it numerous times with the same effective +//input is common (and hard to cache at a higher level) QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFixed *descent, QFixed *leading) const { QFontEngine *engine = 0; @@ -1770,28 +1778,47 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix QFont font = fnt; if (hasFormats()) { - QTextCharFormat f = format(&si); - font = f.font(); - - if (block.docHandle() && block.docHandle()->layout()) { - // Make sure we get the right dpi on printers - QPaintDevice *pdev = block.docHandle()->layout()->paintDevice(); - if (pdev) - font = QFont(font, pdev); + if (feCache.prevFontEngine && feCache.prevPosition == si.position && feCache.prevLength == length(&si) && feCache.prevScript == script) { + engine = feCache.prevFontEngine; + scaledEngine = feCache.prevScaledFontEngine; } else { - font = font.resolve(fnt); - } - engine = font.d->engineForScript(script); - QTextCharFormat::VerticalAlignment valign = f.verticalAlignment(); - if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) { - if (font.pointSize() != -1) - font.setPointSize((font.pointSize() * 2) / 3); - else - font.setPixelSize((font.pixelSize() * 2) / 3); - scaledEngine = font.d->engineForScript(script); + QTextCharFormat f = format(&si); + font = f.font(); + + if (block.docHandle() && block.docHandle()->layout()) { + // Make sure we get the right dpi on printers + QPaintDevice *pdev = block.docHandle()->layout()->paintDevice(); + if (pdev) + font = QFont(font, pdev); + } else { + font = font.resolve(fnt); + } + engine = font.d->engineForScript(script); + QTextCharFormat::VerticalAlignment valign = f.verticalAlignment(); + if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) { + if (font.pointSize() != -1) + font.setPointSize((font.pointSize() * 2) / 3); + else + font.setPixelSize((font.pixelSize() * 2) / 3); + scaledEngine = font.d->engineForScript(script); + } + feCache.prevFontEngine = engine; + feCache.prevScaledFontEngine = scaledEngine; + feCache.prevScript = script; + feCache.prevPosition = si.position; + feCache.prevLength = length(&si); } } else { - engine = font.d->engineForScript(script); + if (feCache.prevFontEngine && feCache.prevScript == script && feCache.prevPosition == -1) + engine = feCache.prevFontEngine; + else { + engine = font.d->engineForScript(script); + feCache.prevFontEngine = engine; + feCache.prevScript = script; + feCache.prevPosition = -1; + feCache.prevLength = -1; + feCache.prevScaledFontEngine = 0; + } } if (si.analysis.flags == QScriptAnalysis::SmallCaps) { diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 5588cbc..7270efb 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -550,6 +550,23 @@ public: mutable QScriptLineArray lines; + struct FontEngineCache { + FontEngineCache(); + mutable QFontEngine *prevFontEngine; + mutable QFontEngine *prevScaledFontEngine; + mutable int prevScript; + mutable int prevPosition; + mutable int prevLength; + inline void reset() { + prevFontEngine = 0; + prevScaledFontEngine = 0; + prevScript = -1; + prevPosition = -1; + prevLength = -1; + } + }; + mutable FontEngineCache feCache; + QString text; QFont fnt; QTextBlock block; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 0df3c2e..3bad6a5 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -401,6 +401,7 @@ QTextLayout::~QTextLayout() void QTextLayout::setFont(const QFont &font) { d->fnt = font; + d->feCache.reset(); } /*! @@ -540,6 +541,7 @@ void QTextLayout::setAdditionalFormats(const QList &formatList) } if (d->block.docHandle()) d->block.docHandle()->documentChange(d->block.position(), d->block.length()); + d->feCache.reset(); } /*! @@ -1860,14 +1862,14 @@ void QTextLine::layout_helper(int maxGlyphs) lbh.currentPosition = qMax(line.from, current.position); end = current.position + eng->length(item); lbh.glyphs = eng->shapedGlyphs(¤t); + QFontEngine *fontEngine = eng->fontEngine(current); + if (lbh.fontEngine != fontEngine) { + lbh.fontEngine = fontEngine; + lbh.minimumRightBearing = qMin(QFixed(), + QFixed::fromReal(fontEngine->minRightBearing())); + } } const QScriptItem ¤t = eng->layoutData->items[item]; - QFontEngine *fontEngine = eng->fontEngine(current); - if (lbh.fontEngine != fontEngine) { - lbh.fontEngine = fontEngine; - lbh.minimumRightBearing = qMin(QFixed(), - QFixed::fromReal(fontEngine->minRightBearing())); - } lbh.tmpData.leading = qMax(lbh.tmpData.leading + lbh.tmpData.ascent, current.leading + current.ascent) - qMax(lbh.tmpData.ascent, -- cgit v0.12 From 1e9a92cd6e8670a9dc90fed2044e7de38a3b13e6 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 9 Jul 2010 10:47:46 +0200 Subject: Incorrect assertion in item views we were checking if the parent of main items was QModelIndex instead if checking if it is just invalid (it might have a pointer to its model and still be invalid). Task-number: QTBUG-12090 Reviewed-by: Ian Walters --- src/gui/itemviews/qabstractitemview.cpp | 2 +- src/gui/kernel/qapplication.cpp | 2 ++ src/gui/kernel/qwidget.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 15e59ba..302aa20 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -653,7 +653,7 @@ void QAbstractItemView::setModel(QAbstractItemModel *model) "QAbstractItemView::setModel", "A model should return the exact same index " "(including its internal id/pointer) when asked for it twice in a row."); - Q_ASSERT_X(d->model->index(0,0).parent() == QModelIndex(), + Q_ASSERT_X(!d->model->index(0,0).parent().isValid(), "QAbstractItemView::setModel", "The parent of a top level index should be invalid"); diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4f557d6..6a67369 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5780,6 +5780,8 @@ Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QGestureManager* QGestureManager::instance() { QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); + if (!qAppPriv) + return 0; if (!qAppPriv->gestureManager) qAppPriv->gestureManager = new QGestureManager(qApp); return qAppPriv->gestureManager; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 2627960..2e980c1 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -12053,8 +12053,8 @@ void QWidget::ungrabGesture(Qt::GestureType gesture) { Q_D(QWidget); if (d->gestureContext.remove(gesture)) { - QGestureManager *manager = QGestureManager::instance(); - manager->cleanupCachedGestures(this, gesture); + if (QGestureManager *manager = QGestureManager::instance()) + manager->cleanupCachedGestures(this, gesture); } } #endif // QT_NO_GESTURES -- cgit v0.12 From 2b358140c6b75ee29135175535190d415f5af10f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Fri, 9 Jul 2010 11:28:26 +0200 Subject: Small fix in iteviews for sizeHintForColumn/Row We were trying to check the column/row count but always from the root of the model insteal of the root that can be defined in the view. Task-number: QTBUG-5773 --- src/gui/itemviews/qabstractitemview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 302aa20..ea24328 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2944,7 +2944,7 @@ int QAbstractItemView::sizeHintForRow(int row) const { Q_D(const QAbstractItemView); - if (row < 0 || row >= d->model->rowCount() || !model()) + if (row < 0 || row >= d->model->rowCount(d->root)) return -1; ensurePolished(); @@ -2956,7 +2956,7 @@ int QAbstractItemView::sizeHintForRow(int row) const for (int c = 0; c < colCount; ++c) { index = d->model->index(row, c, d->root); if (QWidget *editor = d->editorForIndex(index).editor) - height = qMax(height, editor->size().height()); + height = qMax(height, editor->height()); int hint = d->delegateForIndex(index)->sizeHint(option, index).height(); height = qMax(height, hint); } @@ -2975,7 +2975,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const { Q_D(const QAbstractItemView); - if (column < 0 || column >= d->model->columnCount() || !model()) + if (column < 0 || column >= d->model->columnCount(d->root)) return -1; ensurePolished(); -- 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 d193933b31088f83358a657f0399c6eeae2467e2 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 12 Jul 2010 09:54:40 +0200 Subject: Make QFontEngineGlyphCache explicitly shared QFontEngine will delete its glyph cache (and if it's a GL engine, its texture) when the font engine dies. The font engine can die when the QFontCache decides to clean it up, e.g. based on the trigger of a timer. To make it possible to use the glyph cache elsewhere, without interference by the font cache, it has been made explicitly shared. Reviewed-by: Kim --- src/gui/text/qfontengine.cpp | 12 +++++------- src/gui/text/qfontengine_p.h | 2 +- src/gui/text/qfontengineglyphcache_p.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 2d95bae..3f6b409 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -185,10 +185,6 @@ QFontEngine::QFontEngine() QFontEngine::~QFontEngine() { - for (QLinkedList::const_iterator it = m_glyphCaches.constBegin(), - end = m_glyphCaches.constEnd(); it != end; ++it) { - delete it->cache; - } m_glyphCaches.clear(); qHBFreeFace(hbFace); } @@ -734,14 +730,16 @@ void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data) { Q_ASSERT(data); - GlyphCacheEntry entry = { key, data }; + GlyphCacheEntry entry; + entry.context = key; + entry.cache = data; if (m_glyphCaches.contains(entry)) return; // Limit the glyph caches to 4. This covers all 90 degree rotations and limits // memory use when there is continous or random rotation if (m_glyphCaches.size() == 4) - delete m_glyphCaches.takeLast().cache; + m_glyphCaches.removeLast(); m_glyphCaches.push_front(entry); @@ -750,7 +748,7 @@ void QFontEngine::setGlyphCache(void *key, QFontEngineGlyphCache *data) QFontEngineGlyphCache *QFontEngine::glyphCache(void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const { for (QLinkedList::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) { - QFontEngineGlyphCache *c = it->cache; + QFontEngineGlyphCache *c = it->cache.data(); if (key == it->context && type == c->cacheType() && qtransform_equals_no_translate(c->m_transform, transform)) { diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index d29ef45..4e518d6 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -262,7 +262,7 @@ protected: private: struct GlyphCacheEntry { void *context; - QFontEngineGlyphCache *cache; + QExplicitlySharedDataPointer cache; bool operator==(const GlyphCacheEntry &other) { return context == other.context && cache == other.cache; } }; diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h index 7b82b46..eba16f7 100644 --- a/src/gui/text/qfontengineglyphcache_p.h +++ b/src/gui/text/qfontengineglyphcache_p.h @@ -72,7 +72,7 @@ QT_BEGIN_NAMESPACE -class QFontEngineGlyphCache +class QFontEngineGlyphCache: public QSharedData { public: enum Type { -- 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 8c662477a3596fd5fdf8388ed8266e52aa8b7069 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 12 Jul 2010 19:58:08 +0200 Subject: Skipped tst_QGL::graphicsViewClipping on mac. As it prevent integration See QTBUG-12138 --- tests/auto/qgl/tst_qgl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index c05f730..ffd7622 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -838,6 +838,9 @@ public: void tst_QGL::graphicsViewClipping() { +#ifdef Q_WS_MAC + QSKIP("Prevent integration, see QTBUG-12138", SkipAll); +#endif const int size = 64; UnclippedWidget *widget = new UnclippedWidget; widget->setFixedSize(size, size); -- cgit v0.12 From 5652cb1c49b4350f9a80eafaae4276e173d845bc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 13 Jul 2010 09:49:56 +0200 Subject: Skipped tst_QGL::glFBOUseInGLWidget on mac. As it prevent integration See QTBUG-12138 --- tests/auto/qgl/tst_qgl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index ffd7622..e76de02 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1286,6 +1286,9 @@ protected: void tst_QGL::glFBOUseInGLWidget() { +#ifdef Q_WS_MAC + QSKIP("Prevent integration, see QTBUG-12138", SkipAll); +#endif if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); -- cgit v0.12 From dac4ff9ea66bb4e09c220069ff7a55e3f87c9f53 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 13 Jul 2010 09:49:56 +0200 Subject: Skipped tst_QGL::glPBufferRendering on mac. As it prevent integration See QTBUG-12138 --- tests/auto/qgl/tst_qgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index e76de02..34f64f0 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -943,6 +943,10 @@ void tst_QGL::partialGLWidgetUpdates() // This tests that rendering to a QGLPBuffer using QPainter works. void tst_QGL::glPBufferRendering() { +#ifdef Q_WS_MAC + QSKIP("Prevent integration, see QTBUG-12138", SkipAll); +#endif + if (!QGLPixelBuffer::hasOpenGLPbuffers()) QSKIP("QGLPixelBuffer not supported on this platform", SkipSingle); -- 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 11c669e2a56b6b4de0a40393167887d53f3134a6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 13 Jul 2010 09:49:56 +0200 Subject: Skipped tst_QGL::replaceClipping on mac. As it prevent integration See QTBUG-12138 --- tests/auto/qgl/tst_qgl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 34f64f0..c71824a 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -1689,6 +1689,10 @@ protected: void tst_QGL::replaceClipping() { +#ifdef Q_WS_MAC + QSKIP("Prevent integration, see QTBUG-12138", SkipAll); +#endif + ReplaceClippingGLWidget glw; #ifdef Q_WS_QWS glw.setWindowFlags(Qt::FramelessWindowHint); -- cgit v0.12 From 943bd1af642651b5f600cacf237627058d38bccf Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 14 Jul 2010 08:48:13 +0200 Subject: Ensure that the view loses its selection when typing in the lineedit When QT_NO_FSCOMPLETER is defined then when selecting a file in the view in a filedialog and then changing the filename in the lineedit to a file that does not exist then the view should deselect any selection it has. The name of the slot in this case is unfortunate as it does not actually do any auto-completion. This ensures that the same behaviour works in both cases. Reviewed-by: Alexis Menard --- src/gui/dialogs/qfiledialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index cb74a3c..a0dca5d 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -2209,9 +2209,9 @@ void QFileDialogPrivate::createWidgets() #ifndef QT_NO_FSCOMPLETER completer = new QFSCompleter(model, q); qFileDialogUi->fileNameEdit->setCompleter(completer); +#endif // QT_NO_FSCOMPLETER QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_autoCompleteFileName(QString))); -#endif // QT_NO_FSCOMPLETER QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_updateOkButton())); -- cgit v0.12 From 5bcb42d8f47f7206e9c0776b67a4c990ac93aa34 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 14 Jul 2010 10:31:32 +0200 Subject: tst_QGL: Skip all QGL test on mac as they crash and prevent integration See QTBUG-12138 --- tests/auto/qgl/tst_qgl.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index c71824a..d6a6e9c 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -72,7 +72,9 @@ public: tst_QGL(); virtual ~tst_QGL(); +#ifndef Q_WS_MAC //All tests are disabled on mac as they crash and prevent integration, see QTBUG-12138 private slots: +#endif void getSetCheck(); void openGLVersionCheck(); void graphicsViewClipping(); @@ -838,9 +840,6 @@ public: void tst_QGL::graphicsViewClipping() { -#ifdef Q_WS_MAC - QSKIP("Prevent integration, see QTBUG-12138", SkipAll); -#endif const int size = 64; UnclippedWidget *widget = new UnclippedWidget; widget->setFixedSize(size, size); @@ -943,10 +942,6 @@ void tst_QGL::partialGLWidgetUpdates() // This tests that rendering to a QGLPBuffer using QPainter works. void tst_QGL::glPBufferRendering() { -#ifdef Q_WS_MAC - QSKIP("Prevent integration, see QTBUG-12138", SkipAll); -#endif - if (!QGLPixelBuffer::hasOpenGLPbuffers()) QSKIP("QGLPixelBuffer not supported on this platform", SkipSingle); @@ -1290,9 +1285,6 @@ protected: void tst_QGL::glFBOUseInGLWidget() { -#ifdef Q_WS_MAC - QSKIP("Prevent integration, see QTBUG-12138", SkipAll); -#endif if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) QSKIP("QGLFramebufferObject not supported on this platform", SkipSingle); @@ -1689,10 +1681,6 @@ protected: void tst_QGL::replaceClipping() { -#ifdef Q_WS_MAC - QSKIP("Prevent integration, see QTBUG-12138", SkipAll); -#endif - ReplaceClippingGLWidget glw; #ifdef Q_WS_QWS glw.setWindowFlags(Qt::FramelessWindowHint); -- cgit v0.12 From 1348b33591182e16264ff15854efe849638ca04c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 12 Jul 2010 14:42:37 +0200 Subject: Support text decoration in QPainter::drawGlyphs() In order to support text decorations (overline, underline and strikeout) in QPainter::drawGlyphs(), we need to call drawTextItemDecoration() from this function. To support this, it has been generalized to no longer require a QTextItemInt. We also need to propagate the decoration attributes of the font from QTextLayout to QGlyphs, since this is not part of the QFontEngine. Task-number: QTBUG-12122 Reviewed-by: Kim --- src/gui/painting/qpainter.cpp | 68 ++++++++++++++++---- src/gui/text/qtextlayout.cpp | 36 ++++++++--- tests/auto/qglyphs/tst_qglyphs.cpp | 126 +++++++++++++++++++++++++++++++++++++ 3 files changed, 208 insertions(+), 22 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index a845842..d6fbab3 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -88,6 +88,10 @@ bool qt_show_painter_debug_output = true; extern QPixmap qt_pixmapForBrush(int style, bool invert); +static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, QFontEngine *fe, + QTextCharFormat::UnderlineStyle underlineStyle, + QTextItemInt::RenderFlags flags, qreal width, + const QTextCharFormat &charFormat); void qt_format_text(const QFont &font, const QRectF &_r, int tf, const QTextOption *option, const QString& str, QRectF *brect, int tabstops, int* tabarray, int tabarraylen, @@ -5750,6 +5754,8 @@ void qt_draw_glyphs(QPainter *painter, const quint32 *glyphArray, const QPointF void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, int glyphCount) { + Q_Q(QPainter); + updateState(state); QFontEngine *fontEngine = state->font.d->engineForScript(QUnicodeTables::Common); @@ -5764,6 +5770,26 @@ void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, in fontEngine = static_cast(fontEngine)->engine(engineIdx); } + QFixed leftMost; + QFixed rightMost; + QFixed baseLine; + for (int i=0; iboundingBox(glyphArray[i]); + if (i == 0 || leftMost > positions[i].x) + leftMost = positions[i].x; + + // We don't support glyphs that do not share a common baseline. If this turns out to + // be a relevant use case, then we need to find clusters of glyphs that share a baseline + // and do a drawTextItemDecorations call per cluster. + if (i == 0 || baseLine < positions[i].y) + baseLine = positions[i].y; + + // We use the advance rather than the actual bounds to match the algorithm in drawText() + if (i == 0 || rightMost < positions[i].x + gm.xoff) + rightMost = positions[i].x + gm.xoff; + } + + QFixed width = rightMost - leftMost; if (extended != 0) { QStaticTextItem staticTextItem; @@ -5797,6 +5823,21 @@ void QPainterPrivate::drawGlyphs(quint32 *glyphArray, QFixedPoint *positions, in engine->drawTextItem(QPointF(0, 0), textItem); } + + QTextItemInt::RenderFlags flags; + if (state->font.underline()) + flags |= QTextItemInt::Underline; + if (state->font.overline()) + flags |= QTextItemInt::Overline; + if (state->font.strikeOut()) + flags |= QTextItemInt::StrikeOut; + + drawTextItemDecoration(q, QPointF(leftMost.toReal(), baseLine.toReal()), + fontEngine, + (state->font.underline() + ? QTextCharFormat::SingleUnderline + : QTextCharFormat::NoUnderline), + flags, width.toReal(), QTextCharFormat()); } /*! @@ -6322,15 +6363,15 @@ static QPixmap generateWavyPixmap(qreal maxRadius, const QPen &pen) return pixmap; } -static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const QTextItemInt &ti) +static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, QFontEngine *fe, + QTextCharFormat::UnderlineStyle underlineStyle, + QTextItemInt::RenderFlags flags, qreal width, + const QTextCharFormat &charFormat) { - QTextCharFormat::UnderlineStyle underlineStyle = ti.underlineStyle; if (underlineStyle == QTextCharFormat::NoUnderline - && !(ti.flags & (QTextItem::StrikeOut | QTextItem::Overline))) + && !(flags & (QTextItem::StrikeOut | QTextItem::Overline))) return; - QFontEngine *fe = ti.fontEngine; - const QPen oldPen = painter->pen(); const QBrush oldBrush = painter->brush(); painter->setBrush(Qt::NoBrush); @@ -6339,7 +6380,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const pen.setWidthF(fe->lineThickness().toReal()); pen.setCapStyle(Qt::FlatCap); - QLineF line(pos.x(), pos.y(), pos.x() + ti.width.toReal(), pos.y()); + QLineF line(pos.x(), pos.y(), pos.x() + width, pos.y()); const qreal underlineOffset = fe->underlinePosition().toReal(); // deliberately ceil the offset to avoid the underline coming too close to @@ -6354,21 +6395,21 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const painter->save(); painter->translate(0, pos.y() + 1); - QColor uc = ti.charFormat.underlineColor(); + QColor uc = charFormat.underlineColor(); if (uc.isValid()) pen.setColor(uc); // Adapt wave to underlineOffset or pen width, whatever is larger, to make it work on all platforms const QPixmap wave = generateWavyPixmap(qMax(underlineOffset, pen.widthF()), pen); - const int descent = (int) ti.descent.toReal(); + const int descent = (int) fe->descent().toReal(); painter->setBrushOrigin(painter->brushOrigin().x(), 0); - painter->fillRect(pos.x(), 0, qCeil(ti.width.toReal()), qMin(wave.height(), descent), wave); + painter->fillRect(pos.x(), 0, qCeil(width), qMin(wave.height(), descent), wave); painter->restore(); } else if (underlineStyle != QTextCharFormat::NoUnderline) { QLineF underLine(line.x1(), underlinePos, line.x2(), underlinePos); - QColor uc = ti.charFormat.underlineColor(); + QColor uc = charFormat.underlineColor(); if (uc.isValid()) pen.setColor(uc); @@ -6380,14 +6421,14 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const pen.setStyle(Qt::SolidLine); pen.setColor(oldPen.color()); - if (ti.flags & QTextItem::StrikeOut) { + if (flags & QTextItem::StrikeOut) { QLineF strikeOutLine = line; strikeOutLine.translate(0., - fe->ascent().toReal() / 3.); painter->setPen(pen); painter->drawLine(strikeOutLine); } - if (ti.flags & QTextItem::Overline) { + if (flags & QTextItem::Overline) { QLineF overLine = line; overLine.translate(0., - fe->ascent().toReal()); painter->setPen(pen); @@ -6528,7 +6569,8 @@ void QPainter::drawTextItem(const QPointF &p, const QTextItem &_ti) else d->engine->drawTextItem(p, ti); } - drawTextItemDecoration(this, p, ti); + drawTextItemDecoration(this, p, ti.fontEngine, ti.underlineStyle, ti.flags, ti.width.toReal(), + ti.charFormat); if (d->state->renderHints != oldRenderHints) { d->state->renderHints = oldRenderHints; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 3bad6a5..4dda114 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2183,13 +2183,15 @@ static void setPenAndDrawBackground(QPainter *p, const QPen &defaultPen, const Q namespace { struct GlyphInfo { - GlyphInfo(const QGlyphLayout &layout, const QPointF &position) - : glyphLayout(layout), itemPosition(position) + GlyphInfo(const QGlyphLayout &layout, const QPointF &position, + const QTextItemInt::RenderFlags &renderFlags) + : glyphLayout(layout), itemPosition(position), flags(renderFlags) { } QGlyphLayout glyphLayout; QPointF itemPosition; + QTextItem::RenderFlags flags; }; } @@ -2218,6 +2220,15 @@ QList QTextLine::glyphs() const QPointF pos(iterator.x.toReal(), y); QFont font = eng->font(si); + + QTextItem::RenderFlags flags; + if (font.overline()) + flags |= QTextItem::Overline; + if (font.underline()) + flags |= QTextItem::Underline; + if (font.strikeOut()) + flags |= QTextItem::StrikeOut; + QGlyphLayout glyphLayout = eng->shapedGlyphs(&si).mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart); @@ -2235,7 +2246,7 @@ QList QTextLine::glyphs() const QGlyphLayout subLayout = glyphLayout.mid(start, end - start); glyphLayoutHash.insertMulti(multiFontEngine->engine(which), - GlyphInfo(subLayout, pos)); + GlyphInfo(subLayout, pos, flags)); start = end; which = e; @@ -2243,16 +2254,16 @@ QList QTextLine::glyphs() const QGlyphLayout subLayout = glyphLayout.mid(start, end - start); glyphLayoutHash.insertMulti(multiFontEngine->engine(which), - GlyphInfo(subLayout, pos)); + GlyphInfo(subLayout, pos, flags)); } else { glyphLayoutHash.insertMulti(mainFontEngine, - GlyphInfo(glyphLayout, pos)); + GlyphInfo(glyphLayout, pos, flags)); } } } - QHash glyphsHash; + QHash, QGlyphs> glyphsHash; QList keys = glyphLayoutHash.uniqueKeys(); for (int i=0; i QTextLine::glyphs() const for (int j=0; j glyphsArray; QVarLengthArray positionsArray; @@ -2283,10 +2299,12 @@ QList QTextLine::glyphs() const glyphIndexes.setGlyphIndexes(glyphs); glyphIndexes.setPositions(positions); - if (!glyphsHash.contains(fontEngine)) - glyphsHash.insert(fontEngine, QGlyphs()); + QPair key(fontEngine, int(flags)); + + if (!glyphsHash.contains(key)) + glyphsHash.insert(key, QGlyphs()); - QGlyphs &target = glyphsHash[fontEngine]; + QGlyphs &target = glyphsHash[key]; target += glyphIndexes; target.setFont(font); } diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index 54a69dc..6827b23 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -66,6 +66,9 @@ private slots: void drawNonExistentGlyphs(); void drawMultiScriptText1(); void drawMultiScriptText2(); + void drawStruckOutText(); + void drawOverlinedText(); + void drawUnderlinedText(); void detach(); private: @@ -401,6 +404,129 @@ void tst_QGlyphs::detach() QCOMPARE(glyphs.glyphIndexes(), QVector() << 1 << 2 << 3); } +void tst_QGlyphs::drawStruckOutText() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s = QString::fromLatin1("Foobar"); + + QFont font; + font.setStrikeOut(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphs glyphs = layout.glyphs().size() > 0 + ? layout.glyphs().at(0) + : QGlyphs(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawStruckOutText_textLayoutDraw.png"); + drawGlyphs.save("drawStruckOutText_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphs::drawOverlinedText() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s = QString::fromLatin1("Foobar"); + + QFont font; + font.setOverline(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphs glyphs = layout.glyphs().size() > 0 + ? layout.glyphs().at(0) + : QGlyphs(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawOverlineText_textLayoutDraw.png"); + drawGlyphs.save("drawOverlineText_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + +void tst_QGlyphs::drawUnderlinedText() +{ + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QString s = QString::fromLatin1("Foobar"); + + QFont font; + font.setUnderline(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphs glyphs = layout.glyphs().size() > 0 + ? layout.glyphs().at(0) + : QGlyphs(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawUnderlineText_textLayoutDraw.png"); + drawGlyphs.save("drawUnderlineText_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); +} + QTEST_MAIN(tst_QGlyphs) #include "tst_qglyphs.moc" -- cgit v0.12 From 81856e8b008099e39465543c3e85049380256cbb Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 13 Jul 2010 16:47:26 +0200 Subject: Support RTL text in QGlyphs RTL text would be positioned wrong with QGlyphs, as we would not correctly detect the direction of the text and pass it into getGlyphPositions(). The bidi analysis is the same as in the QTextLine::draw() method. Reviewed-by: Kim --- src/gui/text/qtextlayout.cpp | 5 +++- tests/auto/qglyphs/tst_qglyphs.cpp | 49 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 4dda114..43900c0 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2228,6 +2228,8 @@ QList QTextLine::glyphs() const flags |= QTextItem::Underline; if (font.strikeOut()) flags |= QTextItem::StrikeOut; + if (si.analysis.bidiLevel % 2) + flags |= QTextItem::RightToLeft; QGlyphLayout glyphLayout = eng->shapedGlyphs(&si).mid(iterator.glyphsStart, iterator.glyphsEnd - iterator.glyphsStart); @@ -2285,7 +2287,8 @@ QList QTextLine::glyphs() const QVarLengthArray glyphsArray; QVarLengthArray positionsArray; - fontEngine->getGlyphPositions(glyphLayout, QTransform(), 0, glyphsArray, positionsArray); + fontEngine->getGlyphPositions(glyphLayout, QTransform(), flags, glyphsArray, + positionsArray); Q_ASSERT(glyphsArray.size() == positionsArray.size()); QVector glyphs; diff --git a/tests/auto/qglyphs/tst_qglyphs.cpp b/tests/auto/qglyphs/tst_qglyphs.cpp index 6827b23..b75e801 100644 --- a/tests/auto/qglyphs/tst_qglyphs.cpp +++ b/tests/auto/qglyphs/tst_qglyphs.cpp @@ -69,6 +69,7 @@ private slots: void drawStruckOutText(); void drawOverlinedText(); void drawUnderlinedText(); + void drawRightToLeft(); void detach(); private: @@ -527,6 +528,54 @@ void tst_QGlyphs::drawUnderlinedText() QCOMPARE(textLayoutDraw, drawGlyphs); } +void tst_QGlyphs::drawRightToLeft() +{ +#if defined(Q_WS_MAC) + QSKIP("Unstable because of QTBUG-11145", SkipAll); +#endif + + QString s; + s.append(QChar(1575)); + s.append(QChar(1578)); + + QPixmap textLayoutDraw(1000, 1000); + QPixmap drawGlyphs(1000, 1000); + + textLayoutDraw.fill(Qt::white); + drawGlyphs.fill(Qt::white); + + QFont font; + font.setUnderline(true); + + QTextLayout layout(s); + layout.setFont(font); + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + + { + QPainter p(&textLayoutDraw); + layout.draw(&p, QPointF(50, 50)); + } + + QGlyphs glyphs = layout.glyphs().size() > 0 + ? layout.glyphs().at(0) + : QGlyphs(); + + { + QPainter p(&drawGlyphs); + p.drawGlyphs(QPointF(50, 50), glyphs); + } + +#if defined(DEBUG_SAVE_IMAGE) + textLayoutDraw.save("drawRightToLeft_textLayoutDraw.png"); + drawGlyphs.save("drawRightToLeft_drawGlyphIndexes.png"); +#endif + + QCOMPARE(textLayoutDraw, drawGlyphs); + +} + QTEST_MAIN(tst_QGlyphs) #include "tst_qglyphs.moc" -- 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 37f585ece17063a814598221c0cbb874c52d223f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 15 Jul 2010 10:05:11 +0200 Subject: Support glyphs that are wider than default width in texture glyph cache We need to reserve space for the widest possible glyph in the font Reviewed-by: Kim --- src/gui/painting/qtextureglyphcache.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 29cd82b..376219b 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -127,8 +127,12 @@ void QTextureGlyphCache::populate(QFontEngine *fontEngine, int numGlyphs, const rowHeight += margin * 2 + paddingDoubled; - if (m_w == 0) - m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; + if (m_w == 0) { + if (fontEngine->maxCharWidth() <= QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH) + m_w = QT_DEFAULT_TEXTURE_GLYPH_CACHE_WIDTH; + else + m_w = qt_next_power_of_two(fontEngine->maxCharWidth()); + } // now actually use the coords and paint the wanted glyps into cache. QHash::iterator iter = listItemCoordinates.begin(); -- cgit v0.12 From aada50574b844d30f5e8da0111590bbd92070d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 15 Jul 2010 13:55:11 +0200 Subject: Compile with qmlscene. Reviewed-by: kim --- 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 dfbc926..cdf6539 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -416,7 +416,7 @@ public: #endif #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) - static QGLExtensionFuncs qt_extensionFuncs; + static Q_OPENGL_EXPORT QGLExtensionFuncs qt_extensionFuncs; static inline QGLExtensionFuncs& extensionFuncs(const QGLContext *) { return qt_extensionFuncs; } #endif -- 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 63d0b54df365380107cea7017c7893c7d04df13e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 15 Jul 2010 20:26:23 +0200 Subject: Fix compilation after merge viewport has been renamed contentItem in 4.7 (commit 9d6ccfea89ae99b747f70ece71185868f189d0f9) (the code in master was added in commit 8c08c737837389f5ff2641219eb901ad217d3f24) --- .../graphicsitems/qdeclarativeflickable.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index f32d62b..4dc011e 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -1030,23 +1030,23 @@ void QDeclarativeFlickablePrivate::data_append(QDeclarativeListProperty int QDeclarativeFlickablePrivate::data_count(QDeclarativeListProperty *property) { - QDeclarativeItem *viewport = static_cast(property->data)->viewport; - return viewport->childItems().count() + viewport->children().count(); + QDeclarativeItem *contentItem= static_cast(property->data)->contentItem; + return contentItem->childItems().count() + contentItem->children().count(); } QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty *property, int index) { - QDeclarativeItem *viewport = static_cast(property->data)->viewport; + QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; - int childItemCount = viewport->childItems().count(); + int childItemCount = contentItem->childItems().count(); if (index < 0) return 0; if (index < childItemCount) { - return viewport->childItems().at(index)->toGraphicsObject(); + return contentItem->childItems().at(index)->toGraphicsObject(); } else { - return viewport->children().at(index - childItemCount); + return contentItem->children().at(index - childItemCount); } return 0; @@ -1054,13 +1054,13 @@ QObject *QDeclarativeFlickablePrivate::data_at(QDeclarativeListProperty void QDeclarativeFlickablePrivate::data_clear(QDeclarativeListProperty *property) { - QDeclarativeItem *viewport = static_cast(property->data)->viewport; + QDeclarativeItem *contentItem = static_cast(property->data)->contentItem; - const QList graphicsItems = viewport->childItems(); + const QList graphicsItems = contentItem->childItems(); for (int i = 0; i < graphicsItems.count(); i++) - viewport->scene()->removeItem(graphicsItems[i]); + contentItem->scene()->removeItem(graphicsItems[i]); - const QList objects = viewport->children(); + const QList objects = contentItem->children(); for (int i = 0; i < objects.count(); i++) objects[i]->setParent(0); } -- 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 c8bb76ec0b19da9e24512852dc8b00461e1a1b7b Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Thu, 22 Jul 2010 16:15:55 +0200 Subject: Fix the CGContext on Mac OS X. Sometimes we got a bad context, resulting in wrong paintings. It also unify the raster engine behavior among platforms. Reviewed-by: Jason Barron --- src/gui/graphicsview/qgraphicsview_p.h | 34 +++++++++++++++++------------- src/gui/kernel/qcocoaview_mac.mm | 4 ++-- src/gui/kernel/qt_cocoa_helpers_mac.mm | 2 +- src/gui/painting/qwindowsurface_raster.cpp | 16 ++++---------- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index 7bd9ecb..62be800 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -62,6 +62,7 @@ #include "qgraphicssceneevent.h" #include #include +#include QT_BEGIN_NAMESPACE @@ -180,21 +181,24 @@ public: inline void dispatchPendingUpdateRequests() { -#ifndef Q_WS_MAC - // QWidget::update() works slightly different on the Mac; it's not part of - // our backing store so it needs special threatment. - if (qt_widget_private(viewport)->paintOnScreen()) - QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest); - else - QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest); -#else - // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa) - // is called, which means there's a pending update request. We want to dispatch it - // now because otherwise graphics view updates would require two - // round-trips in the event loop before the item is painted. - extern void qt_mac_dispatchPendingUpdateRequests(QWidget *); - qt_mac_dispatchPendingUpdateRequests(viewport->window()); -#endif +#ifdef Q_WS_MAC + // QWidget::update() works slightly different on the Mac without the raster engine; + // it's not part of our backing store so it needs special threatment. + if (QApplicationPrivate::graphics_system_name != "raster") { + // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa) + // is called, which means there's a pending update request. We want to dispatch it + // now because otherwise graphics view updates would require two + // round-trips in the event loop before the item is painted. + extern void qt_mac_dispatchPendingUpdateRequests(QWidget *); + qt_mac_dispatchPendingUpdateRequests(viewport->window()); + } else +#endif // !Q_WS_MAC + { + if (qt_widget_private(viewport)->paintOnScreen()) + QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest); + else + QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest); + } } void setUpdateClip(QGraphicsItem *); diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 3665557..c9fa79b 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -498,9 +498,9 @@ static int qCocoaViewCount = 0; return; if (QApplicationPrivate::graphicsSystem() != 0) { - if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) - bs->markDirty(qwidget->rect(), qwidget); + qwidget->update(qwidget->rect()); qwidgetprivate->syncBackingStore(qwidget->rect()); + return; } CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index e3478e6..2eee434 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1332,7 +1332,7 @@ CGContextRef qt_mac_graphicsContextFor(QWidget *widget) CGrafPtr port = GetWindowPort(qt_mac_window_for(widget)); QDBeginCGContext(port, &context); #else - CGContextRef context = reinterpret_cast([[qt_mac_window_for(widget) graphicsContext] graphicsPort]); + CGContextRef context = (CGContextRef)[[NSGraphicsContext graphicsContextWithWindow:qt_mac_window_for(widget)] graphicsPort]; #endif return context; } diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index f3e1e4e..6a2cb1e 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -248,10 +248,6 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi #ifdef Q_WS_MAC -// qDebug() << "Flushing" << widget << rgn << offset; - -// d->image->image.save("flush.png"); - Q_UNUSED(offset); // Get a context for the widget. #ifndef QT_MAC_USE_COCOA @@ -282,23 +278,19 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi CGImageRef subImage = CGImageCreateWithImageInRect(image, area); qt_mac_drawCGImage(context, &area, subImage); + CGImageRelease(subImage); CGImageRelease(image); -// CGSize size = { d->image->image.width(), d->image->image.height() }; -// CGLayerRef layer = CGLayerCreateWithContext(d->image->cg, size, 0); -// CGPoint pt = { 0, 0 }; -// CGContextDrawLayerAtPoint(context, pt, layer); -// CGLayerRelease(layer); - - // Restore context. - CGContextRestoreGState(context); #ifndef QT_MAC_USE_COCOA QDEndCGContext(port, &context); #else CGContextFlush(context); #endif + // Restore context. + CGContextRestoreGState(context); + #endif // Q_WS_MAC #ifdef Q_OS_SYMBIAN -- cgit v0.12 From d9d877326b13c55dc33b1cac13f3ee70e8de62bf Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 22 Jul 2010 17:53:59 +0200 Subject: Make QPalette::operator== return false if the currentColorGroup differs This was affecting QLineEdit's selected text color when the window is inactive. Task-number: QTBUG-697 Reviewed-by: ogoffart --- src/gui/kernel/qpalette.cpp | 2 ++ src/gui/widgets/qlineedit.cpp | 2 +- tests/auto/qpalette/tst_qpalette.cpp | 30 ++++++++++++++++++++++++++++++ tests/auto/qwidget/tst_qwidget.cpp | 6 +++--- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 98e8f66..910dfa9 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -876,6 +876,8 @@ void QPalette::detach() */ bool QPalette::operator==(const QPalette &p) const { + if (p.currentColorGroup() != current_group) + return false; if (isCopyOf(p)) return true; for(int grp = 0; grp < (int)NColorGroups; grp++) { diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 1bffde1..98f0f44 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1946,7 +1946,7 @@ void QLineEdit::paintEvent(QPaintEvent *) if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ flags |= QLineControl::DrawSelections; // Palette only used for selections/mask and may not be in sync - if(d->control->palette() != pal) + if (d->control->palette() != pal) d->control->setPalette(pal); } diff --git a/tests/auto/qpalette/tst_qpalette.cpp b/tests/auto/qpalette/tst_qpalette.cpp index 2501f8d..65eabbd 100644 --- a/tests/auto/qpalette/tst_qpalette.cpp +++ b/tests/auto/qpalette/tst_qpalette.cpp @@ -65,6 +65,7 @@ public slots: private slots: void roleValues_data(); void roleValues(); + void operators(); }; tst_QPalette::tst_QPalette() @@ -128,5 +129,34 @@ void tst_QPalette::roleValues() QCOMPARE(role, value); } +void tst_QPalette::operators() +{ + { + QPalette palette = qApp->palette(); + QPalette copy = palette; + QCOMPARE(palette.currentColorGroup(), copy.currentColorGroup()); + QCOMPARE(palette.resolve(), copy.resolve()); + QVERIFY(copy.isCopyOf(palette)); + + } + + { + QPalette palette = qApp->palette(); + QPalette copy = palette; + copy.setColor(QPalette::Base, palette.color(QPalette::Base).lighter()); + QVERIFY(palette != copy); + QVERIFY(!copy.isCopyOf(palette)); + } + + { + QPalette palette = qApp->palette(); + QPalette copy = palette; + copy.setCurrentColorGroup(QPalette::Inactive); + palette.setCurrentColorGroup(QPalette::Active); + QVERIFY(palette != copy); + } + +} + QTEST_MAIN(tst_QPalette) #include "tst_qpalette.moc" diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index 2d559c8..f0c40e8 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -988,8 +988,8 @@ void tst_QWidget::palettePropagation2() { // ! Note, the code below is executed in tst_QWidget's constructor. // QPalette palette; - // font.setColor(QPalette::ToolTipBase, QColor(12, 13, 14)); - // font.setColor(QPalette::Text, QColor(21, 22, 23)); + // palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14)); + // palette.setColor(QPalette::Text, QColor(21, 22, 23)); // qApp->setPalette(palette, "QPropagationTestWidget"); QWidget *root = new QWidget; @@ -1000,7 +1000,7 @@ void tst_QWidget::palettePropagation2() QWidget *child4 = new QWidget(child3); QWidget *child5 = new QWidget(child4); root->show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(root); // These colors are unlikely to be imposed on the default palette of // QWidget ;-). -- 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 f8c82039e9b665cabaf605a3d363108e732d8205 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Fri, 23 Jul 2010 11:01:38 +0200 Subject: Revert "Make QPalette::operator== return false if the currentColorGroup differs" This reverts commit d9d877326b13c55dc33b1cac13f3ee70e8de62bf. The behavior change it implied was bigger than expected and made too many autotests fail. Will document better that the currentColorGroup is not taken into account when comparing palettes. --- src/gui/kernel/qpalette.cpp | 2 -- src/gui/widgets/qlineedit.cpp | 2 +- tests/auto/qpalette/tst_qpalette.cpp | 30 ------------------------------ tests/auto/qwidget/tst_qwidget.cpp | 6 +++--- 4 files changed, 4 insertions(+), 36 deletions(-) diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 910dfa9..98e8f66 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -876,8 +876,6 @@ void QPalette::detach() */ bool QPalette::operator==(const QPalette &p) const { - if (p.currentColorGroup() != current_group) - return false; if (isCopyOf(p)) return true; for(int grp = 0; grp < (int)NColorGroups; grp++) { diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 98f0f44..1bffde1 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1946,7 +1946,7 @@ void QLineEdit::paintEvent(QPaintEvent *) if (d->control->hasSelectedText() || (d->cursorVisible && !d->control->inputMask().isEmpty() && !d->control->isReadOnly())){ flags |= QLineControl::DrawSelections; // Palette only used for selections/mask and may not be in sync - if (d->control->palette() != pal) + if(d->control->palette() != pal) d->control->setPalette(pal); } diff --git a/tests/auto/qpalette/tst_qpalette.cpp b/tests/auto/qpalette/tst_qpalette.cpp index 65eabbd..2501f8d 100644 --- a/tests/auto/qpalette/tst_qpalette.cpp +++ b/tests/auto/qpalette/tst_qpalette.cpp @@ -65,7 +65,6 @@ public slots: private slots: void roleValues_data(); void roleValues(); - void operators(); }; tst_QPalette::tst_QPalette() @@ -129,34 +128,5 @@ void tst_QPalette::roleValues() QCOMPARE(role, value); } -void tst_QPalette::operators() -{ - { - QPalette palette = qApp->palette(); - QPalette copy = palette; - QCOMPARE(palette.currentColorGroup(), copy.currentColorGroup()); - QCOMPARE(palette.resolve(), copy.resolve()); - QVERIFY(copy.isCopyOf(palette)); - - } - - { - QPalette palette = qApp->palette(); - QPalette copy = palette; - copy.setColor(QPalette::Base, palette.color(QPalette::Base).lighter()); - QVERIFY(palette != copy); - QVERIFY(!copy.isCopyOf(palette)); - } - - { - QPalette palette = qApp->palette(); - QPalette copy = palette; - copy.setCurrentColorGroup(QPalette::Inactive); - palette.setCurrentColorGroup(QPalette::Active); - QVERIFY(palette != copy); - } - -} - QTEST_MAIN(tst_QPalette) #include "tst_qpalette.moc" diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f0c40e8..2d559c8 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -988,8 +988,8 @@ void tst_QWidget::palettePropagation2() { // ! Note, the code below is executed in tst_QWidget's constructor. // QPalette palette; - // palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14)); - // palette.setColor(QPalette::Text, QColor(21, 22, 23)); + // font.setColor(QPalette::ToolTipBase, QColor(12, 13, 14)); + // font.setColor(QPalette::Text, QColor(21, 22, 23)); // qApp->setPalette(palette, "QPropagationTestWidget"); QWidget *root = new QWidget; @@ -1000,7 +1000,7 @@ void tst_QWidget::palettePropagation2() QWidget *child4 = new QWidget(child3); QWidget *child5 = new QWidget(child4); root->show(); - QTest::qWaitForWindowShown(root); + QTest::qWait(100); // These colors are unlikely to be imposed on the default palette of // QWidget ;-). -- 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 9b06a827cbb3967e7476ca0888f8bf3b171424f2 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 26 Jul 2010 12:44:06 +0200 Subject: QAbstractSocket: Remove old workaround This old workaround hurts performance on Linux but is only needed on old kernels and in corner cases (using a local socket with QAbstractSocket). Removing it. Reviewed-by: Peter Hartmann --- src/network/socket/qabstractsocket.cpp | 22 ---------------------- src/network/socket/qabstractsocket_p.h | 3 --- 2 files changed, 25 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index b604e89..171fbb6 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -466,9 +466,6 @@ QAbstractSocketPrivate::QAbstractSocketPrivate() peerPort(0), socketEngine(0), cachedSocketDescriptor(-1), -#ifdef Q_OS_LINUX - addToBytesAvailable(0), -#endif readBufferMaxSize(0), readBuffer(QABSTRACTSOCKET_BUFFERSIZE), writeBuffer(QABSTRACTSOCKET_BUFFERSIZE), @@ -1132,10 +1129,6 @@ bool QAbstractSocketPrivate::readFromSocket() Q_Q(QAbstractSocket); // Find how many bytes we can read from the socket layer. qint64 bytesToRead = socketEngine->bytesAvailable(); -#ifdef Q_OS_LINUX - if (bytesToRead > 0) // ### See setSocketDescriptor() - bytesToRead += addToBytesAvailable; -#endif if (bytesToRead == 0) { // Under heavy load, certain conditions can trigger read notifications // for socket notifiers on which there is no activity. If we continue @@ -1340,10 +1333,6 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint d->localAddress.clear(); d->peerAddress.clear(); d->peerName = hostName; -#ifdef Q_OS_LINUX - // ### See setSocketDescriptor(). - d->addToBytesAvailable = 0; -#endif if (d->hostLookupId != -1) { QHostInfo::abortHostLookup(d->hostLookupId); d->hostLookupId = -1; @@ -1603,17 +1592,6 @@ bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState sock d->peerAddress = d->socketEngine->peerAddress(); d->cachedSocketDescriptor = socketDescriptor; -#ifdef Q_OS_LINUX - // ### This is a workaround for certain broken Linux kernels, when using - // QTcpSocket with a Unix domain socket. It was introduced around 2.6.9, - // and fixed at some point after that. - // http://archive.linux-usenet.com/index-t-73300.html - // We can provide a better workaround for this: readFromSocket() can loop - // while reading, but this must happen without triggering an implicit - // close because of reading after the socket has closed. - d->addToBytesAvailable = 4096; -#endif - return true; } diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h index b51c301..6c333d3 100644 --- a/src/network/socket/qabstractsocket_p.h +++ b/src/network/socket/qabstractsocket_p.h @@ -138,9 +138,6 @@ public: void setupSocketNotifiers(); bool readFromSocket(); -#ifdef Q_OS_LINUX - qint64 addToBytesAvailable; -#endif qint64 readBufferMaxSize; QRingBuffer readBuffer; QRingBuffer writeBuffer; -- cgit v0.12 From 83dbd809a0af50ac91d1e36a6b0437fc263958f3 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 26 Jul 2010 13:05:15 +0200 Subject: QNAM: Stop half-supporting wrong way of deleting We clearly state that deleteLater() should be used. Therefore stop the usage of QPointer to track deletion since it is bad for performance and only worked in some cases anyway. Reviewed-by: Peter Hartmann --- .../access/qhttpnetworkconnectionchannel.cpp | 22 ---------------------- src/network/access/qnetworkreplyimpl.cpp | 13 ++++--------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index d3576dd..71a4de3 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -419,15 +419,8 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() bytes = replyPrivate->readBodyFast(socket, &replyPrivate->responseData); replyPrivate->totalProgress += bytes; if (replyPrivate->shouldEmitSignals()) { - QPointer replyPointer = reply; emit reply->readyRead(); - // make sure that the reply is valid - if (replyPointer.isNull()) - return; emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); - // make sure that the reply is valid - if (replyPointer.isNull()) - return; } } else @@ -445,17 +438,10 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() if (!replyPrivate->autoDecompress) { replyPrivate->totalProgress += bytes; if (replyPrivate->shouldEmitSignals()) { - QPointer replyPointer = reply; // important: At the point of this readyRead(), the byteDatas list must be empty, // else implicit sharing will trigger memcpy when the user is reading data! emit reply->readyRead(); - // make sure that the reply is valid - if (replyPointer.isNull()) - return; emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); - // make sure that the reply is valid - if (replyPointer.isNull()) - return; } } #ifndef QT_NO_COMPRESS @@ -589,18 +575,10 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete) reply->d_func()->totalProgress += inflated.size(); reply->d_func()->appendUncompressedReplyData(inflated); if (reply->d_func()->shouldEmitSignals()) { - QPointer replyPointer = reply; // important: At the point of this readyRead(), inflated must be cleared, // else implicit sharing will trigger memcpy when the user is reading data! emit reply->readyRead(); - // make sure that the reply is valid - if (replyPointer.isNull()) - return true; emit reply->dataReadProgress(reply->d_func()->totalProgress, 0); - // make sure that the reply is valid - if (replyPointer.isNull()) - return true; - } } } else { diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 31ee2a4..3798ac2 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -543,8 +543,6 @@ void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions() { Q_Q(QNetworkReplyImpl); - QPointer qq = q; - QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader); if (preMigrationDownloaded != Q_INT64_C(-1)) totalSize = totalSize.toLongLong() + preMigrationDownloaded; @@ -555,13 +553,10 @@ void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions() // else implicit sharing will trigger memcpy when the user is reading data! emit q->readyRead(); - // hopefully we haven't been deleted here - if (!qq.isNull()) { - resumeNotificationHandling(); - // do we still have room in the buffer? - if (nextDownstreamBlockSize() > 0) - backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); - } + resumeNotificationHandling(); + // do we still have room in the buffer? + if (nextDownstreamBlockSize() > 0) + backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); } // this is used when it was fetched from the cache, right? -- cgit v0.12 From 2636e58e748d066096472bc9822f89ba9d4b47a3 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Tue, 27 Jul 2010 14:46:01 +0200 Subject: Fix a memory leak in the QTestLib. A comment string wasn't deleted in expectedFailMode. Reviewed-by: Harald Fernengel --- src/testlib/qtestresult.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index 8c52a82..bbe3e7f 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -191,10 +191,13 @@ bool QTestResult::expectFail(const char *dataIndex, const char *comment, QTEST_ASSERT(comment); QTEST_ASSERT(mode > 0); - if (!isExpectFailData(dataIndex)) + if (!isExpectFailData(dataIndex)) { + delete[] comment; return true; // we don't care + } if (QTest::expectFailMode) { + delete[] comment; clearExpectFail(); addFailure("Already expecting a fail", file, line); return false; -- 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 457539959363245082add602c186239be0f71af1 Mon Sep 17 00:00:00 2001 From: Jedrzej Nowacki Date: Wed, 28 Jul 2010 13:57:53 +0200 Subject: Increase test coverage for QScriptValue. New test value for tst_QScriptValue::getSetData testcase. Setting data is allowed only for an object. Reviewed-by: Kent Hansen --- tests/auto/qscriptvalue/tst_qscriptvalue.cpp | 43 +++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp index 8aa4e711..1d8706c 100644 --- a/tests/auto/qscriptvalue/tst_qscriptvalue.cpp +++ b/tests/auto/qscriptvalue/tst_qscriptvalue.cpp @@ -2234,19 +2234,36 @@ void tst_QScriptValue::getSetScope() void tst_QScriptValue::getSetData() { QScriptEngine eng; - QScriptValue object = eng.newObject(); - QVERIFY(!object.data().isValid()); - QScriptValue v1(true); - object.setData(v1); - QVERIFY(object.data().strictlyEquals(v1)); - QScriptValue v2(123); - object.setData(v2); - QVERIFY(object.data().strictlyEquals(v2)); - QScriptValue v3 = eng.newObject(); - object.setData(v3); - QVERIFY(object.data().strictlyEquals(v3)); - object.setData(QScriptValue()); - QVERIFY(!object.data().isValid()); + { + QScriptValue object = eng.newObject(); + QVERIFY(!object.data().isValid()); + QScriptValue v1(true); + object.setData(v1); + QVERIFY(object.data().strictlyEquals(v1)); + QScriptValue v2(123); + object.setData(v2); + QVERIFY(object.data().strictlyEquals(v2)); + QScriptValue v3 = eng.newObject(); + object.setData(v3); + QVERIFY(object.data().strictlyEquals(v3)); + object.setData(QScriptValue()); + QVERIFY(!object.data().isValid()); + } + { + QScriptValue value = eng.undefinedValue(); + QVERIFY(!value.data().isValid()); + QScriptValue v1(true); + value.setData(v1); + QVERIFY(!value.data().isValid()); + QScriptValue v2(123); + value.setData(v2); + QVERIFY(!value.data().isValid()); + QScriptValue v3 = eng.newObject(); + value.setData(v3); + QVERIFY(!value.data().isValid()); + value.setData(QScriptValue()); + QVERIFY(!value.data().isValid()); + } } class TestScriptClass : public QScriptClass -- cgit v0.12 From 96c8fdd87878da258286e053edf1046750485821 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 29 Jul 2010 16:09:04 +0200 Subject: Setting a timeSpec on QDateTimeEdit breaks the edit when only time is shown Because of the time zone change we get an "overflow" in the min and max time. For example min 00:00:00 becomes 01:00:00 and max 23:59:59 becomes 00:59:59 which is an invalid time span and the displayed time gets fixed to the newly set min/max value. Autotest included. Task-number: QTBUG-12384 Reviewed-by: Gabriel --- src/gui/widgets/qdatetimeedit.cpp | 15 +++++++++++++++ tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 50fa9c9..e272ce4 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -889,7 +889,13 @@ void QDateTimeEdit::setDisplayFormat(const QString &format) const bool dateShown = (d->sections & DateSections_Mask); Q_ASSERT(dateShown || timeShown); if (timeShown && !dateShown) { + QTime time = d->value.toTime(); setDateRange(d->value.toDate(), d->value.toDate()); + if (d->minimum.toTime() >= d->maximum.toTime()) { + setTimeRange(QDATETIMEEDIT_TIME_MIN, QDATETIMEEDIT_TIME_MAX); + // if the time range became invalid during the adjustment, the time would have been reset + setTime(time); + } } else if (dateShown && !timeShown) { setTimeRange(QDATETIMEEDIT_TIME_MIN, QDATETIMEEDIT_TIME_MAX); d->value = QDateTime(d->value.toDate(), QTime(), d->spec); @@ -1667,6 +1673,15 @@ void QDateTimeEditPrivate::updateTimeSpec() minimum = minimum.toDateTime().toTimeSpec(spec); maximum = maximum.toDateTime().toTimeSpec(spec); value = value.toDateTime().toTimeSpec(spec); + + // time zone changes can lead to 00:00:00 becomes 01:00:00 and 23:59:59 becomes 00:59:59 (invalid range) + const bool dateShown = (sections & QDateTimeEdit::DateSections_Mask); + if (!dateShown) { + if (minimum.toTime() >= maximum.toTime()){ + minimum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MIN, spec); + maximum = QDateTime(value.toDate(), QDATETIMEEDIT_TIME_MAX, spec); + } + } } void QDateTimeEditPrivate::updateEdit() diff --git a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp index 3125258..50b0e0a 100644 --- a/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp +++ b/tests/auto/qdatetimeedit/tst_qdatetimeedit.cpp @@ -273,6 +273,9 @@ private slots: void task196924(); void focusNextPrevChild(); + + void taskQTBUG_12384_timeSpecShowTimeOnly(); + private: EditorDateEdit* testWidget; QWidget *testFocusWidget; @@ -3420,7 +3423,20 @@ void tst_QDateTimeEdit::focusNextPrevChild() QCOMPARE(edit.currentSection(), QDateTimeEdit::MonthSection); } +void tst_QDateTimeEdit::taskQTBUG_12384_timeSpecShowTimeOnly() +{ + QDateTime time = QDateTime::fromString("20100723 04:02:40", "yyyyMMdd hh:mm:ss"); + time.setTimeSpec(Qt::UTC); + + EditorDateEdit edit; + edit.setDisplayFormat("hh:mm:ss"); + edit.setTimeSpec(Qt::UTC); + edit.setDateTime(time); + QCOMPARE(edit.minimumTime(), QTime(0, 0, 0, 0)); + QCOMPARE(edit.maximumTime(), QTime(23, 59, 59, 999)); + QCOMPARE(edit.time(), time.time()); +} QTEST_MAIN(tst_QDateTimeEdit) #include "tst_qdatetimeedit.moc" -- cgit v0.12 From 79fc59bb9dc62a9c0ee05a057973c6b4408f616b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 30 Jul 2010 12:00:24 +0200 Subject: tst_qgl: enable back on mac QTBUG-12138 is closed --- tests/auto/qgl/tst_qgl.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp index 085ca54..5fe453b 100644 --- a/tests/auto/qgl/tst_qgl.cpp +++ b/tests/auto/qgl/tst_qgl.cpp @@ -72,9 +72,7 @@ public: tst_QGL(); virtual ~tst_QGL(); -#ifndef Q_WS_MAC //All tests are disabled on mac as they crash and prevent integration, see QTBUG-12138 private slots: -#endif void getSetCheck(); void openGLVersionCheck(); void graphicsViewClipping(); -- cgit v0.12 From 6699f65e276d24c99d0937f1bb460ced176076d8 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 30 Jul 2010 12:44:19 +0200 Subject: Minor optimization Make internal qpf2 font tag array read-only. Reviewed-by: Paul Olav Tvete --- src/gui/text/qpfutil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qpfutil.cpp b/src/gui/text/qpfutil.cpp index 376f49c..7f8c58e 100644 --- a/src/gui/text/qpfutil.cpp +++ b/src/gui/text/qpfutil.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -static QFontEngineQPF::TagType tagTypes[QFontEngineQPF::NumTags] = { +static const QFontEngineQPF::TagType tagTypes[QFontEngineQPF::NumTags] = { QFontEngineQPF::StringType, // FontName QFontEngineQPF::StringType, // FileName QFontEngineQPF::UInt32Type, // FileIndex -- cgit v0.12 From 7fb31670f080c224249279c35240a8eb95f8d877 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 20 Jul 2010 14:26:06 +0200 Subject: Add QTextFragment::glyphs() accessor Add a function to retrieve fonts, glyph indexes and positions needed to visualize the text in a QTextFragment to allow converting the text of a QTextDocument to QGlyphs objects. Reviewed-by: Simon Hausmann --- src/gui/text/qtextlayout.cpp | 15 ++++++++++++--- src/gui/text/qtextlayout.h | 3 ++- src/gui/text/qtextobject.cpp | 29 +++++++++++++++++++++++++++++ src/gui/text/qtextobject.h | 3 +++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index aff88f6..531e46b 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1134,7 +1134,7 @@ QList QTextLayout::glyphs() const { QList glyphs; for (int i=0; ilines.size(); ++i) - glyphs += QTextLine(i, d).glyphs(); + glyphs += QTextLine(i, d).glyphs(-1, -1); return glyphs; } @@ -2198,13 +2198,16 @@ namespace { /*! \internal - Returns the glyph indexes and positions for all glyphs in this QTextLine. + Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in + QScriptItems that overlap with the range defined by \a from and \a length. The arguments + specify characters, relative to the text in the layout. Note that it is not possible to + use this function to retrieve a subset of the glyphs in a QScriptItem. \since 4.8 \sa QTextLayout::glyphs() */ -QList QTextLine::glyphs() const +QList QTextLine::glyphs(int from, int length) const { const QScriptLine &line = eng->lines[i]; @@ -2217,7 +2220,13 @@ QList QTextLine::glyphs() const qreal y = line.y.toReal() + line.base().toReal(); while (!iterator.atEnd()) { QScriptItem &si = iterator.next(); + if (si.analysis.flags >= QScriptAnalysis::TabOrObject) + continue; + QPointF pos(iterator.x.toReal(), y); + if (from >= 0 && length >= 0 && + (from >= si.position + eng->length(&si) || from + length <= si.position)) + continue; QFont font = eng->font(si); diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h index f6aaf22..32d6d0e 100644 --- a/src/gui/text/qtextlayout.h +++ b/src/gui/text/qtextlayout.h @@ -239,9 +239,10 @@ public: private: QTextLine(int line, QTextEngine *e) : i(line), eng(e) {} void layout_helper(int numGlyphs); - QList glyphs() const; + QList glyphs(int from, int length) const; friend class QTextLayout; + friend class QTextFragment; int i; QTextEngine *eng; }; diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 5fb3384..e366f77 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -1650,6 +1650,35 @@ QTextBlock::iterator &QTextBlock::iterator::operator--() than the \a other text fragment; otherwise returns false. */ +/*! + Returns the glyphs of this text fragment. The positions of the glyphs are + relative to the position of the QTextBlock's layout. + + \sa QGlyphs, QTextBlock::layout(), QTextLayout::position(), QPainter::drawGlyphs() +*/ +QList QTextFragment::glyphs() const +{ + if (!p || !n) + return QList(); + + int pos = position(); + int len = length(); + if (len == 0) + return QList(); + + int blockNode = p->blockMap().findNode(pos); + + const QTextBlockData *blockData = p->blockMap().fragment(blockNode); + QTextLayout *layout = blockData->layout; + + QList ret; + for (int i=0; ilineCount(); ++i) { + QTextLine textLine = layout->lineAt(i); + ret += textLine.glyphs(pos, len); + } + + return ret; +} /*! Returns the position of this text fragment in the document. diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h index a573a26..332458d 100644 --- a/src/gui/text/qtextobject.h +++ b/src/gui/text/qtextobject.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -315,6 +316,8 @@ public: int charFormatIndex() const; QString text() const; + QList glyphs() const; + private: const QTextDocumentPrivate *p; int n; -- 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 794c7c77f28bb530db017cc25a5e33e00933253b Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Tue, 3 Aug 2010 13:36:22 +0200 Subject: Fix the issue of resizing a window with the raster engine on Mac OS X. Reviewed-by: Richard Moe Gustavsen --- src/gui/kernel/qcocoaview_mac.mm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 5780ebc..3229e71 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -532,9 +532,23 @@ static int qCocoaViewCount = 0; if (!qwidget) return; + // We use a different graphics system. if (QApplicationPrivate::graphicsSystem() != 0) { - qwidget->update(qwidget->rect()); - qwidgetprivate->syncBackingStore(qwidget->rect()); + + // Qt handles the painting occuring inside the window. + // Cocoa also keeps track of all widgets as NSView and therefore might + // ask for a repainting of a widget even if Qt is already taking care of it. + // + // The only valid reason for Cocoa to call drawRect: is for window manipulation + // (ie. resize, ...). + // + // Qt will then forward the update to the children. + if (qwidget->isWindow()) { + qwidget->update(qwidget->rect()); + qwidgetprivate->syncBackingStore(qwidget->rect()); + } + + // Since we don't want to use the native engine, we must exit. return; } -- 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 8435ba93fad9eb799764eb3b66a8a9838db3fea3 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 3 Aug 2010 18:33:07 +0200 Subject: Remove obsolete code & workarounds for unsupported versions of MS Visual C++ The minimum supported version of MS Visual C++ 2003, which is _MSC_VER 1310. Merge-request: 756 Reviewed-by: Olivier Goffart --- src/corelib/concurrent/qtconcurrentcompilertest.h | 6 -- src/corelib/global/qendian.h | 4 +- src/corelib/global/qglobal.h | 60 +++--------- src/corelib/kernel/qobject.h | 101 +-------------------- src/corelib/kernel/qvariant.cpp | 8 -- src/corelib/tools/qmap.h | 4 +- src/corelib/tools/qsharedpointer_impl.h | 1 - src/corelib/tools/qstring.cpp | 4 - src/corelib/tools/qstring.h | 9 +- src/corelib/tools/qvector.h | 3 - .../qml/parser/qdeclarativejsengine_p.h | 6 -- src/gui/kernel/qwidget.h | 8 -- src/gui/text/qcssparser.cpp | 8 -- src/gui/text/qfontdatabase.cpp | 4 - src/network/kernel/qhostinfo_win.cpp | 5 - src/script/api/qscriptengine.cpp | 7 -- src/script/api/qscriptengine.h | 12 +-- src/script/api/qscriptvalue.cpp | 12 +-- src/sql/drivers/odbc/qsql_odbc.cpp | 37 +++----- src/testlib/qtest_global.h | 2 +- tests/auto/collections/tst_collections.cpp | 11 --- tests/auto/qwidget/tst_qwidget.cpp | 28 +----- tools/configure/configureapp.cpp | 7 +- tools/configure/environment.cpp | 12 +-- tools/configure/environment.h | 4 - 25 files changed, 37 insertions(+), 326 deletions(-) diff --git a/src/corelib/concurrent/qtconcurrentcompilertest.h b/src/corelib/concurrent/qtconcurrentcompilertest.h index 982a50c..4fbb3d7 100644 --- a/src/corelib/concurrent/qtconcurrentcompilertest.h +++ b/src/corelib/concurrent/qtconcurrentcompilertest.h @@ -51,12 +51,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Core) -#ifdef Q_CC_MSVC -# if _MSC_VER < 1300 -# define QT_CONURRENT_NONSTANDARD_COMPILER -# endif -#endif - #if defined (Q_CC_MSVC) && (_MSC_VER < 1300) # define QT_TYPENAME #else diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index d53504a..e0e946b 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -89,7 +89,7 @@ template inline void qToUnaligned(const T src, uchar *dest) * and return the value in host-endian encoding. * There is no requirement that \a src must be aligned. */ -#if defined Q_CC_MSVC && _MSC_VER < 1300 || defined Q_CC_SUN +#if defined Q_CC_SUN inline quint64 qFromLittleEndian_helper(const uchar *src, quint64 *dest) { return 0 @@ -177,7 +177,7 @@ template <> inline qint16 qFromLittleEndian(const uchar *src) * and return the value in host-endian encoding. * There is no requirement that \a src must be aligned. */ -#if defined Q_CC_MSVC && _MSC_VER < 1300 || defined Q_CC_SUN +#if defined Q_CC_SUN inline quint64 qFromBigEndian_helper(const uchar *src, quint64 *dest) { return 0 diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 519e6e0..1d78cbd 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -383,31 +383,12 @@ namespace QT_NAMESPACE {} #elif defined(_MSC_VER) # define Q_CC_MSVC -/* proper support of bool for _MSC_VER >= 1100 */ +# define Q_CC_MSVC_NET # define Q_CANNOT_DELETE_CONSTANT # define Q_OUTOFLINE_TEMPLATE inline # define Q_NO_TEMPLATE_FRIENDS -# define QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION -# define Q_ALIGNOF(type) __alignof(type) -# define Q_DECL_ALIGN(n) __declspec(align(n)) - -/* Visual C++.Net issues for _MSC_VER >= 1300 */ -# if _MSC_VER >= 1300 -# define Q_CC_MSVC_NET -# if _MSC_VER < 1310 || (defined(Q_OS_WIN64) && defined(_M_IA64)) -# define Q_TYPENAME -# else -# undef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION -# endif -# else -# define Q_NO_USING_KEYWORD -# define QT_NO_MEMBER_TEMPLATES -# endif -# if _MSC_VER < 1310 -# define QT_NO_QOBJECT_CHECK -# define Q_TYPENAME -# define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS -# endif +# define Q_ALIGNOF(type) __alignof(type) +# define Q_DECL_ALIGN(n) __declspec(align(n)) /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ # if defined(__INTEL_COMPILER) # define Q_CC_INTEL @@ -924,10 +905,10 @@ redefine to built-in booleans to make autotests work properly */ #endif /* - Proper for-scoping in VC++6 and MIPSpro CC + Proper for-scoping in MIPSpro CC */ #ifndef QT_NO_KEYWORDS -# if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64)) +# if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64)) # define for if(0){}else for # endif #endif @@ -951,7 +932,7 @@ redefine to built-in booleans to make autotests work properly */ # define Q_DECL_DEPRECATED Q_DECL_DEPRECATED #elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT) # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) -#elif defined(Q_CC_MSVC) && (_MSC_VER >= 1300) +#elif defined(Q_CC_MSVC) # define Q_DECL_DEPRECATED __declspec(deprecated) # if defined (Q_CC_INTEL) # define Q_DECL_VARIABLE_DEPRECATED @@ -1053,7 +1034,7 @@ redefine to built-in booleans to make autotests work properly */ #else # define QT_FASTCALL #endif -# elif defined(Q_CC_MSVC) && (_MSC_VER > 1300 || defined(Q_CC_INTEL)) +# elif defined(Q_CC_MSVC) # define QT_FASTCALL __fastcall # else # define QT_FASTCALL @@ -1721,12 +1702,7 @@ inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; } #if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB) # define Q_FUNC_INFO __PRETTY_FUNCTION__ #elif defined(_MSC_VER) - /* MSVC 2002 doesn't have __FUNCSIG__ nor can it handle QT_STRINGIFY. */ -# if _MSC_VER <= 1300 -# define Q_FUNC_INFO __FILE__ "(line number unavailable)" -# else -# define Q_FUNC_INFO __FUNCSIG__ -# endif +# define Q_FUNC_INFO __FUNCSIG__ #else # if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN) # define Q_FUNC_INFO __FILE__ "(line number unavailable)" @@ -2149,10 +2125,6 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); # pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */ # pragma warning(disable: 4710) /* function not inlined */ # pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */ -# if _MSC_VER < 1300 -# pragma warning(disable: 4284) /* return type for 'type1::operator ->' is 'type2 *' */ - /* (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) */ -# endif # elif defined(Q_CC_BOR) # pragma option -w-inl # pragma option -w-aus @@ -2226,13 +2198,9 @@ public: #define Q_DECLARE_FLAGS(Flags, Enum)\ typedef QFlags Flags; -#if defined Q_CC_MSVC && _MSC_VER < 1300 -# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) -#else -# define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ +#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \ { return QIncompatibleFlag(int(f1) | f2); } -#endif #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ inline QFlags operator|(Flags::enum_type f1, Flags::enum_type f2) \ @@ -2289,9 +2257,9 @@ template inline const QForeachContainer *qForeachContainer(const QForeachContainerBase *base, const T *) { return static_cast *>(base); } -#if (defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) && !defined(Q_CC_INTEL)) || defined(Q_CC_MIPS) +#if defined(Q_CC_MIPS) /* - Proper for-scoping in VC++6 and MIPSpro CC + Proper for-scoping in MIPSpro CC */ # define Q_FOREACH(variable,container) \ if(0){}else \ @@ -2648,12 +2616,6 @@ QT_LICENSED_MODULE(DBus) # define QT_NO_QFUTURE #endif -// MSVC 6.0 and MSVC .NET 2002, can`t handle the map(), etc templates, -// but the QFuture class compiles. -#if (defined(Q_CC_MSVC) && _MSC_VER <= 1300) -# define QT_NO_CONCURRENT -#endif - // gcc 3 version has problems with some of the // map/filter overloads. #if defined(Q_CC_GNU) && (__GNUC__ < 4) diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index d26f078..7f0084c 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -77,18 +77,10 @@ class QObjectUserData; typedef QList QObjectList; -#if defined Q_CC_MSVC && _MSC_VER < 1300 -template inline T qFindChild(const QObject *o, const QString &name = QString(), T = 0); -template inline QList qFindChildren(const QObject *o, const QString &name = QString(), T = 0); -# ifndef QT_NO_REGEXP -template inline QList qFindChildren(const QObject *o, const QRegExp &re, T = 0); -# endif -#else template inline T qFindChild(const QObject *, const QString & = QString()); template inline QList qFindChildren(const QObject *, const QString & = QString()); -# ifndef QT_NO_REGEXP +#ifndef QT_NO_REGEXP template inline QList qFindChildren(const QObject *, const QRegExp &); -# endif #endif class @@ -342,95 +334,6 @@ Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString const QMetaObject &mo, QList *list); Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); -#if defined Q_CC_MSVC && _MSC_VER < 1300 - -template -inline T qFindChild(const QObject *o, const QString &name, T) -{ return static_cast(qt_qFindChild_helper(o, name, ((T)0)->staticMetaObject)); } - -template -inline QList qFindChildren(const QObject *o, const QString &name, T) -{ - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, name, 0, ((T)0)->staticMetaObject, u.voidList); - return list; -} - -template -inline T qFindChild(const QObject *o, const QString &name) -{ return qFindChild(o, name, T(0)); } - -template -inline T qFindChild(const QObject *o) -{ return qFindChild(o, QString(), T(0)); } - -template -inline QList qFindChildren(const QObject *o, const QString &name) -{ return qFindChildren(o, name, T(0)); } - -template -inline QList qFindChildren(const QObject *o) -{ return qFindChildren(o, QString(), T(0)); } - -#ifndef QT_NO_REGEXP -template -inline QList qFindChildren(const QObject *o, const QRegExp &re, T) -{ - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, 0, &re, ((T)0)->staticMetaObject, u.voidList); - return list; -} - -template -inline QList qFindChildren(const QObject *o, const QRegExp &re) -{ return qFindChildren(o, re, T(0)); } - -#endif - -#ifdef Q_MOC_RUN -# define Q_DECLARE_INTERFACE(IFace, IId) Q_DECLARE_INTERFACE(IFace, IId) -#endif // Q_MOC_RUN - - -template inline const char * qobject_interface_iid() -{ return 0; } - -template inline T qobject_cast_helper(QObject *object, T) -{ return static_cast(((T)0)->staticMetaObject.cast(object)); } - -template inline T qobject_cast_helper(const QObject *object, T) -{ return static_cast(const_cast(((T)0)->staticMetaObject.cast(const_cast(object)))); } - -template -inline T qobject_cast(QObject *object) -{ return qobject_cast_helper(object, T(0)); } - -template -inline T qobject_cast(const QObject *object) -{ return qobject_cast_helper(object, T(0)); } - -#ifndef Q_MOC_RUN -# define Q_DECLARE_INTERFACE(IFace, IId) \ - template <> inline const char *qobject_interface_iid() \ - { return IId; } \ - template <> inline IFace *qobject_cast_helper(QObject *object, IFace *) \ - { return (IFace *)(object ? object->qt_metacast(IId) : 0); } \ - template <> inline IFace *qobject_cast_helper(const QObject *object, IFace *) \ - { return (IFace *)(object ? const_cast(object)->qt_metacast(IId) : 0); } -#endif // Q_MOC_RUN - -#else - template inline T qFindChild(const QObject *o, const QString &name) { return static_cast(qt_qFindChild_helper(o, name, reinterpret_cast(0)->staticMetaObject)); } @@ -499,8 +402,6 @@ template inline const char * qobject_interface_iid() { return reinterpret_cast((object ? const_cast(object)->qt_metacast(IId) : 0)); } #endif // Q_MOC_RUN -#endif - #ifndef QT_NO_DEBUG_STREAM Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *); #endif diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f5d7c0d..9617e0c 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -947,11 +947,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - *f = (double)(qlonglong)qMetaTypeUNumber(d); -#else *f = double(qMetaTypeUNumber(d)); -#endif break; default: *f = 0.0; @@ -986,11 +982,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, case QMetaType::UChar: case QMetaType::UShort: case QMetaType::ULong: -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - *f = (float)(qlonglong)qMetaTypeUNumber(d); -#else *f = float(qMetaTypeUNumber(d)); -#endif break; default: *f = 0.0f; diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index e4b73a1..d15df0b 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -639,13 +639,13 @@ Q_OUTOFLINE_TEMPLATE void QMap::freeData(QMapData *x) while (next != x) { cur = next; next = cur->forward[0]; -#if defined(_MSC_VER) && (_MSC_VER >= 1300) +#if defined(_MSC_VER) #pragma warning(disable:4189) #endif Node *concreteNode = concrete(reinterpret_cast(cur)); concreteNode->key.~Key(); concreteNode->value.~T(); -#if defined(_MSC_VER) && (_MSC_VER >= 1300) +#if defined(_MSC_VER) #pragma warning(default:4189) #endif } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 083c7c2..dd27f7e 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -109,7 +109,6 @@ namespace QtSharedPointer { template inline void normalDeleter(T *t) { delete t; } // this uses partial template specialization - // the only compilers that didn't support this were MSVC 6.0 and 2002 template struct RemovePointer; template struct RemovePointer { typedef T Type; }; template struct RemovePointer > { typedef T Type; }; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 3068af7..3371b36 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -336,11 +336,7 @@ inline char qToLower(char ch) return ch; } -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 -const QString::Null QString::null; -#else const QString::Null QString::null = { }; -#endif /*! \macro QT_NO_CAST_FROM_ASCII diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 952c572..7f7e475 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -51,14 +51,7 @@ #endif #ifndef QT_NO_STL -# if defined (Q_CC_MSVC_NET) && _MSC_VER < 1310 // Avoids nasty warning for xlocale, line 450 -# pragma warning (push) -# pragma warning (disable : 4189) -# include -# pragma warning (pop) -# else -# include -# endif +# include # ifndef QT_NO_STL_WCHAR // workaround for some headers not typedef'ing std::wstring diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index c2e2485..5613c12 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -789,11 +789,8 @@ QT_END_INCLUDE_NAMESPACE #else #define Q_TEMPLATE_EXTERN extern #endif -# pragma warning(push) /* MSVC 6.0 doesn't care about the disabling in qglobal.h (why?), so do it here */ -# pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */ Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector; -# pragma warning(pop) #endif QT_END_NAMESPACE diff --git a/src/declarative/qml/parser/qdeclarativejsengine_p.h b/src/declarative/qml/parser/qdeclarativejsengine_p.h index 1389244..d0b744d 100644 --- a/src/declarative/qml/parser/qdeclarativejsengine_p.h +++ b/src/declarative/qml/parser/qdeclarativejsengine_p.h @@ -88,12 +88,6 @@ uint qHash(const QDeclarativeJS::NameId &id); } // end of namespace QDeclarativeJS -#if defined(Q_CC_MSVC) && _MSC_VER <= 1300 -//this ensures that code outside QDeclarativeJS can use the hash function -//it also a workaround for some compilers -inline uint qHash(const QDeclarativeJS::NameId &nameId) { return QDeclarativeJS::qHash(nameId); } -#endif - namespace QDeclarativeJS { class Lexer; diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 941bd68..980f40f 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -898,13 +898,6 @@ protected: Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags) -#if defined Q_CC_MSVC && _MSC_VER < 1300 -template <> inline QWidget *qobject_cast_helper(QObject *o, QWidget *) -{ - if (!o || !o->isWidgetType()) return 0; - return (QWidget*)(o); -} -#else template <> inline QWidget *qobject_cast(QObject *o) { if (!o || !o->isWidgetType()) return 0; @@ -915,7 +908,6 @@ template <> inline const QWidget *qobject_cast(const QObject *o) if (!o || !o->isWidgetType()) return 0; return static_cast(o); } -#endif inline QWidget *QWidget::childAt(int ax, int ay) const { return childAt(QPoint(ax, ay)); } diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index b3d2526..39c4053 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -1032,15 +1032,7 @@ bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *re parseShorthandBackgroundProperty(decl.d->values, &brushData, image, repeat, alignment, pal); *brush = brushFromData(brushData, pal); if (brushData.type != BrushData::DependsOnThePalette) { -#if defined Q_CC_MSVC && _MSC_VER <= 1300 - BackgroundData data; - data.brush = brushData; - data.image = *image; - data.repeat = *repeat; - data.alignment = *alignment; -#else BackgroundData data = { brushData, *image, *repeat, *alignment }; -#endif decl.d->parsed = qVariantFromValue(data); } } diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index e6c36a4..2b26638 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -75,10 +75,6 @@ # define FM_DEBUG if (false) qDebug #endif -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) -# define for if(0){}else for -#endif - QT_BEGIN_NAMESPACE #define SMOOTH_SCALABLE 0xffff diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 65257e8..1671ae4 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -39,11 +39,6 @@ ** ****************************************************************************/ -#if defined Q_CC_MSVC && _MSC_VER <=1300 -//VC.net 2002 support for templates doesn't match some PSDK requirements -#define _WSPIAPI_COUNTOF(_Array) (sizeof(_Array) / sizeof(_Array[0])) -#endif - #include #include "qhostinfo_p.h" diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 4a18c7d..30c197e 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2986,14 +2986,7 @@ JSC::JSValue QScriptEnginePrivate::create(JSC::ExecState *exec, int type, const case QMetaType::LongLong: return JSC::jsNumber(exec, qsreal(*reinterpret_cast(ptr))); case QMetaType::ULongLong: -#if defined(Q_OS_WIN) && defined(_MSC_FULL_VER) && _MSC_FULL_VER <= 12008804 -#pragma message("** NOTE: You need the Visual Studio Processor Pack to compile support for 64bit unsigned integers.") - return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast(ptr))); -#elif defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - return JSC::jsNumber(exec, qsreal((qlonglong)*reinterpret_cast(ptr))); -#else return JSC::jsNumber(exec, qsreal(*reinterpret_cast(ptr))); -#endif case QMetaType::Double: return JSC::jsNumber(exec, qsreal(*reinterpret_cast(ptr))); case QMetaType::QString: diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index 3212ed5..1fe65db 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -349,11 +349,7 @@ inline bool qscriptvalue_cast_helper(const QScriptValue &value, int type, void * } template -T qscriptvalue_cast(const QScriptValue &value -#if !defined qdoc && defined Q_CC_MSVC && _MSC_VER < 1300 -, T * = 0 -#endif - ) +T qscriptvalue_cast(const QScriptValue &value) { T t; const int id = qMetaTypeId(); @@ -366,13 +362,11 @@ T qscriptvalue_cast(const QScriptValue &value return T(); } -#if !defined Q_CC_MSVC || _MSC_VER >= 1300 template <> inline QVariant qscriptvalue_cast(const QScriptValue &value) { return value.toVariant(); } -#endif template inline T qScriptValueToValue(const QScriptValue &value) @@ -428,11 +422,7 @@ void qScriptValueToSequence(const QScriptValue &value, Container &cont) quint32 len = value.property(QLatin1String("length")).toUInt32(); for (quint32 i = 0; i < len; ++i) { QScriptValue item = value.property(i); -#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET - cont.push_back(qscriptvalue_cast(item)); -#else cont.push_back(qscriptvalue_cast(item)); -#endif } } diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index f6390bb..fbd5d96 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -688,10 +688,6 @@ static bool LessThan(QScriptValue lhs, QScriptValue rhs) return false; case Number: -#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET - if (qIsNaN(lhs.toNumber()) || qIsNaN(rhs.toNumber())) - return false; -#endif return lhs.toNumber() < rhs.toNumber(); case Boolean: @@ -714,13 +710,7 @@ static bool LessThan(QScriptValue lhs, QScriptValue rhs) if (lhs.isString() && rhs.isString()) return lhs.toString() < rhs.toString(); - qsreal n1 = lhs.toNumber(); - qsreal n2 = rhs.toNumber(); -#if defined Q_CC_MSVC && !defined Q_CC_MSVC_NET - if (qIsNaN(n1) || qIsNaN(n2)) - return false; -#endif - return n1 < n2; + return lhs.toNumber() < rhs.toNumber(); } static bool Equals(QScriptValue lhs, QScriptValue rhs) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 9a35ac5..cc73f1b 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -62,15 +62,6 @@ QT_BEGIN_NAMESPACE // undefine this to prevent initial check of the ODBC driver #define ODBC_CHECK_DRIVER -// newer platform SDKs use SQLLEN instead of SQLINTEGER -#if defined(WIN32) && (_MSC_VER < 1300) && !defined(__MINGW64_VERSION_MAJOR) -# define QSQLLEN SQLINTEGER -# define QSQLULEN SQLUINTEGER -#else -# define QSQLLEN SQLLEN -# define QSQLULEN SQLULEN -#endif - static const int COLNAMESIZE = 256; //Map Qt parameter types to ODBC types static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }; @@ -360,7 +351,7 @@ static QString qGetStringData(SQLHANDLE hStmt, int column, int colSize, bool uni { QString fieldVal; SQLRETURN r = SQL_ERROR; - QSQLLEN lengthIndicator = 0; + SQLLEN lengthIndicator = 0; // NB! colSize must be a multiple of 2 for unicode enabled DBs if (colSize <= 0) { @@ -462,10 +453,10 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column) QByteArray fieldVal; SQLSMALLINT colNameLen; SQLSMALLINT colType; - QSQLULEN colSize; + SQLULEN colSize; SQLSMALLINT colScale; SQLSMALLINT nullable; - QSQLLEN lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQL_ERROR; QVarLengthArray colName(COLNAMESIZE); @@ -499,7 +490,7 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column) break; if (lengthIndicator == SQL_NULL_DATA) return QVariant(QVariant::ByteArray); - if (lengthIndicator > QSQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) { + if (lengthIndicator > SQLLEN(colSize) || lengthIndicator == SQL_NO_TOTAL) { read += colSize; colSize = 65536; } else { @@ -517,7 +508,7 @@ static QVariant qGetBinaryData(SQLHANDLE hStmt, int column) static QVariant qGetIntData(SQLHANDLE hStmt, int column, bool isSigned = true) { SQLINTEGER intbuf = 0; - QSQLLEN lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQLGetData(hStmt, column+1, isSigned ? SQL_C_SLONG : SQL_C_ULONG, @@ -537,7 +528,7 @@ static QVariant qGetIntData(SQLHANDLE hStmt, int column, bool isSigned = true) static QVariant qGetDoubleData(SQLHANDLE hStmt, int column) { SQLDOUBLE dblbuf; - QSQLLEN lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQLGetData(hStmt, column+1, SQL_C_DOUBLE, @@ -557,7 +548,7 @@ static QVariant qGetDoubleData(SQLHANDLE hStmt, int column) static QVariant qGetBigIntData(SQLHANDLE hStmt, int column, bool isSigned = true) { SQLBIGINT lngbuf = 0; - QSQLLEN lengthIndicator = 0; + SQLLEN lengthIndicator = 0; SQLRETURN r = SQLGetData(hStmt, column+1, isSigned ? SQL_C_SBIGINT : SQL_C_UBIGINT, @@ -601,7 +592,7 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i ) { SQLSMALLINT colNameLen; SQLSMALLINT colType; - QSQLULEN colSize; + SQLULEN colSize; SQLSMALLINT colScale; SQLSMALLINT nullable; SQLRETURN r = SQL_ERROR; @@ -621,7 +612,7 @@ static QSqlField qMakeFieldInfo(const QODBCPrivate* p, int i ) return QSqlField(); } - QSQLLEN unsignedFlag = SQL_FALSE; + SQLLEN unsignedFlag = SQL_FALSE; r = SQLColAttribute (p->hStmt, i + 1, SQL_DESC_UNSIGNED, @@ -1146,7 +1137,7 @@ QVariant QODBCResult::data(int field) return d->fieldCache.at(field); SQLRETURN r(0); - QSQLLEN lengthIndicator = 0; + SQLLEN lengthIndicator = 0; for (int i = d->fieldCacheIdx; i <= field; ++i) { // some servers do not support fetching column n after we already @@ -1256,7 +1247,7 @@ int QODBCResult::size() int QODBCResult::numRowsAffected() { - QSQLLEN affectedRowCount = 0; + SQLLEN affectedRowCount = 0; SQLRETURN r = SQLRowCount(d->hStmt, &affectedRowCount); if (r == SQL_SUCCESS) return affectedRowCount; @@ -1343,8 +1334,8 @@ bool QODBCResult::exec() SQLCloseCursor(d->hStmt); QList tmpStorage; // holds temporary buffers - QVarLengthArray indicators(boundValues().count()); - memset(indicators.data(), 0, indicators.size() * sizeof(QSQLLEN)); + QVarLengthArray indicators(boundValues().count()); + memset(indicators.data(), 0, indicators.size() * sizeof(SQLLEN)); // bind parameters - only positional binding allowed QVector& values = boundValues(); @@ -1354,7 +1345,7 @@ bool QODBCResult::exec() if (bindValueType(i) & QSql::Out) values[i].detach(); const QVariant &val = values.at(i); - QSQLLEN *ind = &indicators[i]; + SQLLEN *ind = &indicators[i]; if (val.isNull()) *ind = SQL_NULL_DATA; switch (val.type()) { diff --git a/src/testlib/qtest_global.h b/src/testlib/qtest_global.h index a78113a..4dd0cb7 100644 --- a/src/testlib/qtest_global.h +++ b/src/testlib/qtest_global.h @@ -62,7 +62,7 @@ QT_MODULE(Test) # endif #endif -#if (defined (Q_CC_MSVC) && _MSC_VER < 1310) || defined (Q_CC_SUN) || defined (Q_CC_XLC) || (defined (Q_CC_GNU) && (__GNUC__ - 0 < 3)) || defined (Q_CC_NOKIAX86) +#if defined (Q_CC_SUN) || defined (Q_CC_XLC) || (defined (Q_CC_GNU) && (__GNUC__ - 0 < 3)) || defined (Q_CC_NOKIAX86) # define QTEST_NO_SPECIALIZATIONS #endif diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp index d092c34..4ecd392 100644 --- a/tests/auto/collections/tst_collections.cpp +++ b/tests/auto/collections/tst_collections.cpp @@ -3447,27 +3447,16 @@ void tst_Collections::containerTypedefs() testSetContainerTypedefs(QSet()); } -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) -class Key1 -{}; -class T1 -{}; -class T2 -{}; -#else class Key1; class T1; class T2; -#endif void tst_Collections::forwardDeclared() { { typedef QHash C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QMultiHash C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } -#if !defined(Q_CC_MSVC_NET) || _MSC_VER >= 1310 { typedef QMap C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } { typedef QMultiMap C; C *x = 0; C::iterator i; C::const_iterator j; Q_UNUSED(x) } -#endif #if !defined(Q_CC_RVCT) // RVCT can't handle forward declared template parameters if those are used to declare // class members inside templated class. diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index f722f89..2413888 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -456,23 +456,15 @@ void tst_QWidget::getSetCheck() QCOMPARE(obj1.minimumWidth(), 0); // A widgets width can never be less than 0 obj1.setMinimumWidth(INT_MAX); #ifndef Q_WS_QWS //QWS doesn't allow toplevels to be bigger than the screen -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - QCOMPARE((long)obj1.minimumWidth(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#else QCOMPARE(obj1.minimumWidth(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium #endif -#endif child1.setMinimumWidth(0); QCOMPARE(child1.minimumWidth(), 0); child1.setMinimumWidth(INT_MIN); QCOMPARE(child1.minimumWidth(), 0); // A widgets width can never be less than 0 child1.setMinimumWidth(INT_MAX); -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - QCOMPARE((long)child1.minimumWidth(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#else QCOMPARE(child1.minimumWidth(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#endif // int QWidget::minimumHeight() // void QWidget::setMinimumHeight(int) @@ -482,38 +474,24 @@ void tst_QWidget::getSetCheck() QCOMPARE(obj1.minimumHeight(), 0); // A widgets height can never be less than 0 obj1.setMinimumHeight(INT_MAX); #ifndef Q_WS_QWS //QWS doesn't allow toplevels to be bigger than the screen -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - QCOMPARE((long)obj1.minimumHeight(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#else QCOMPARE(obj1.minimumHeight(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium #endif -#endif child1.setMinimumHeight(0); QCOMPARE(child1.minimumHeight(), 0); child1.setMinimumHeight(INT_MIN); QCOMPARE(child1.minimumHeight(), 0); // A widgets height can never be less than 0 child1.setMinimumHeight(INT_MAX); -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - QCOMPARE((long)child1.minimumHeight(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#else QCOMPARE(child1.minimumHeight(), QWIDGETSIZE_MAX); // The largest minimum size should only be as big as the maximium -#endif - - -// int QWidget::maximumWidth() + // int QWidget::maximumWidth() // void QWidget::setMaximumWidth(int) obj1.setMaximumWidth(0); QCOMPARE(obj1.maximumWidth(), 0); obj1.setMaximumWidth(INT_MIN); QCOMPARE(obj1.maximumWidth(), 0); // A widgets width can never be less than 0 obj1.setMaximumWidth(INT_MAX); -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - QCOMPARE((long)obj1.maximumWidth(), QWIDGETSIZE_MAX); // QWIDGETSIZE_MAX is the abs max, not INT_MAX -#else QCOMPARE(obj1.maximumWidth(), QWIDGETSIZE_MAX); // QWIDGETSIZE_MAX is the abs max, not INT_MAX -#endif // int QWidget::maximumHeight() // void QWidget::setMaximumHeight(int) @@ -522,11 +500,7 @@ void tst_QWidget::getSetCheck() obj1.setMaximumHeight(INT_MIN); QCOMPARE(obj1.maximumHeight(), 0); // A widgets height can never be less than 0 obj1.setMaximumHeight(INT_MAX); -#if defined(Q_CC_MSVC) && !defined(Q_CC_MSVC_NET) - QCOMPARE((long)obj1.maximumHeight(), QWIDGETSIZE_MAX); // QWIDGETSIZE_MAX is the abs max, not INT_MAX -#else QCOMPARE(obj1.maximumHeight(), QWIDGETSIZE_MAX); // QWIDGETSIZE_MAX is the abs max, not INT_MAX -#endif // back to normal obj1.setMinimumWidth(0); diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 69e4727..3f0fe87 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -2098,12 +2098,7 @@ bool Configure::checkAvailability(const QString &part) else if (part == "INCREDIBUILD_XGE") available = findFile("BuildConsole.exe") && findFile("xgConsole.exe"); else if (part == "XMLPATTERNS") - { - /* MSVC 6.0 and MSVC 2002/7.0 has too poor C++ support for QtXmlPatterns. */ - return dictionary.value("QMAKESPEC") != "win32-msvc" - && dictionary.value("QMAKESPEC") != "win32-msvc.net" // Leave for now, since we can't be sure if they are using 2002 or 2003 with this spec - && dictionary.value("QMAKESPEC") != "win32-msvc2002" - && dictionary.value("EXCEPTIONS") == "yes"; + available = dictionary.value("EXCEPTIONS") == "yes"; } else if (part == "PHONON") { if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { available = true; diff --git a/tools/configure/environment.cpp b/tools/configure/environment.cpp index 943a8a2..5d9851f 100644 --- a/tools/configure/environment.cpp +++ b/tools/configure/environment.cpp @@ -75,8 +75,6 @@ struct CompilerInfo{ {CC_BORLAND, "Borland C++", 0, "bcc32.exe"}, {CC_MINGW, "MinGW (Minimalist GNU for Windows)", 0, "g++.exe"}, {CC_INTEL, "Intel(R) C++ Compiler for 32-bit applications", 0, "icl.exe"}, // xilink.exe, xilink5.exe, xilink6.exe, xilib.exe - {CC_MSVC6, "Microsoft (R) 32-bit C/C++ Optimizing Compiler (6.x)", "Software\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++\\ProductDir", "cl.exe"}, // link.exe, lib.exe - {CC_NET2002, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2002 (7.0)", "Software\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe {CC_NET2003, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2003 (7.1)", "Software\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir", "cl.exe"}, // link.exe, lib.exe {CC_NET2005, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2005 (8.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\8.0", "cl.exe"}, // link.exe, lib.exe {CC_NET2008, "Microsoft (R) 32-bit C/C++ Optimizing Compiler.NET 2008 (9.0)", "Software\\Microsoft\\VisualStudio\\SxS\\VC7\\9.0", "cl.exe"}, // link.exe, lib.exe @@ -118,14 +116,6 @@ QString Environment::detectQMakeSpec() case CC_NET2003: spec = "win32-msvc2003"; break; - case CC_NET2002: - spec = "win32-msvc2002"; - break; - case CC_MSVC4: - case CC_MSVC5: - case CC_MSVC6: - spec = "win32-msvc"; - break; case CC_INTEL: spec = "win32-icc"; break; @@ -152,7 +142,7 @@ QString Environment::detectQMakeSpec() Compiler Environment::detectCompiler() { #ifndef Q_OS_WIN32 - return MSVC6; // Always generate MSVC 6.0 versions on other platforms + return CC_UNKNOWN; // Always generate CC_UNKNOWN on other platforms #else if(detectedCompiler != CC_UNKNOWN) return detectedCompiler; diff --git a/tools/configure/environment.h b/tools/configure/environment.h index 16af8df..9efaea1 100644 --- a/tools/configure/environment.h +++ b/tools/configure/environment.h @@ -50,10 +50,6 @@ enum Compiler { CC_BORLAND = 0x01, CC_MINGW = 0x02, CC_INTEL = 0x03, - CC_MSVC4 = 0x40, - CC_MSVC5 = 0x50, - CC_MSVC6 = 0x60, - CC_NET2002 = 0x70, CC_NET2003 = 0x71, CC_NET2005 = 0x80, CC_NET2008 = 0x90, -- cgit v0.12 From b9328bd135a3556cef2438fa049fb9e1d7cbb977 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 3 Aug 2010 18:33:09 +0200 Subject: Fix MS Visual C++ 6.0 references in the documentation Merge-request: 756 Reviewed-by: Olivier Goffart --- doc/src/porting/porting4.qdoc | 4 +-- src/corelib/kernel/qobject.cpp | 54 ++++++++++++++++++++-------------------- src/corelib/kernel/qvariant.cpp | 48 +++++++++++++++-------------------- src/script/api/qscriptengine.cpp | 32 ++++++++++-------------- 4 files changed, 62 insertions(+), 76 deletions(-) diff --git a/doc/src/porting/porting4.qdoc b/doc/src/porting/porting4.qdoc index f355e7b..698e4a5 100644 --- a/doc/src/porting/porting4.qdoc +++ b/doc/src/porting/porting4.qdoc @@ -2374,8 +2374,8 @@ pointer to a QObjectList. See also the comments on QObjectList below. - Use QObject::findChildren() (or qFindChildren() if you need MSVC 6 - compatibility) instead of QObject::queryList(). For example: + Use QObject::findChildren() instead of QObject::queryList(). + For example: \snippet doc/src/snippets/code/doc_src_porting4.qdoc 18 diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ad689ca..dc3a9c3 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1746,10 +1746,6 @@ QObjectList QObject::queryList(const char *inheritsClass, \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11 - \warning This function is not available with MSVC 6. Use - qFindChild() instead if you need to support that version of the - compiler. - \sa findChildren(), qFindChild() */ @@ -1770,10 +1766,6 @@ QObjectList QObject::queryList(const char *inheritsClass, \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 13 - \warning This function is not available with MSVC 6. Use - qFindChildren() instead if you need to support that version of the - compiler. - \sa findChild(), qFindChildren() */ @@ -1785,10 +1777,6 @@ QObjectList QObject::queryList(const char *inheritsClass, and that have names matching the regular expression \a regExp, or an empty list if there are no such objects. The search is performed recursively. - - \warning This function is not available with MSVC 6. Use - qFindChildren() instead if you need to support that version of the - compiler. */ /*! @@ -1796,9 +1784,11 @@ QObjectList QObject::queryList(const char *inheritsClass, \relates QObject This function is equivalent to - \a{obj}->\l{QObject::findChild()}{findChild}(\a name). It is - provided as a work-around for MSVC 6, which doesn't support - member template functions. + \a{obj}->\l{QObject::findChild()}{findChild}(\a name). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QObject::findChild() */ @@ -1808,9 +1798,11 @@ QObjectList QObject::queryList(const char *inheritsClass, \relates QObject This function is equivalent to - \a{obj}->\l{QObject::findChildren()}{findChildren}(\a name). It is - provided as a work-around for MSVC 6, which doesn't support - member template functions. + \a{obj}->\l{QObject::findChildren()}{findChildren}(\a name). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QObject::findChildren() */ @@ -1821,9 +1813,13 @@ QObjectList QObject::queryList(const char *inheritsClass, \overload qFindChildren() This function is equivalent to - \a{obj}->\l{QObject::findChildren()}{findChildren}(\a regExp). It is - provided as a work-around for MSVC 6, which doesn't support - member template functions. + \a{obj}->\l{QObject::findChildren()}{findChildren}(\a regExp). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. + + \sa QObject::findChildren() */ /*! @@ -1833,9 +1829,11 @@ QObjectList QObject::queryList(const char *inheritsClass, \overload qFindChildren() This function is equivalent to - \a{obj}->\l{QObject::findChild()}{findChild}(\a name). It is - provided as a work-around for MSVC 6, which doesn't support - member template functions. + \a{obj}->\l{QObject::findChild()}{findChild}(\a name). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QObject::findChild() */ @@ -1847,9 +1845,11 @@ QObjectList QObject::queryList(const char *inheritsClass, \overload qFindChildren() This function is equivalent to - \a{obj}->\l{QObject::findChildren()}{findChildren}(\a name). It is - provided as a work-around for MSVC 6, which doesn't support - member template functions. + \a{obj}->\l{QObject::findChildren()}{findChildren}(\a name). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QObject::findChildren() */ diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 9617e0c..bbfbce8 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -3066,10 +3066,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 4 - \warning This function is not available with MSVC 6. Use - qVariantSetValue() instead if you need to support that version of - the compiler. - \sa value(), fromValue(), canConvert() */ @@ -3087,10 +3083,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 5 - \warning This function is not available with MSVC 6. Use - qVariantValue() or qvariant_cast() instead if you need to support - that version of the compiler. - \sa setValue(), fromValue(), canConvert() */ @@ -3103,10 +3095,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 6 - \warning This function is not available with MSVC 6. Use - qVariantCanConvert() instead if you need to support that version - of the compiler. - \sa convert() */ @@ -3122,10 +3110,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) \note If you are working with custom types, you should use the Q_DECLARE_METATYPE() macro to register your custom type. - \warning This function is not available with MSVC 6. Use - qVariantFromValue() instead if you need to support that version - of the compiler. - \sa setValue(), value() */ @@ -3136,9 +3120,11 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) Returns a variant containing a copy of the given \a value with template type \c{T}. - This function is equivalent to QVariant::fromValue(\a value). It - is provided as a work-around for MSVC 6, which doesn't support - member template functions. + This function is equivalent to QVariant::fromValue(\a value). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. For example, a QObject pointer can be stored in a variant with the following code: @@ -3154,9 +3140,11 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) Sets the contents of the given \a variant to a copy of the \a value with the specified template type \c{T}. - This function is equivalent to QVariant::setValue(\a value). It - is provided as a work-around for MSVC 6, which doesn't support - member template functions. + This function is equivalent to QVariant::setValue(\a value). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QVariant::setValue() */ @@ -3178,9 +3166,11 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) Returns the given \a value converted to the template type \c{T}. This function is equivalent to - \l{QVariant::value()}{QVariant::value}(\a value). It is - provided as a work-around for MSVC 6, which doesn't support - member template functions. + \l{QVariant::value()}{QVariant::value}(\a value). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QVariant::value(), qvariant_cast() */ @@ -3191,9 +3181,11 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) Returns true if the given \a value can be converted to the template type specified; otherwise returns false. - This function is equivalent to QVariant::canConvert(\a value). It - is provided as a work-around for MSVC 6, which doesn't support - member template functions. + This function is equivalent to QVariant::canConvert(\a value). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QVariant::canConvert() */ diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 30c197e..01f3c51 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2435,10 +2435,6 @@ QScriptValue QScriptEngine::newQMetaObject( \snippet doc/src/snippets/code/src_script_qscriptengine.cpp 13 - \warning This function is not available with MSVC 6. Use - qScriptValueFromQMetaObject() instead if you need to support that version - of the compiler. - \sa QScriptEngine::newQMetaObject() */ @@ -2451,9 +2447,11 @@ QScriptValue QScriptEngine::newQMetaObject( \c{T}. This function is equivalent to - QScriptEngine::scriptValueFromQMetaObject(). It is provided as a - work-around for MSVC 6, which doesn't support member template - functions. + QScriptEngine::scriptValueFromQMetaObject(). + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa QScriptEngine::newQMetaObject() */ @@ -3744,10 +3742,6 @@ QStringList QScriptEngine::importedExtensions() const to newVariant()); you can change this behavior by installing your own type conversion functions with qScriptRegisterMetaType(). - \warning This function is not available with MSVC 6. Use - qScriptValueFromValue() instead if you need to support that - version of the compiler. - \sa fromScriptValue(), qScriptRegisterMetaType() */ @@ -3761,10 +3755,6 @@ QStringList QScriptEngine::importedExtensions() const description of the built-in type conversion provided by QtScript. - \warning This function is not available with MSVC 6. Use - qScriptValueToValue() or qscriptvalue_cast() instead if you need - to support that version of the compiler. - \sa toScriptValue(), qScriptRegisterMetaType() */ @@ -3777,8 +3767,10 @@ QStringList QScriptEngine::importedExtensions() const value of template type \c{T}. This function is equivalent to QScriptEngine::toScriptValue(). - It is provided as a work-around for MSVC 6, which doesn't support - member template functions. + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa qScriptValueToValue() */ @@ -3791,8 +3783,10 @@ QStringList QScriptEngine::importedExtensions() const Returns the given \a value converted to the template type \c{T}. This function is equivalent to QScriptEngine::fromScriptValue(). - It is provided as a work-around for MSVC 6, which doesn't - support member template functions. + + \note This function was provided as a workaround for MSVC 6 + which did not support member template functions. It is advised + to use the other form in new code. \sa qScriptValueFromValue() */ -- cgit v0.12 From 02e5a6c9abe9562ce2b2057c0b89f65d371c5b40 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 3 Aug 2010 18:33:10 +0200 Subject: It is no longer necessary to check for QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION Merge-request: 756 Reviewed-by: Olivier Goffart --- src/corelib/concurrent/qtconcurrentiteratekernel.h | 5 +---- src/corelib/global/qglobal.h | 24 ---------------------- src/corelib/thread/qthreadstorage.h | 4 ---- src/corelib/tools/qhash.h | 5 +---- src/corelib/tools/qmap.h | 2 -- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 6 ------ 6 files changed, 2 insertions(+), 44 deletions(-) diff --git a/src/corelib/concurrent/qtconcurrentiteratekernel.h b/src/corelib/concurrent/qtconcurrentiteratekernel.h index 23aaae8..29d276b 100644 --- a/src/corelib/concurrent/qtconcurrentiteratekernel.h +++ b/src/corelib/concurrent/qtconcurrentiteratekernel.h @@ -184,12 +184,9 @@ public: #if defined (QT_NO_STL) : begin(_begin), end(_end), current(_begin), currentIndex(0), forIteration(false), progressReportingEnabled(true) -#elif !defined(QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION) +#else : begin(_begin), end(_end), current(_begin), currentIndex(0), forIteration(selectIteration(typename std::iterator_traits::iterator_category())), progressReportingEnabled(true) -#else - : begin(_begin), end(_end), currentIndex(0), - forIteration(selectIteration(std::iterator_category(_begin))), progressReportingEnabled(true) #endif { #if defined (QT_NO_STL) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 1d78cbd..909fe9d 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1952,8 +1952,6 @@ static inline bool qIsNull(float f) qIsDetached - data sharing functionality */ -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION - /* The catch-all template. */ @@ -1986,28 +1984,6 @@ public: }; }; -#else - -template char QTypeInfoHelper(T*(*)()); -void* QTypeInfoHelper(...); - -template inline bool qIsDetached(T &) { return true; } - -template -class QTypeInfo -{ -public: - enum { - isPointer = (1 == sizeof(QTypeInfoHelper((T(*)())0))), - isComplex = !isPointer, - isStatic = !isPointer, - isLarge = (sizeof(T)>sizeof(void*)), - isDummy = false - }; -}; - -#endif /* QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION */ - /* Specialize a specific type with: diff --git a/src/corelib/thread/qthreadstorage.h b/src/corelib/thread/qthreadstorage.h index 3a786ba..6264674 100644 --- a/src/corelib/thread/qthreadstorage.h +++ b/src/corelib/thread/qthreadstorage.h @@ -91,8 +91,6 @@ inline void qThreadStorage_setLocalData(QThreadStorageData &d, T **t) { (void) d.set(*t); } -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION - // value-based specialization template inline @@ -116,8 +114,6 @@ inline void qThreadStorage_setLocalData(QThreadStorageData &d, T *t) { (void) d.set(new T(*t)); } -#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION - // MOC_SKIP_END #endif diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 0777f06..360f99d 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -225,7 +225,7 @@ struct QHashNode inline bool same_key(uint h0, const Key &key0) { return h0 == h && key0 == key; } }; -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION + #define Q_HASH_DECLARE_INT_NODES(key_type) \ template \ struct QHashDummyNode { \ @@ -253,7 +253,6 @@ Q_HASH_DECLARE_INT_NODES(ushort); Q_HASH_DECLARE_INT_NODES(int); Q_HASH_DECLARE_INT_NODES(uint); #undef Q_HASH_DECLARE_INT_NODES -#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION template class QHash @@ -513,8 +512,6 @@ Q_INLINE_TEMPLATE void QHash::deleteNode2(QHashData::Node *node) { #ifdef Q_CC_BOR concrete(node)->~QHashNode(); -#elif defined(QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION) - concrete(node)->~QHashNode(); #else concrete(node)->~Node(); #endif diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h index d15df0b..2d11613 100644 --- a/src/corelib/tools/qmap.h +++ b/src/corelib/tools/qmap.h @@ -107,7 +107,6 @@ template inline bool qMapLessThanKey(const Key &key1, const Key &key return key1 < key2; } -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION template inline bool qMapLessThanKey(Ptr *key1, Ptr *key2) { Q_ASSERT(sizeof(quintptr) == sizeof(Ptr *)); @@ -119,7 +118,6 @@ template inline bool qMapLessThanKey(const Ptr *key1, const Ptr *key Q_ASSERT(sizeof(quintptr) == sizeof(const Ptr *)); return quintptr(key1) < quintptr(key2); } -#endif // QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION template struct QMapNode { diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 6b4904f..7b0f723 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -732,7 +732,6 @@ void tst_QSharedPointer::objectCast() ptr = baseptr.objectCast(); QVERIFY(ptr == data); -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION // again: ptr = qobject_cast(baseptr); QVERIFY(ptr == data); @@ -740,7 +739,6 @@ void tst_QSharedPointer::objectCast() // again: ptr = qobject_cast >(baseptr); QVERIFY(ptr == data); -#endif } check(); @@ -760,7 +758,6 @@ void tst_QSharedPointer::objectCast() ptr = baseptr.objectCast(); QVERIFY(ptr == data); -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION // again: ptr = qobject_cast(baseptr); QVERIFY(ptr == data); @@ -802,7 +799,6 @@ void tst_QSharedPointer::objectCast() QSharedPointer otherptr = qSharedPointerObjectCast(weakptr); QVERIFY(otherptr.isNull()); -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION // again: otherptr = qobject_cast(weakptr); QVERIFY(otherptr.isNull()); @@ -1736,12 +1732,10 @@ void tst_QSharedPointer::invalidConstructs_data() << &QTest::QExternalTest::tryCompileFail << "QSharedPointer baseptr = QSharedPointer(new QObject);\n" "qSharedPointerObjectCast(baseptr);"; -#ifndef QT_NO_PARTIAL_TEMPLATE_SPECIALIZATION QTest::newRow("const-dropping-object-cast2") << &QTest::QExternalTest::tryCompileFail << "QSharedPointer baseptr = QSharedPointer(new QObject);\n" "qobject_cast(baseptr);"; -#endif // arithmethics through automatic cast operators QTest::newRow("arithmethic1") -- cgit v0.12 From 26f43dcc70a0bcc8aec96a0ca6f648c543b97b10 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 3 Aug 2010 18:33:12 +0200 Subject: It is no longer necessary to check for QT_NO_MEMBER_TEMPLATES Merge-request: 756 Reviewed-by: Olivier Goffart --- src/corelib/concurrent/qfuture.h | 2 +- src/corelib/io/qdebug.h | 4 ---- src/corelib/kernel/qobject.h | 6 ++---- src/corelib/kernel/qobjectdefs.h | 4 ++-- src/corelib/kernel/qvariant.h | 6 ------ src/corelib/tools/qshareddata.h | 2 -- src/corelib/tools/qsharedpointer.cpp | 4 ---- src/corelib/tools/qsharedpointer.h | 3 --- src/gui/math3d/qmatrix4x4.cpp | 4 ---- src/gui/math3d/qmatrix4x4.h | 10 ++-------- src/script/api/qscriptengine.h | 8 -------- src/xmlpatterns/utils/qautoptr_p.h | 2 -- tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp | 6 ++---- tests/auto/qobject/tst_qobject.cpp | 2 -- tests/auto/qscriptengine/tst_qscriptengine.cpp | 2 -- 15 files changed, 9 insertions(+), 56 deletions(-) diff --git a/src/corelib/concurrent/qfuture.h b/src/corelib/concurrent/qfuture.h index 02ae40a..2856f5e 100644 --- a/src/corelib/concurrent/qfuture.h +++ b/src/corelib/concurrent/qfuture.h @@ -210,7 +210,7 @@ public: bool operator==(const QFuture &other) const { return (d == other.d); } bool operator!=(const QFuture &other) const { return (d != other.d); } -#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(Q_CC_XLC) +#if !defined(Q_CC_XLC) template QFuture(const QFuture &other) : d(other.d) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 093312f..0591318 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -137,10 +137,8 @@ public: inline QNoDebug &nospace() { return *this; } inline QNoDebug &maybeSpace() { return *this; } -#ifndef QT_NO_MEMBER_TEMPLATES template inline QNoDebug &operator<<(const T &) { return *this; } -#endif }; Q_CORE_EXPORT_INLINE QDebug qCritical() { return QDebug(QtCriticalMsg); } @@ -285,10 +283,8 @@ Q_CORE_EXPORT_INLINE QDebug qDebug() { return QDebug(QtDebugMsg); } inline QNoDebug qDebug() { return QNoDebug(); } #define qDebug QT_NO_QDEBUG_MACRO -#ifdef QT_NO_MEMBER_TEMPLATES template inline QNoDebug operator<<(QNoDebug debug, const T &) { return debug; } -#endif #endif diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 7f0084c..c8aa2b5 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -156,7 +156,6 @@ public: int startTimer(int interval); void killTimer(int id); -#ifndef QT_NO_MEMBER_TEMPLATES template inline T findChild(const QString &aName = QString()) const { return qFindChild(this, aName); } @@ -170,7 +169,6 @@ public: inline QList findChildren(const QRegExp &re) const { return qFindChildren(this, re); } #endif -#endif #ifdef QT3_SUPPORT QT3_SUPPORT QObject *child(const char *objName, const char *inheritsClass = 0, @@ -369,7 +367,7 @@ inline QList qFindChildren(const QObject *o, const QRegExp &re) template inline T qobject_cast(QObject *object) { -#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) +#if !defined(QT_NO_QOBJECT_CHECK) reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(object)); #endif return static_cast(reinterpret_cast(0)->staticMetaObject.cast(object)); @@ -382,7 +380,7 @@ inline T qobject_cast(const QObject *object) register T ptr = static_cast(object); Q_UNUSED(ptr); -#if !defined(QT_NO_MEMBER_TEMPLATES) && !defined(QT_NO_QOBJECT_CHECK) +#if !defined(QT_NO_QOBJECT_CHECK) reinterpret_cast(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast(const_cast(object))); #endif return static_cast(const_cast(reinterpret_cast(0)->staticMetaObject.cast(const_cast(object)))); diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 555a1f5..996fce2 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -117,7 +117,7 @@ class QString; # define QT_TR_FUNCTIONS #endif -#if defined(QT_NO_MEMBER_TEMPLATES) || defined(QT_NO_QOBJECT_CHECK) +#if defined(QT_NO_QOBJECT_CHECK) /* tmake ignore Q_OBJECT */ #define Q_OBJECT_CHECK #else @@ -144,7 +144,7 @@ inline int qYouForgotTheQ_OBJECT_Macro(T, T) { return 0; } template inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {} -#endif // QT_NO_MEMBER_TEMPLATES +#endif // QT_NO_QOBJECT_CHECK #ifdef Q_NO_DATA_RELOCATION #define Q_OBJECT_GETSTATICMETAOBJECT static const QMetaObject &getStaticMetaObject(); diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index cb2825c..73b00e9 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -83,7 +83,6 @@ class QUrl; class QVariant; class QVariantComparisonHelper; -#ifndef QT_NO_MEMBER_TEMPLATES template inline QVariant qVariantFromValue(const T &); @@ -95,7 +94,6 @@ inline T qVariantValue(const QVariant &); template inline bool qVariantCanConvert(const QVariant &); -#endif class Q_CORE_EXPORT QVariant { @@ -327,7 +325,6 @@ class Q_CORE_EXPORT QVariant const void *constData() const; inline const void *data() const { return constData(); } -#ifndef QT_NO_MEMBER_TEMPLATES template inline void setValue(const T &value); @@ -342,7 +339,6 @@ class Q_CORE_EXPORT QVariant template bool canConvert() const { return qVariantCanConvert(*this); } -#endif public: #ifndef qdoc @@ -527,11 +523,9 @@ inline QSize &QVariant::asSize() { return *reinterpret_cast(castOrDetach(Size)); } #endif //QT3_SUPPORT -#ifndef QT_NO_MEMBER_TEMPLATES template inline void QVariant::setValue(const T &avalue) { qVariantSetValue(*this, avalue); } -#endif #ifndef QT_NO_DATASTREAM Q_CORE_EXPORT QDataStream& operator>> (QDataStream& s, QVariant& p); diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h index 7e9934d..80ba7b7 100644 --- a/src/corelib/tools/qshareddata.h +++ b/src/corelib/tools/qshareddata.h @@ -161,14 +161,12 @@ public: explicit QExplicitlySharedDataPointer(T *data); inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o) : d(o.d) { if (d) d->ref.ref(); } -#ifndef QT_NO_MEMBER_TEMPLATES template inline QExplicitlySharedDataPointer(const QExplicitlySharedDataPointer &o) : d(static_cast(o.data())) { if(d) d->ref.ref(); } -#endif inline QExplicitlySharedDataPointer & operator=(const QExplicitlySharedDataPointer &o) { if (o.d != d) { diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index 1b4b356..bad2897 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -1275,8 +1275,6 @@ QT_END_NAMESPACE -#if !defined(QT_NO_MEMBER_TEMPLATES) - //# define QT_SHARED_POINTER_BACKTRACE_SUPPORT # ifdef QT_SHARED_POINTER_BACKTRACE_SUPPORT # if defined(__GLIBC__) && (__GLIBC__ >= 2) && !defined(__UCLIBC__) && !defined(QT_LINUXBASE) @@ -1501,5 +1499,3 @@ void QtSharedPointer::internalSafetyCheckCleanCheck() } QT_END_NAMESPACE - -#endif diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h index c51ade6..e0f4dca 100644 --- a/src/corelib/tools/qsharedpointer.h +++ b/src/corelib/tools/qsharedpointer.h @@ -47,10 +47,7 @@ #include #ifndef Q_QDOC -# if !defined(QT_NO_MEMBER_TEMPLATES) -// QSharedPointer requires member template support # include -# endif #else QT_BEGIN_HEADER diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 16c7f97..04a9099 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -102,8 +102,6 @@ QMatrix4x4::QMatrix4x4(const qreal *values) \sa optimize() */ -#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC) - /*! \fn QMatrix4x4::QMatrix4x4(const QGenericMatrix& matrix) @@ -126,8 +124,6 @@ QMatrix4x4::QMatrix4x4(const qreal *values) \sa qGenericMatrixFromMatrix4x4() */ -#endif - /*! \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix& matrix) \relates QMatrix4x4 diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 0671fa8..1f77d36 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -69,10 +69,10 @@ public: qreal m21, qreal m22, qreal m23, qreal m24, qreal m31, qreal m32, qreal m33, qreal m34, qreal m41, qreal m42, qreal m43, qreal m44); -#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC) + template explicit QMatrix4x4(const QGenericMatrix& matrix); -#endif + QMatrix4x4(const qreal *values, int cols, int rows); QMatrix4x4(const QTransform& transform); QMatrix4x4(const QMatrix& matrix); @@ -169,10 +169,8 @@ public: QRect mapRect(const QRect& rect) const; QRectF mapRect(const QRectF& rect) const; -#if !defined(QT_NO_MEMBER_TEMPLATES) || defined(Q_QDOC) template QGenericMatrix toGenericMatrix() const; -#endif inline qreal *data(); inline const qreal *data() const { return m[0]; } @@ -223,8 +221,6 @@ inline QMatrix4x4::QMatrix4x4 flagBits = General; } -#if !defined(QT_NO_MEMBER_TEMPLATES) - template Q_INLINE_TEMPLATE QMatrix4x4::QMatrix4x4 (const QGenericMatrix& matrix) @@ -261,8 +257,6 @@ QGenericMatrix QMatrix4x4::toGenericMatrix() const return result; } -#endif - inline const qreal& QMatrix4x4::operator()(int aRow, int aColumn) const { Q_ASSERT(aRow >= 0 && aRow < 4 && aColumn >= 0 && aColumn < 4); diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index 1fe65db..6add6ed 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -65,13 +65,11 @@ inline QScriptValue qscriptQMetaObjectConstructor(QScriptContext *, QScriptEngin class QRegExp; #endif -#ifndef QT_NO_MEMBER_TEMPLATES template inline QScriptValue qScriptValueFromValue(QScriptEngine *, const T &); template inline T qScriptValueToValue(const QScriptValue &); -#endif class QScriptSyntaxCheckResultPrivate; class Q_SCRIPT_EXPORT QScriptSyntaxCheckResult @@ -196,9 +194,7 @@ public: QScriptValue newQMetaObject(const QMetaObject *metaObject, const QScriptValue &ctor = QScriptValue()); -# ifndef QT_NO_MEMBER_TEMPLATES template QScriptValue scriptValueFromQMetaObject(); -# endif // QT_NO_MEMBER_TEMPLATES #endif // QT_NO_QOBJECT @@ -213,7 +209,6 @@ public: -#ifndef QT_NO_MEMBER_TEMPLATES template inline QScriptValue toScriptValue(const T &value) { @@ -224,7 +219,6 @@ public: { return qScriptValueToValue(value); } -#endif // QT_NO_MEMBER_TEMPLATES void installTranslatorFunctions(const QScriptValue &object = QScriptValue()); @@ -311,12 +305,10 @@ template<> inline QScriptValue qscriptQMetaObjectConstructor(QScriptContext * return o; \ } -# ifndef QT_NO_MEMBER_TEMPLATES template QScriptValue QScriptEngine::scriptValueFromQMetaObject() { return qScriptValueFromQMetaObject(this); } -# endif // QT_NO_MEMBER_TEMPLATES #endif // QT_NO_QOBJECT diff --git a/src/xmlpatterns/utils/qautoptr_p.h b/src/xmlpatterns/utils/qautoptr_p.h index 060e7be..173999f 100644 --- a/src/xmlpatterns/utils/qautoptr_p.h +++ b/src/xmlpatterns/utils/qautoptr_p.h @@ -122,7 +122,6 @@ namespace QPatternist return *this; } -#ifndef QT_NO_MEMBER_TEMPLATES template operator AutoPtrRef() { @@ -139,7 +138,6 @@ namespace QPatternist inline AutoPtr(AutoPtr& other) : m_ptr(other.release()) { } -#endif inline T *release() { diff --git a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp index 5709196..22c679a 100644 --- a/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/qmatrixnxn/tst_qmatrixnxn.cpp @@ -2822,10 +2822,9 @@ void tst_QMatrixNxN::convertGeneric() 9.0f, 10.0f, 11.0f, 12.0f, 0.0f, 0.0f, 0.0f, 1.0f }; -#if !defined(QT_NO_MEMBER_TEMPLATES) QMatrix4x4 m4(m1); QVERIFY(isSame(m4, unique4x4)); -#endif + QMatrix4x4 m5 = qGenericMatrixToMatrix4x4(m1); QVERIFY(isSame(m5, unique4x4)); @@ -2835,10 +2834,9 @@ void tst_QMatrixNxN::convertGeneric() 9.0f, 10.0f, 11.0f, 12.0f }; QMatrix4x4 m9(uniqueValues4); -#if !defined(QT_NO_MEMBER_TEMPLATES) + QMatrix4x3 m10 = m9.toGenericMatrix<4, 3>(); QVERIFY(isSame(m10, conv4x4)); -#endif QMatrix4x3 m11 = qGenericMatrixFromMatrix4x4<4, 3>(m9); QVERIFY(isSame(m11, conv4x4)); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index 5caac15..fc38a84 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -669,11 +669,9 @@ void tst_QObject::findChildren() l = qFindChildren(&o, "unnamed"); QCOMPARE(l.size(), 0); -#ifndef QT_NO_MEMBER_TEMPLATES tl = o.findChildren("t1"); QCOMPARE(tl.size(), 1); QCOMPARE(tl.at(0), &t1); -#endif } diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 81fb749..04b2627 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1909,7 +1909,6 @@ void tst_QScriptEngine::valueConversion() QString snum = qScriptValueToValue(num); QCOMPARE(snum, QLatin1String("123")); } -#ifndef QT_NO_MEMBER_TEMPLATES { QScriptValue num = eng.toScriptValue(123); QCOMPARE(num.isNumber(), true); @@ -1921,7 +1920,6 @@ void tst_QScriptEngine::valueConversion() QString snum = eng.fromScriptValue(num); QCOMPARE(snum, QLatin1String("123")); } -#endif { QScriptValue num(&eng, 123); QCOMPARE(qScriptValueToValue(num), char(123)); -- cgit v0.12 From 0d6a0f1371d899c4105bc4383550ca1cb6b132b2 Mon Sep 17 00:00:00 2001 From: miniak Date: Tue, 3 Aug 2010 18:33:13 +0200 Subject: qmake: qmakeDeleteCacheClear() function can be template now Merge-request: 756 Reviewed-by: Olivier Goffart --- qmake/cachekeys.h | 9 +++------ qmake/generators/makefile.cpp | 4 ++-- qmake/option.cpp | 2 +- qmake/project.cpp | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/qmake/cachekeys.h b/qmake/cachekeys.h index 63bd224..c5c1631 100644 --- a/qmake/cachekeys.h +++ b/qmake/cachekeys.h @@ -166,12 +166,9 @@ struct FileFixifyCacheKey inline uint qHash(const FileFixifyCacheKey &f) { return f.hashCode(); } // ------------------------------------------------------------------------------------------------- -// As MSVC 6.0 can't handle template functions that well, we need a separate function for each type -inline void qmakeDeleteCacheClear_QMapStringInt(void *i) { delete reinterpret_cast *>(i); } -inline void qmakeDeleteCacheClear_QStringList(void *i) { delete reinterpret_cast(i); } -inline void qmakeDeleteCacheClear_QHashFixStringCacheKeyQString(void *i) { delete reinterpret_cast *>(i); } -inline void qmakeDeleteCacheClear_QHashFileInfoCacheKeyQFileInfo(void *i) { delete reinterpret_cast *>(i); } -inline void qmakeDeleteCacheClear_QHashFileFixifyCacheKeyQString(void *i) { delete reinterpret_cast *>(i); } +template +inline void qmakeDeleteCacheClear(void *i) { delete reinterpret_cast(i); } + inline void qmakeFreeCacheClear(void *i) { free(i); } typedef void (*qmakeCacheClearFunc)(void *); diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 45a96f5..74c7977 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -2712,7 +2712,7 @@ MakefileGenerator::fileInfo(QString file) const static QFileInfo noInfo = QFileInfo(); if(!cache) { cache = new QHash; - qmakeAddCacheClear(qmakeDeleteCacheClear_QHashFileInfoCacheKeyQFileInfo, (void**)&cache); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&cache); } FileInfoCacheKey cacheKey(file); QFileInfo value = cache->value(cacheKey, noInfo); @@ -2791,7 +2791,7 @@ MakefileGenerator::fileFixify(const QString& file, const QString &out_d, const Q static QHash *cache = 0; if(!cache) { cache = new QHash; - qmakeAddCacheClear(qmakeDeleteCacheClear_QHashFileFixifyCacheKeyQString, (void**)&cache); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&cache); } FileFixifyCacheKey cacheKey(ret, out_d, in_d, fix, canon); QString cacheVal = cache->value(cacheKey); diff --git a/qmake/option.cpp b/qmake/option.cpp index 8db3797..27e7c18 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -621,7 +621,7 @@ Option::fixString(QString string, uchar flags) static QHash *cache = 0; if(!cache) { cache = new QHash; - qmakeAddCacheClear(qmakeDeleteCacheClear_QHashFixStringCacheKeyQString, (void**)&cache); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&cache); } FixStringCacheKey cacheKey(string, flags); if(cache->contains(cacheKey)) { diff --git a/qmake/project.cpp b/qmake/project.cpp index cb02923..29d4242 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -87,7 +87,7 @@ QMap qmake_expandFunctions() static QMap *qmake_expand_functions = 0; if(!qmake_expand_functions) { qmake_expand_functions = new QMap; - qmakeAddCacheClear(qmakeDeleteCacheClear_QMapStringInt, (void**)&qmake_expand_functions); + qmakeAddCacheClear(qmakeDeleteCacheClear >, (void**)&qmake_expand_functions); qmake_expand_functions->insert("member", E_MEMBER); qmake_expand_functions->insert("first", E_FIRST); qmake_expand_functions->insert("last", E_LAST); @@ -1631,7 +1631,7 @@ QMakeProject::doProjectInclude(QString file, uchar flags, QMap, (void**)&feature_roots); } debug_msg(2, "Looking for feature '%s' in (%s)", file.toLatin1().constData(), feature_roots->join("::").toLatin1().constData()); -- cgit v0.12 From 5683a6f6f30e65c272c1194f31395161bde229e4 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 4 Aug 2010 09:14:30 +0200 Subject: QImage::fill() overloads that take QColor and Qt::GlobalColor This will break source compatibility in some cases, but only when the user has a bug in the first place, so this is preferable Reviewed-by: Eskil --- src/gui/image/qimage.cpp | 82 ++++++++++++++++++++++++++++ src/gui/image/qimage.h | 3 ++ tests/auto/qimage/tst_qimage.cpp | 113 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 198 insertions(+) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 30cf758..0e7ced83 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -2022,6 +2022,88 @@ void QImage::fill(uint pixel) 0, 0, d->width, d->height, d->bytes_per_line); } + +/*! + \fn void QImage::fill(Qt::GlobalColor color) + + \overload + + \since 4.8 + */ + +void QImage::fill(Qt::GlobalColor color) +{ + fill(QColor(color)); +} + + + +/*! + \fn void QImage::fill(Qt::GlobalColor color) + + \overload + + Fills the entire image with the given \a color. + + If the depth of the image is 1, the image will be filled with 1 if + \a color equals Qt::color0; it will otherwise be filled with 0. + + If the depth of the image is 8, the image will be filled with the + index corresponding the \a color in the color table if present; it + will otherwise be filled with 0.| + + \since 4.8 +*/ + +void QImage::fill(const QColor &color) +{ + if (!d) + return; + detach(); + + // In case we run out of memory + if (!d) + return; + + if (d->depth == 32) { + uint pixel = color.rgba(); + if (d->format == QImage::Format_ARGB32_Premultiplied) + pixel = PREMUL(pixel); + fill((uint) pixel); + + } else if (d->depth == 16 && d->format == QImage::Format_RGB16) { + qrgb565 p(color.rgba()); + fill((uint) p.rawValue()); + + } else if (d->depth == 1) { + if (color == Qt::color1) + fill((uint) 1); + else + fill((uint) 0); + + } else if (d->depth == 8) { + uint pixel = 0; + for (int i=0; icolortable.size(); ++i) { + if (color.rgba() == d->colortable.at(i)) { + pixel = i; + break; + } + } + fill(pixel); + + } else { + QPainter p(this); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.fillRect(rect(), color); + } + +} + + + + + + /*! Inverts all pixel values in the image. diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 896061f..f37dcf2 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -210,6 +210,9 @@ public: void setColorTable(const QVector colors); void fill(uint pixel); + void fill(const QColor &color); + void fill(Qt::GlobalColor color); + bool hasAlphaChannel() const; void setAlphaChannel(const QImage &alphaChannel); diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp index 517c1816..63320b2 100644 --- a/tests/auto/qimage/tst_qimage.cpp +++ b/tests/auto/qimage/tst_qimage.cpp @@ -59,6 +59,7 @@ #endif Q_DECLARE_METATYPE(QImage::Format) +Q_DECLARE_METATYPE(Qt::GlobalColor) class tst_QImage : public QObject { @@ -139,6 +140,11 @@ private slots: void premultipliedAlphaConsistency(); void compareIndexed(); + + void fillColor_data(); + void fillColor(); + + void fillColorWithAlpha(); }; tst_QImage::tst_QImage() @@ -1820,5 +1826,112 @@ void tst_QImage::compareIndexed() QCOMPARE(img, imgInverted); } +void tst_QImage::fillColor_data() +{ + QTest::addColumn("format"); + QTest::addColumn("color"); + QTest::addColumn("pixelValue"); + + QTest::newRow("Mono, color0") << QImage::Format_Mono << Qt::color0 << 0u; + QTest::newRow("Mono, color1") << QImage::Format_Mono << Qt::color1 << 1u; + + QTest::newRow("MonoLSB, color0") << QImage::Format_MonoLSB << Qt::color0 << 0u; + QTest::newRow("MonoLSB, color1") << QImage::Format_MonoLSB << Qt::color1 << 1u; + + const char *names[] = { + "Indexed8", + "RGB32", + "ARGB32", + "ARGB32pm", + "RGB16", + "ARGB8565pm", + "RGB666", + "ARGB6666pm", + "RGB555", + "ARGB8555pm", + "RGB888", + "RGB444", + "ARGB4444pm", + 0 + }; + + QImage::Format formats[] = { + QImage::Format_Indexed8, + QImage::Format_RGB32, + QImage::Format_ARGB32, + QImage::Format_ARGB32_Premultiplied, + QImage::Format_RGB16, + QImage::Format_ARGB8565_Premultiplied, + QImage::Format_RGB666, + QImage::Format_ARGB6666_Premultiplied, + QImage::Format_RGB555, + QImage::Format_ARGB8555_Premultiplied, + QImage::Format_RGB888, + QImage::Format_RGB444, + QImage::Format_ARGB4444_Premultiplied + }; + + for (int i=0; names[i] != 0; ++i) { + QByteArray name; + name.append(names[i]).append(", "); + + QTest::newRow(QByteArray(name).append("black").constData()) << formats[i] << Qt::black << 0xff000000; + QTest::newRow(QByteArray(name).append("white").constData()) << formats[i] << Qt::white << 0xffffffff; + QTest::newRow(QByteArray(name).append("red").constData()) << formats[i] << Qt::red << 0xffff0000; + QTest::newRow(QByteArray(name).append("green").constData()) << formats[i] << Qt::green << 0xff00ff00; + QTest::newRow(QByteArray(name).append("blue").constData()) << formats[i] << Qt::blue << 0xff0000ff; + } + + QTest::newRow("RGB16, transparent") << QImage::Format_RGB16 << Qt::transparent << 0xff000000; + QTest::newRow("RGB32, transparent") << QImage::Format_RGB32 << Qt::transparent << 0xff000000; + QTest::newRow("ARGB32, transparent") << QImage::Format_ARGB32 << Qt::transparent << 0x00000000u; + QTest::newRow("ARGB32pm, transparent") << QImage::Format_ARGB32_Premultiplied << Qt::transparent << 0x00000000u; +} + +void tst_QImage::fillColor() +{ + QFETCH(QImage::Format, format); + QFETCH(Qt::GlobalColor, color); + QFETCH(uint, pixelValue); + + QImage image(1, 1, format); + + if (image.depth() == 8) { + QVector table; + table << 0xff000000; + table << 0xffffffff; + table << 0xffff0000; + table << 0xff00ff00; + table << 0xff0000ff; + image.setColorTable(table); + } + + image.fill(color); + if (image.depth() == 1) { + QCOMPARE(image.pixelIndex(0, 0), (int) pixelValue); + } else { + QCOMPARE(image.pixel(0, 0), pixelValue); + } + + image.fill(QColor(color)); + if (image.depth() == 1) { + QCOMPARE(image.pixelIndex(0, 0), (int) pixelValue); + } else { + QCOMPARE(image.pixel(0, 0), pixelValue); + } +} + +void tst_QImage::fillColorWithAlpha() +{ + QImage argb32(1, 1, QImage::Format_ARGB32); + argb32.fill(QColor(255, 0, 0, 127)); + QCOMPARE(argb32.pixel(0, 0), qRgba(255, 0, 0, 127)); + + QImage argb32pm(1, 1, QImage::Format_ARGB32_Premultiplied); + argb32pm.fill(QColor(255, 0, 0, 127)); + QCOMPARE(argb32pm.pixel(0, 0), 0x7f7f0000u); +} + + QTEST_MAIN(tst_QImage) #include "tst_qimage.moc" -- cgit v0.12 From ef2ee289926c175146e181292b2808225441307f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Aug 2010 10:14:50 +0200 Subject: Fix compilation with QT_NO_DEBUG_STREAM That code should have been removed in commit 26f43dcc70a0bcc8aec96a0ca6f648c543b97b10 There is a template member operator<< in QNoDebug --- src/corelib/io/qdebug.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 0591318..a9d5ad4 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -283,9 +283,6 @@ Q_CORE_EXPORT_INLINE QDebug qDebug() { return QDebug(QtDebugMsg); } inline QNoDebug qDebug() { return QNoDebug(); } #define qDebug QT_NO_QDEBUG_MACRO -template -inline QNoDebug operator<<(QNoDebug debug, const T &) { return debug; } - #endif #if !defined(QT_NO_WARNING_OUTPUT) -- 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 5203b315aae66ada8ced60fbce3064ad92551848 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Aug 2010 15:14:00 +0200 Subject: tst_qsharedpointer.cpp: fix compilation Mistake in commit 26f43dcc70a0bcc8aec96a0ca6f648c543b97b10 --- tests/auto/qsharedpointer/tst_qsharedpointer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp index 7b0f723..5e624e4 100644 --- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp @@ -765,7 +765,6 @@ void tst_QSharedPointer::objectCast() // again: ptr = qobject_cast >(baseptr); QVERIFY(ptr == data); -#endif } check(); @@ -806,7 +805,6 @@ void tst_QSharedPointer::objectCast() // again: otherptr = qobject_cast >(weakptr); QVERIFY(otherptr.isNull()); -#endif } check(); } -- 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 cda344eaa344e82ac682f9c7979fd5222333cab1 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 2 Aug 2010 13:40:58 +0200 Subject: Add benchmarks for QVariant(int type, void *copy = 0) Tests all built-in (core and GUI) types, both default construction (copy == 0) and copy construction. The benchmarks for GUI types must go into a separate file because core tests don't (and shouldn't) link against QtGui. Reviewed-by: Benjamin Poulain --- .../corelib/kernel/qvariant/tst_qvariant.cpp | 47 +++++++++ .../gui/kernel/qguivariant/qguivariant.pro | 6 ++ .../gui/kernel/qguivariant/tst_qguivariant.cpp | 111 +++++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 tests/benchmarks/gui/kernel/qguivariant/qguivariant.pro create mode 100644 tests/benchmarks/gui/kernel/qguivariant/tst_qguivariant.cpp diff --git a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp index 58cec4f..5e19c1b 100644 --- a/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/benchmarks/corelib/kernel/qvariant/tst_qvariant.cpp @@ -71,6 +71,11 @@ private slots: void floatVariantValue(); void rectVariantValue(); void stringVariantValue(); + + void createCoreType_data(); + void createCoreType(); + void createCoreTypeCopy_data(); + void createCoreTypeCopy(); }; void tst_qvariant::testBound() @@ -220,6 +225,48 @@ void tst_qvariant::stringVariantValue() } } +void tst_qvariant::createCoreType_data() +{ + QTest::addColumn("typeId"); + for (int i = 0; i <= QMetaType::LastCoreType; ++i) + QTest::newRow(QMetaType::typeName(i)) << i; + for (int i = QMetaType::FirstCoreExtType; i <= QMetaType::LastCoreExtType; ++i) + QTest::newRow(QMetaType::typeName(i)) << i; +} + +// Tests how fast a Qt core type can be default-constructed by a +// QVariant. The purpose of this benchmark is to measure the overhead +// of creating (and destroying) a QVariant compared to creating the +// type directly. +void tst_qvariant::createCoreType() +{ + QFETCH(int, typeId); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + QVariant(typeId, (void *)0); + } +} + +void tst_qvariant::createCoreTypeCopy_data() +{ + createCoreType_data(); +} + +// Tests how fast a Qt core type can be copy-constructed by a +// QVariant. The purpose of this benchmark is to measure the overhead +// of creating (and destroying) a QVariant compared to creating the +// type directly. +void tst_qvariant::createCoreTypeCopy() +{ + QFETCH(int, typeId); + QVariant other(typeId, (void *)0); + const void *copy = other.constData(); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + QVariant(typeId, copy); + } +} + QTEST_MAIN(tst_qvariant) #include "tst_qvariant.moc" diff --git a/tests/benchmarks/gui/kernel/qguivariant/qguivariant.pro b/tests/benchmarks/gui/kernel/qguivariant/qguivariant.pro new file mode 100644 index 0000000..4e05dd7 --- /dev/null +++ b/tests/benchmarks/gui/kernel/qguivariant/qguivariant.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qguivariant + +SOURCES += tst_qguivariant.cpp + diff --git a/tests/benchmarks/gui/kernel/qguivariant/tst_qguivariant.cpp b/tests/benchmarks/gui/kernel/qguivariant/tst_qguivariant.cpp new file mode 100644 index 0000000..4016be1 --- /dev/null +++ b/tests/benchmarks/gui/kernel/qguivariant/tst_qguivariant.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 + +#define ITERATION_COUNT 1e5 + +class tst_QGuiVariant : public QObject +{ + Q_OBJECT + +public: + tst_QGuiVariant(); + virtual ~tst_QGuiVariant(); + +private slots: + void createGuiType_data(); + void createGuiType(); + void createGuiTypeCopy_data(); + void createGuiTypeCopy(); +}; + +tst_QGuiVariant::tst_QGuiVariant() +{ +} + +tst_QGuiVariant::~tst_QGuiVariant() +{ +} + +void tst_QGuiVariant::createGuiType_data() +{ + QTest::addColumn("typeId"); + for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) + QTest::newRow(QMetaType::typeName(i)) << i; +} + +// Tests how fast a Qt GUI type can be default-constructed by a +// QVariant. The purpose of this benchmark is to measure the overhead +// of creating (and destroying) a QVariant compared to creating the +// type directly. +void tst_QGuiVariant::createGuiType() +{ + QFETCH(int, typeId); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + QVariant(typeId, (void *)0); + } +} + +void tst_QGuiVariant::createGuiTypeCopy_data() +{ + createGuiType_data(); +} + +// Tests how fast a Qt GUI type can be copy-constructed by a +// QVariant. The purpose of this benchmark is to measure the overhead +// of creating (and destroying) a QVariant compared to creating the +// type directly. +void tst_QGuiVariant::createGuiTypeCopy() +{ + QFETCH(int, typeId); + QVariant other(typeId, (void *)0); + const void *copy = other.constData(); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + QVariant(typeId, copy); + } +} + +QTEST_MAIN(tst_QGuiVariant) +#include "tst_qguivariant.moc" -- cgit v0.12 From a0ee11510df847fee64274d260a6c5f693a70787 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 2 Aug 2010 16:11:33 +0200 Subject: Add benchmarks for QMetaType::construct(int type, void *copy = 0) Tests all built-in (core and GUI) types, both default construction (copy == 0) and copy construction. The benchmarks for GUI types must go into a separate file because core tests don't (and shouldn't) link against QtGui. Reviewed-by: Benjamin Poulain --- .../corelib/kernel/qmetatype/tst_qmetatype.cpp | 52 ++++++++++ .../gui/kernel/qguimetatype/qguimetatype.pro | 6 ++ .../gui/kernel/qguimetatype/tst_qguimetatype.cpp | 113 +++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 tests/benchmarks/gui/kernel/qguimetatype/qguimetatype.pro create mode 100644 tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp diff --git a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp index 36399af..ebeea84 100644 --- a/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/benchmarks/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -71,6 +71,11 @@ private slots: void isRegisteredBuiltin(); void isRegisteredCustom(); void isRegisteredNotRegistered(); + + void constructCoreType_data(); + void constructCoreType(); + void constructCoreTypeCopy_data(); + void constructCoreTypeCopy(); }; tst_QMetaType::tst_QMetaType() @@ -229,5 +234,52 @@ void tst_QMetaType::isRegisteredNotRegistered() } } +void tst_QMetaType::constructCoreType_data() +{ + QTest::addColumn("typeId"); + for (int i = 0; i <= QMetaType::LastCoreType; ++i) + QTest::newRow(QMetaType::typeName(i)) << i; + for (int i = QMetaType::FirstCoreExtType; i <= QMetaType::LastCoreExtType; ++i) + QTest::newRow(QMetaType::typeName(i)) << i; + // GUI types are tested in tst_QGuiMetaType. +} + +// Tests how fast QMetaType can default-construct and destroy a Qt +// core type. The purpose of this benchmark is to measure the overhead +// of using type id-based creation compared to creating the type +// directly (i.e. "T *t = new T(); delete t;"). +void tst_QMetaType::constructCoreType() +{ + QFETCH(int, typeId); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) { + void *data = QMetaType::construct(typeId, (void *)0); + QMetaType::destroy(typeId, data); + } + } +} + +void tst_QMetaType::constructCoreTypeCopy_data() +{ + constructCoreType_data(); +} + +// Tests how fast QMetaType can copy-construct and destroy a Qt core +// type. The purpose of this benchmark is to measure the overhead of +// using type id-based creation compared to creating the type directly +// (i.e. "T *t = new T(other); delete t;"). +void tst_QMetaType::constructCoreTypeCopy() +{ + QFETCH(int, typeId); + QVariant other(typeId, (void *)0); + const void *copy = other.constData(); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) { + void *data = QMetaType::construct(typeId, copy); + QMetaType::destroy(typeId, data); + } + } +} + QTEST_MAIN(tst_QMetaType) #include "tst_qmetatype.moc" diff --git a/tests/benchmarks/gui/kernel/qguimetatype/qguimetatype.pro b/tests/benchmarks/gui/kernel/qguimetatype/qguimetatype.pro new file mode 100644 index 0000000..7ef99e4 --- /dev/null +++ b/tests/benchmarks/gui/kernel/qguimetatype/qguimetatype.pro @@ -0,0 +1,6 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qguimetatype + +SOURCES += tst_qguimetatype.cpp + diff --git a/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp new file mode 100644 index 0000000..f94767b --- /dev/null +++ b/tests/benchmarks/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -0,0 +1,113 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 + +class tst_QGuiMetaType : public QObject +{ + Q_OBJECT + +public: + tst_QGuiMetaType(); + virtual ~tst_QGuiMetaType(); + +private slots: + void constructGuiType_data(); + void constructGuiType(); + void constructGuiTypeCopy_data(); + void constructGuiTypeCopy(); +}; + +tst_QGuiMetaType::tst_QGuiMetaType() +{ +} + +tst_QGuiMetaType::~tst_QGuiMetaType() +{ +} + +void tst_QGuiMetaType::constructGuiType_data() +{ + QTest::addColumn("typeId"); + for (int i = QMetaType::FirstGuiType; i <= QMetaType::LastGuiType; ++i) + QTest::newRow(QMetaType::typeName(i)) << i; +} + +// Tests how fast QMetaType can default-construct and destroy a Qt GUI +// type. The purpose of this benchmark is to measure the overhead of +// using type id-based creation compared to creating the type directly +// (i.e. "T *t = new T(); delete t;"). +void tst_QGuiMetaType::constructGuiType() +{ + QFETCH(int, typeId); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) { + void *data = QMetaType::construct(typeId, (void *)0); + QMetaType::destroy(typeId, data); + } + } +} + +void tst_QGuiMetaType::constructGuiTypeCopy_data() +{ + constructGuiType_data(); +} + +// Tests how fast QMetaType can copy-construct and destroy a Qt GUI +// type. The purpose of this benchmark is to measure the overhead of +// using type id-based creation compared to creating the type directly +// (i.e. "T *t = new T(other); delete t;"). +void tst_QGuiMetaType::constructGuiTypeCopy() +{ + QFETCH(int, typeId); + QVariant other(typeId, (void *)0); + const void *copy = other.constData(); + QBENCHMARK { + for (int i = 0; i < 100000; ++i) { + void *data = QMetaType::construct(typeId, copy); + QMetaType::destroy(typeId, data); + } + } +} + +QTEST_MAIN(tst_QGuiMetaType) +#include "tst_qguimetatype.moc" -- cgit v0.12 From 548840aa9ef4428ee29cae145a179f8752ae8eb6 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Mon, 2 Aug 2010 07:49:21 +0200 Subject: Add benchmarks for QtScript's QObject binding The benchmarks cover the following: - Reading and writing meta-object-defined properties. - Reading and writing dynamic properties. - Reading child objects. - Reading script-defined (wrapper object) properties. - Reading prototype-inherited properties. - Calling slots (overloaded and non-overloaded, with or without implicit argument conversion). - Signal handling. Both "simple" and "complex" objects are tested. A "simple" object is an object that inherits directly from QObject, i.e. it doesn't drag with it a lot of stuff. A "complex" object is an object that has many properties and a relatively long inheritance chain (currently QPushButton is used). Reviewed-by: Jedrzej Nowacki --- .../script/qscriptqobject/qscriptqobject.pro | 7 + .../script/qscriptqobject/tst_qscriptqobject.cpp | 1237 ++++++++++++++++++++ 2 files changed, 1244 insertions(+) create mode 100644 tests/benchmarks/script/qscriptqobject/qscriptqobject.pro create mode 100644 tests/benchmarks/script/qscriptqobject/tst_qscriptqobject.cpp diff --git a/tests/benchmarks/script/qscriptqobject/qscriptqobject.pro b/tests/benchmarks/script/qscriptqobject/qscriptqobject.pro new file mode 100644 index 0000000..30bc447 --- /dev/null +++ b/tests/benchmarks/script/qscriptqobject/qscriptqobject.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_bench_qscriptqobject + +SOURCES += tst_qscriptqobject.cpp + +QT += script diff --git a/tests/benchmarks/script/qscriptqobject/tst_qscriptqobject.cpp b/tests/benchmarks/script/qscriptqobject/tst_qscriptqobject.cpp new file mode 100644 index 0000000..e68db06 --- /dev/null +++ b/tests/benchmarks/script/qscriptqobject/tst_qscriptqobject.cpp @@ -0,0 +1,1237 @@ +/**************************************************************************** +** +** 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 test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in 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 + +#define ITERATION_COUNT 1e4 + +struct CustomType +{ + int a; +}; +Q_DECLARE_METATYPE(CustomType) + +class PropertyTestObject : public QObject +{ + Q_OBJECT + Q_ENUMS(EnumType) + Q_FLAGS(FlagsType) + Q_PROPERTY(bool boolProperty READ boolProperty WRITE setBoolProperty) + Q_PROPERTY(int intProperty READ intProperty WRITE setIntProperty) + Q_PROPERTY(double doubleProperty READ doubleProperty WRITE setDoubleProperty) + Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty) + Q_PROPERTY(QVariant variantProperty READ variantProperty WRITE setVariantProperty) + Q_PROPERTY(QObject* qobjectProperty READ qobjectProperty WRITE setQObjectProperty) + Q_PROPERTY(CustomType customProperty READ customProperty WRITE setCustomProperty) + Q_PROPERTY(EnumType enumProperty READ enumProperty WRITE setEnumProperty) + Q_PROPERTY(FlagsType flagsProperty READ flagsProperty WRITE setFlagsProperty) +public: + enum EnumType { + NoEnumValue = 0, + FirstEnumValue = 1, + SecondEnumValue = 2, + ThirdEnumValue = 4 + }; + Q_DECLARE_FLAGS(FlagsType, EnumType) + + PropertyTestObject(QObject *parent = 0) + : QObject(parent), + m_boolProperty(false), + m_intProperty(123), + m_doubleProperty(123), + m_stringProperty("hello"), + m_variantProperty(double(123)), + m_qobjectProperty(this), + m_enumProperty(SecondEnumValue), + m_flagsProperty(FirstEnumValue | ThirdEnumValue) + { } + + bool boolProperty() const + { return m_boolProperty; } + void setBoolProperty(bool value) + { m_boolProperty = value; } + + int intProperty() const + { return m_intProperty; } + void setIntProperty(int value) + { m_intProperty = value; } + + int doubleProperty() const + { return m_doubleProperty; } + void setDoubleProperty(double value) + { m_doubleProperty = value; } + + QString stringProperty() const + { return m_stringProperty; } + void setStringProperty(const QString &value) + { m_stringProperty = value; } + + QVariant variantProperty() const + { return m_variantProperty; } + void setVariantProperty(const QVariant &value) + { m_variantProperty = value; } + + QObject *qobjectProperty() const + { return m_qobjectProperty; } + void setQObjectProperty(QObject *qobject) + { m_qobjectProperty = qobject; } + + CustomType customProperty() const + { return m_customProperty; } + void setCustomProperty(const CustomType &value) + { m_customProperty = value; } + + EnumType enumProperty() const + { return m_enumProperty; } + void setEnumProperty(EnumType value) + { m_enumProperty = value; } + + FlagsType flagsProperty() const + { return m_flagsProperty; } + void setFlagsProperty(FlagsType value) + { m_flagsProperty = value; } + +private: + bool m_boolProperty; + int m_intProperty; + double m_doubleProperty; + QString m_stringProperty; + QVariant m_variantProperty; + QObject *m_qobjectProperty; + CustomType m_customProperty; + EnumType m_enumProperty; + FlagsType m_flagsProperty; +}; + +class SlotTestObject : public QObject +{ + Q_OBJECT +public: + SlotTestObject(QObject *parent = 0) + : QObject(parent), + m_string(QString::fromLatin1("hello")), + m_variant(123) + { } + +public Q_SLOTS: + void voidSlot() { } + void boolSlot(bool) { } + void intSlot(int) { } + void doubleSlot(double) { } + void stringSlot(const QString &) { } + void variantSlot(const QVariant &) { } + void qobjectSlot(QObject *) { } + void customTypeSlot(const CustomType &) { } + + bool returnBoolSlot() { return true; } + int returnIntSlot() { return 123; } + double returnDoubleSlot() { return 123.0; } + QString returnStringSlot() { return m_string; } + QVariant returnVariantSlot() { return m_variant; } + QObject *returnQObjectSlot() { return this; } + CustomType returnCustomTypeSlot() { return m_custom; } + + void fourDoubleSlot(double, double, double, double) { } + void sixDoubleSlot(double, double, double, double, double, double) { } + void eightDoubleSlot(double, double, double, double, double, double, double, double) { } + + void fourStringSlot(const QString &, const QString &, const QString &, const QString &) { } + void sixStringSlot(const QString &, const QString &, const QString &, const QString &, + const QString &, const QString &) { } + void eightStringSlot(const QString &, const QString &, const QString &, const QString &, + const QString &, const QString &, const QString &, const QString &) { } + +private: + QString m_string; + QVariant m_variant; + CustomType m_custom; +}; + +class SignalTestObject : public QObject +{ + Q_OBJECT +public: + SignalTestObject(QObject *parent = 0) + : QObject(parent) + { } + + void emitVoidSignal() + { emit voidSignal(); } + void emitBoolSignal(bool value) + { emit boolSignal(value); } + void emitIntSignal(int value) + { emit intSignal(value); } + void emitDoubleSignal(double value) + { emit doubleSignal(value); } + void emitStringSignal(const QString &value) + { emit stringSignal(value); } + void emitVariantSignal(const QVariant &value) + { emit variantSignal(value); } + void emitQObjectSignal(QObject *object) + { emit qobjectSignal(object); } + void emitCustomTypeSignal(const CustomType &value) + { emit customTypeSignal(value); } + +Q_SIGNALS: + void voidSignal(); + void boolSignal(bool); + void intSignal(int); + void doubleSignal(double); + void stringSignal(const QString &); + void variantSignal(const QVariant &); + void qobjectSignal(QObject *); + void customTypeSignal(const CustomType &); +}; + +class OverloadedSlotTestObject : public QObject +{ + Q_OBJECT +public: + OverloadedSlotTestObject(QObject *parent = 0) + : QObject(parent) + { } + +public Q_SLOTS: + void overloadedSlot() { } + void overloadedSlot(bool) { } + void overloadedSlot(double) { } + void overloadedSlot(const QString &) { } +}; + +class QtScriptablePropertyTestObject + : public PropertyTestObject, public QScriptable +{ +}; + +class QtScriptableSlotTestObject + : public SlotTestObject, public QScriptable +{ +}; + +class tst_QScriptQObject : public QObject +{ + Q_OBJECT + +public: + tst_QScriptQObject(); + virtual ~tst_QScriptQObject(); + +private slots: + void initTestCase(); + + void readMetaProperty_data(); + void readMetaProperty(); + + void writeMetaProperty_data(); + void writeMetaProperty(); + + void readDynamicProperty_data(); + void readDynamicProperty(); + + void writeDynamicProperty_data(); + void writeDynamicProperty(); + + void readMethodByName_data(); + void readMethodByName(); + + void readMethodBySignature_data(); + void readMethodBySignature(); + + void readChild_data(); + void readChild(); + + void readOneOfManyChildren_data(); + void readOneOfManyChildren(); + + void readPrototypeProperty_data(); + void readPrototypeProperty(); + + void readScriptProperty_data(); + void readScriptProperty(); + + void readNoSuchProperty_data(); + void readNoSuchProperty(); + + void readAllMetaProperties(); + + void callSlot_data(); + void callSlot(); + + void callOverloadedSlot_data(); + void callOverloadedSlot(); + + void voidSignalHandler(); + void boolSignalHandler(); + void intSignalHandler(); + void doubleSignalHandler(); + void stringSignalHandler(); + void variantSignalHandler(); + void qobjectSignalHandler(); + void customTypeSignalHandler(); + + void readButtonMetaProperty_data(); + void readButtonMetaProperty(); + + void writeButtonMetaProperty_data(); + void writeButtonMetaProperty(); + + void readDynamicButtonProperty_data(); + void readDynamicButtonProperty(); + + void writeDynamicButtonProperty_data(); + void writeDynamicButtonProperty(); + + void readButtonMethodByName_data(); + void readButtonMethodByName(); + + void readButtonMethodBySignature_data(); + void readButtonMethodBySignature(); + + void readButtonChild_data(); + void readButtonChild(); + + void readButtonPrototypeProperty_data(); + void readButtonPrototypeProperty(); + + void readButtonScriptProperty_data(); + void readButtonScriptProperty(); + + void readNoSuchButtonProperty_data(); + void readNoSuchButtonProperty(); + + void callButtonMethod_data(); + void callButtonMethod(); + + void readAllButtonMetaProperties(); + + void readQScriptableMetaProperty_data(); + void readQScriptableMetaProperty(); + + void writeQScriptableMetaProperty_data(); + void writeQScriptableMetaProperty(); + + void callQScriptableSlot_data(); + void callQScriptableSlot(); + +private: + void readMetaProperty_dataHelper(const QMetaObject *mo); + void readMethodByName_dataHelper(const QMetaObject *mo); + void readMethodBySignature_dataHelper(const QMetaObject *mo); + void readAllMetaPropertiesHelper(QObject *o); + + void readPropertyHelper(QScriptEngine &engine, const QScriptValue &object, + const QString &propertyName, const QString &argTemplate = ".%0"); + void writePropertyHelper(QScriptEngine &engine, const QScriptValue &object, + const QString &propertyName, const QScriptValue &value, + const QString &argTemplate = ".%0"); + + void callMethodHelper(QScriptEngine &engine, QObject *object, + const QString &propertyName, const QString &arguments); + void signalHandlerHelper(QScriptEngine &engine, QObject *object, const char *signal); +}; + +tst_QScriptQObject::tst_QScriptQObject() +{ +} + +tst_QScriptQObject::~tst_QScriptQObject() +{ +} + +void tst_QScriptQObject::initTestCase() +{ + qMetaTypeId(); +} + +void tst_QScriptQObject::readMetaProperty_dataHelper(const QMetaObject *mo) +{ + QTest::addColumn("propertyName"); + + for (int i = 0; i < mo->propertyCount(); ++i) { + QMetaProperty prop = mo->property(i); + if (!qstrcmp(prop.name(), "default")) + continue; // skip reserved word + QTest::newRow(prop.name()) << prop.name(); + } +} + +void tst_QScriptQObject::readMethodByName_dataHelper(const QMetaObject *mo) +{ + QTest::addColumn("propertyName"); + + QSet uniqueNames; + for (int i = 0; i < mo->methodCount(); ++i) { + QMetaMethod method = mo->method(i); + if (method.access() == QMetaMethod::Private) + continue; + QByteArray signature = method.signature(); + QByteArray name = signature.left(signature.indexOf('(')); + if (uniqueNames.contains(name)) + continue; + QTest::newRow(name) << QString::fromLatin1(name); + uniqueNames.insert(name); + } +} + +void tst_QScriptQObject::readMethodBySignature_dataHelper(const QMetaObject *mo) +{ + QTest::addColumn("propertyName"); + + for (int i = 0; i < mo->methodCount(); ++i) { + QMetaMethod method = mo->method(i); + if (method.access() == QMetaMethod::Private) + continue; + QTest::newRow(method.signature()) << QString::fromLatin1(method.signature()); + } +} + +void tst_QScriptQObject::readAllMetaPropertiesHelper(QObject *o) +{ + QString code = QString::fromLatin1( + "(function() {\n" + " for (var i = 0; i < 100; ++i) {\n"); + const QMetaObject *mo = o->metaObject(); + for (int i = 0; i < mo->propertyCount(); ++i) { + QMetaProperty prop = mo->property(i); + if (!qstrcmp(prop.name(), "default")) + continue; // skip reserved word + code.append(QString::fromLatin1(" this.%0;\n").arg(prop.name())); + } + code.append( + " }\n" + "})"); + + QScriptEngine engine; + QScriptValue fun = engine.evaluate(code); + QVERIFY(fun.isFunction()); + + QScriptValue wrapper = engine.newQObject(o); + QBENCHMARK { + fun.call(wrapper); + } + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QScriptQObject::readPropertyHelper( + QScriptEngine &engine, const QScriptValue &object, + const QString &propertyName, const QString &argTemplate) +{ + QString code = QString::fromLatin1( + "(function() {\n" + " for (var i = 0; i < %0; ++i)\n" + " this%1;\n" + "})").arg(ITERATION_COUNT).arg(argTemplate.arg(propertyName)); + QScriptValue fun = engine.evaluate(code); + QVERIFY(fun.isFunction()); + + QBENCHMARK { + fun.call(object); + } + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QScriptQObject::writePropertyHelper( + QScriptEngine &engine, const QScriptValue &object, + const QString &propertyName, const QScriptValue &value, + const QString &argTemplate) +{ + QVERIFY(value.isValid()); + QString code = QString::fromLatin1( + "(function(v) {\n" + " for (var i = 0; i < %0; ++i)\n" + " this%1 = v;\n" + "})").arg(ITERATION_COUNT).arg(argTemplate.arg(propertyName)); + QScriptValue fun = engine.evaluate(code); + QVERIFY(fun.isFunction()); + + QScriptValueList args; + args << value; + QBENCHMARK { + fun.call(object, args); + } + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QScriptQObject::callMethodHelper( + QScriptEngine &engine, QObject *object, + const QString &propertyName, const QString &arguments) +{ + QScriptValue wrapper = engine.newQObject(object); + QScriptValue method = wrapper.property(propertyName); + QVERIFY(method.isFunction()); + + // Generate code that calls the function directly; in this way + // only function call performance is measured, not function lookup + // as well. + QString code = QString::fromLatin1( + "(function(f) {\n" + " for (var i = 0; i < %0; ++i)\n" + " f(%1);\n" + "})").arg(ITERATION_COUNT).arg(arguments); + QScriptValue fun = engine.evaluate(code); + QVERIFY(fun.isFunction()); + + QScriptValueList args; + args << method; + QBENCHMARK { + fun.call(wrapper, args); + } + QVERIFY(!engine.hasUncaughtException()); +} + +void tst_QScriptQObject::signalHandlerHelper( + QScriptEngine &engine, QObject *object, const char *signal) +{ + QScriptValue handler = engine.evaluate("(function(a) { return a; })"); + QVERIFY(handler.isFunction()); + QVERIFY(qScriptConnect(object, signal, QScriptValue(), handler)); +} + +void tst_QScriptQObject::readMetaProperty_data() +{ + readMetaProperty_dataHelper(&PropertyTestObject::staticMetaObject); +} + +// Reads a meta-object-defined property from JS. The purpose of this +// benchmark is to measure the overhead of reading a property from JS +// compared to calling the property getter directly from C++ without +// introspection or value conversion (that's the fastest we could +// possibly hope to get). +void tst_QScriptQObject::readMetaProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + PropertyTestObject testObject; + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName); +} + +void tst_QScriptQObject::writeMetaProperty_data() +{ + readMetaProperty_data(); +} + +// Writes a meta-object-defined property from JS. The purpose of this +// benchmark is to measure the overhead of writing a property from JS +// compared to calling the property setter directly from C++ without +// introspection or value conversion (that's the fastest we could +// possibly hope to get). +void tst_QScriptQObject::writeMetaProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + PropertyTestObject testObject; + QScriptValue wrapper = engine.newQObject(&testObject); + QScriptValue value = wrapper.property(propertyName); + writePropertyHelper(engine, wrapper, propertyName, value); +} + +void tst_QScriptQObject::readDynamicProperty_data() +{ + QTest::addColumn("value"); + + QTest::newRow("bool") << QVariant(false); + QTest::newRow("int") << QVariant(123); + QTest::newRow("double") << QVariant(double(123.0)); + QTest::newRow("string") << QVariant(QString::fromLatin1("hello")); + QTest::newRow("QObject*") << qVariantFromValue((QObject*)this); + QTest::newRow("CustomType") << qVariantFromValue(CustomType()); +} + +// Reads a dynamic property from JS. The purpose of this benchmark is +// to measure the overhead of reading a dynamic property from JS +// versus calling QObject::property(aDynamicProperty) directly from +// C++. +void tst_QScriptQObject::readDynamicProperty() +{ + QFETCH(QVariant, value); + + QObject testObject; + const char *propertyName = "dynamicProperty"; + testObject.setProperty(propertyName, value); + QVERIFY(testObject.dynamicPropertyNames().contains(propertyName)); + + QScriptEngine engine; + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName); +} + +void tst_QScriptQObject::writeDynamicProperty_data() +{ + readDynamicProperty_data(); +} + +// Writes an existing dynamic property from JS. The purpose of this +// benchmark is to measure the overhead of writing a dynamic property +// from JS versus calling QObject::setProperty(aDynamicProperty, +// aVariant) directly from C++. +void tst_QScriptQObject::writeDynamicProperty() +{ + QFETCH(QVariant, value); + + QObject testObject; + const char *propertyName = "dynamicProperty"; + testObject.setProperty(propertyName, value); + QVERIFY(testObject.dynamicPropertyNames().contains(propertyName)); + + QScriptEngine engine; + writePropertyHelper(engine, engine.newQObject(&testObject), propertyName, + qScriptValueFromValue(&engine, value)); +} + +void tst_QScriptQObject::readMethodByName_data() +{ + readMethodByName_dataHelper(&SlotTestObject::staticMetaObject); +} + +// Reads a meta-object-defined method from JS by name. The purpose of +// this benchmark is to measure the overhead of resolving a method +// from JS (effectively, creating and returning a JS wrapper function +// object for a C++ method). +void tst_QScriptQObject::readMethodByName() +{ + readMetaProperty(); +} + +void tst_QScriptQObject::readMethodBySignature_data() +{ + readMethodBySignature_dataHelper(&SlotTestObject::staticMetaObject); +} + +// Reads a meta-object-defined method from JS by signature. The +// purpose of this benchmark is to measure the overhead of resolving a +// method from JS (effectively, creating and returning a JS wrapper +// function object for a C++ method). +void tst_QScriptQObject::readMethodBySignature() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + SlotTestObject testObject; + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName, "['%0']"); +} + +void tst_QScriptQObject::readChild_data() +{ + QTest::addColumn("propertyName"); + + QTest::newRow("child") << "child"; +} + +// Reads a child object from JS. The purpose of this benchmark is to +// measure the overhead of reading a child object from JS compared to +// calling e.g. qFindChild() directly from C++, when the test object +// is a plain QObject with only one child. +void tst_QScriptQObject::readChild() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QObject testObject; + QObject *child = new QObject(&testObject); + child->setObjectName(propertyName); + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName); +} + +void tst_QScriptQObject::readOneOfManyChildren_data() +{ + QTest::addColumn("propertyName"); + + QTest::newRow("child0") << "child0"; + QTest::newRow("child50") << "child50"; + QTest::newRow("child99") << "child99"; +} + +// Reads a child object from JS for an object that has many +// children. The purpose of this benchmark is to measure the overhead +// of reading a child object from JS compared to calling +// e.g. qFindChild() directly from C++. +void tst_QScriptQObject::readOneOfManyChildren() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QObject testObject; + for (int i = 0; i < 100; ++i) { + QObject *child = new QObject(&testObject); + child->setObjectName(QString::fromLatin1("child%0").arg(i)); + } + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName); +} + +void tst_QScriptQObject::readPrototypeProperty_data() +{ + QTest::addColumn("propertyName"); + + // Inherited from Object.prototype. + QTest::newRow("hasOwnProperty") << "hasOwnProperty"; + QTest::newRow("isPrototypeOf") << "isPrototypeOf"; + QTest::newRow("propertyIsEnumerable") << "propertyIsEnumerable"; + QTest::newRow("valueOf") << "valueOf"; +} + +// Reads a property that's inherited from a prototype object. The +// purpose of this benchmark is to measure the overhead of resolving a +// prototype property (i.e., how long it takes the binding to +// determine that the QObject doesn't have the property itself). +void tst_QScriptQObject::readPrototypeProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + PropertyTestObject testObject; + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName); +} + +void tst_QScriptQObject::readScriptProperty_data() +{ + QTest::addColumn("propertyName"); + + QTest::newRow("scriptProperty") << "scriptProperty"; +} + +// Reads a JS (non-Qt) property of a wrapper object. The purpose of +// this benchmark is to measure the overhead of reading a property +// that only exists on the wrapper object, not on the underlying +// QObject. +void tst_QScriptQObject::readScriptProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + PropertyTestObject testObject; + QScriptValue wrapper = engine.newQObject(&testObject); + wrapper.setProperty(propertyName, 123); + QVERIFY(wrapper.property(propertyName).isValid()); + QVERIFY(!testObject.property(propertyName.toLatin1()).isValid()); + + readPropertyHelper(engine, wrapper, propertyName); +} + +void tst_QScriptQObject::readNoSuchProperty_data() +{ + QTest::addColumn("propertyName"); + + QTest::newRow("noSuchProperty") << "noSuchProperty"; +} + +// Reads a non-existing (undefined) property of a wrapper object. The +// purpose of this benchmark is to measure the overhead of reading a +// property that doesn't exist (i.e., how long it takes the binding to +// determine this). +void tst_QScriptQObject::readNoSuchProperty() +{ + readMetaProperty(); +} + +// Reads all meta-object-defined properties from JS. The purpose of +// this benchmark is to measure the overhead of reading different +// properties in sequence, not just the same one repeatedly (like +// readMetaProperty() does). +void tst_QScriptQObject::readAllMetaProperties() +{ + PropertyTestObject testObject; + readAllMetaPropertiesHelper(&testObject); +} + +void tst_QScriptQObject::callSlot_data() +{ + QTest::addColumn("propertyName"); + QTest::addColumn("arguments"); + + QTest::newRow("voidSlot()") << "voidSlot" << ""; + + QTest::newRow("boolSlot(true)") << "boolSlot" << "true"; + QTest::newRow("intSlot(123)") << "intSlot" << "123"; + QTest::newRow("doubleSlot(123)") << "doubleSlot" << "123"; + QTest::newRow("stringSlot('hello')") << "stringSlot" << "'hello'"; + QTest::newRow("variantSlot(123)") << "variantSlot" << "123"; + QTest::newRow("qobjectSlot(this)") << "qobjectSlot" << "this"; // assumes 'this' is a QObject + + QTest::newRow("returnBoolSlot()") << "returnBoolSlot" << ""; + QTest::newRow("returnIntSlot()") << "returnIntSlot" << ""; + QTest::newRow("returnDoubleSlot()") << "returnDoubleSlot" << ""; + QTest::newRow("returnStringSlot()") << "returnStringSlot" << ""; + QTest::newRow("returnVariantSlot()") << "returnVariantSlot" << ""; + QTest::newRow("returnQObjectSlot()") << "returnQObjectSlot" << ""; + QTest::newRow("returnCustomTypeSlot()") << "returnCustomTypeSlot" << ""; + + // Implicit conversion. + QTest::newRow("boolSlot(0)") << "boolSlot" << "0"; + QTest::newRow("intSlot('123')") << "intSlot" << "'123'"; + QTest::newRow("doubleSlot('123')") << "doubleSlot" << "'123'"; + QTest::newRow("stringSlot(123)") << "stringSlot" << "123"; + + // Many arguments. + QTest::newRow("fourDoubleSlot(1,2,3,4)") << "fourDoubleSlot" << "1,2,3,4"; + QTest::newRow("sixDoubleSlot(1,2,3,4,5,6)") << "sixDoubleSlot" << "1,2,3,4,5,6"; + QTest::newRow("eightDoubleSlot(1,2,3,4,5,6,7,8)") << "eightDoubleSlot" << "1,2,3,4,5,6,7,8"; + + QTest::newRow("fourStringSlot('a','b','c','d')") << "fourStringSlot" << "'a','b','c','d'"; + QTest::newRow("sixStringSlot('a','b','c','d','e','f')") << "sixStringSlot" << "'a','b','c','d','e','f'"; + QTest::newRow("eightStringSlot('a','b','c','d','e','f','g','h')") << "eightStringSlot" << "'a','b','c','d','e','f','g','h'"; +} + +// Calls a slot from JS. The purpose of this benchmark is to measure +// the overhead of calling a slot from JS compared to calling the slot +// directly from C++ without introspection or value conversion (that's +// the fastest we could possibly hope to get). The slots themselves +// don't do any work. +void tst_QScriptQObject::callSlot() +{ + QFETCH(QString, propertyName); + QFETCH(QString, arguments); + + QScriptEngine engine; + SlotTestObject testObject; + callMethodHelper(engine, &testObject, propertyName, arguments); +} + +void tst_QScriptQObject::callOverloadedSlot_data() +{ + QTest::addColumn("propertyName"); + QTest::addColumn("arguments"); + + QTest::newRow("overloadedSlot()") << "overloadedSlot" << ""; + QTest::newRow("overloadedSlot(true)") << "overloadedSlot" << "true"; + QTest::newRow("overloadedSlot(123)") << "overloadedSlot" << "123"; + QTest::newRow("overloadedSlot('hello')") << "overloadedSlot" << "'hello'"; +} + +// Calls an overloaded slot from JS. The purpose of this benchmark is +// to measure the overhead of calling an overloaded slot from JS +// compared to calling the overloaded slot directly from C++ without +// introspection or value conversion (that's the fastest we could +// possibly hope to get). +void tst_QScriptQObject::callOverloadedSlot() +{ + QFETCH(QString, propertyName); + QFETCH(QString, arguments); + + QScriptEngine engine; + OverloadedSlotTestObject testObject; + callMethodHelper(engine, &testObject, propertyName, arguments); +} + +// Benchmarks for JS signal handling. The purpose of these benchmarks +// is to measure the overhead of dispatching a Qt signal to JS code +// compared to a normal C++ signal-to-slot dispatch. + +void tst_QScriptQObject::voidSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(voidSignal())); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitVoidSignal(); + } +} + +void tst_QScriptQObject::boolSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(boolSignal(bool))); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitBoolSignal(true); + } +} + +void tst_QScriptQObject::intSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(intSignal(int))); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitIntSignal(123); + } +} + +void tst_QScriptQObject::doubleSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(doubleSignal(double))); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitDoubleSignal(123.0); + } +} + +void tst_QScriptQObject::stringSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(stringSignal(QString))); + QString value = QString::fromLatin1("hello"); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitStringSignal(value); + } +} + +void tst_QScriptQObject::variantSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(variantSignal(QVariant))); + QVariant value = 123; + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitVariantSignal(value); + } +} + +void tst_QScriptQObject::qobjectSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(qobjectSignal(QObject*))); + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitQObjectSignal(this); + } +} + +void tst_QScriptQObject::customTypeSignalHandler() +{ + SignalTestObject testObject; + QScriptEngine engine; + signalHandlerHelper(engine, &testObject, SIGNAL(customTypeSignal(CustomType))); + CustomType value; + QBENCHMARK { + for (int i = 0; i < ITERATION_COUNT; ++i) + testObject.emitCustomTypeSignal(value); + } +} + +void tst_QScriptQObject::readButtonMetaProperty_data() +{ + readMetaProperty_dataHelper(&QPushButton::staticMetaObject); +} + +// Reads a meta-object-defined property from JS. The purpose of this +// benchmark is to measure the overhead of reading a property from JS +// compared to calling the property getter directly from C++ without +// introspection or value conversion (that's the fastest we could +// possibly hope to get). +void tst_QScriptQObject::readButtonMetaProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QPushButton pb; + readPropertyHelper(engine, engine.newQObject(&pb), propertyName); +} + +void tst_QScriptQObject::writeButtonMetaProperty_data() +{ + readButtonMetaProperty_data(); +} + +// Writes a meta-object-defined property from JS. The purpose of this +// benchmark is to measure the overhead of writing a property from JS +// compared to calling the property setter directly from C++ without +// introspection or value conversion (that's the fastest we could +// possibly hope to get). +void tst_QScriptQObject::writeButtonMetaProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QPushButton pb; + QVariant value = pb.property(propertyName.toLatin1()); + writePropertyHelper(engine, engine.newQObject(&pb), propertyName, + qScriptValueFromValue(&engine, value)); +} + +void tst_QScriptQObject::readDynamicButtonProperty_data() +{ + readDynamicProperty_data(); +} + +// Reads a dynamic property from JS. The purpose of this benchmark is +// to measure the overhead of reading a dynamic property from JS +// versus calling QObject::property(aDynamicProperty) directly from +// C++. +void tst_QScriptQObject::readDynamicButtonProperty() +{ + QFETCH(QVariant, value); + + QPushButton pb; + const char *propertyName = "dynamicProperty"; + pb.setProperty(propertyName, value); + QVERIFY(pb.dynamicPropertyNames().contains(propertyName)); + + QScriptEngine engine; + readPropertyHelper(engine, engine.newQObject(&pb), propertyName); +} + +void tst_QScriptQObject::writeDynamicButtonProperty_data() +{ + readDynamicButtonProperty_data(); +} + +// Writes an existing dynamic property from JS. The purpose of this +// benchmark is to measure the overhead of writing a dynamic property +// from JS versus calling QObject::setProperty(aDynamicProperty, +// aVariant) directly from C++. +void tst_QScriptQObject::writeDynamicButtonProperty() +{ + QFETCH(QVariant, value); + + QPushButton pb; + const char *propertyName = "dynamicProperty"; + pb.setProperty(propertyName, value); + QVERIFY(pb.dynamicPropertyNames().contains(propertyName)); + + QScriptEngine engine; + writePropertyHelper(engine, engine.newQObject(&pb), propertyName, + qScriptValueFromValue(&engine, value)); +} + +void tst_QScriptQObject::readButtonMethodByName_data() +{ + readMethodByName_dataHelper(&QPushButton::staticMetaObject); +} + +// Reads a meta-object-defined method from JS by name. The purpose of +// this benchmark is to measure the overhead of resolving a method +// from JS (effectively, creating and returning a JS wrapper function +// object for a C++ method). +void tst_QScriptQObject::readButtonMethodByName() +{ + readButtonMetaProperty(); +} + +void tst_QScriptQObject::readButtonMethodBySignature_data() +{ + readMethodBySignature_dataHelper(&QPushButton::staticMetaObject); +} + +// Reads a meta-object-defined method from JS by signature. The +// purpose of this benchmark is to measure the overhead of resolving a +// method from JS (effectively, creating and returning a JS wrapper +// function object for a C++ method). +void tst_QScriptQObject::readButtonMethodBySignature() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QPushButton pb; + readPropertyHelper(engine, engine.newQObject(&pb), propertyName, "['%0']"); +} + +void tst_QScriptQObject::readButtonChild_data() +{ + QTest::addColumn("propertyName"); + + QTest::newRow("child") << "child"; +} + +// Reads a child object from JS. The purpose of this benchmark is to +// measure the overhead of reading a child object from JS compared to +// calling e.g. qFindChild() directly from C++. +void tst_QScriptQObject::readButtonChild() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QPushButton pb; + QObject *child = new QObject(&pb); + child->setObjectName(propertyName); + readPropertyHelper(engine, engine.newQObject(&pb), propertyName); +} + +void tst_QScriptQObject::readButtonPrototypeProperty_data() +{ + readPrototypeProperty_data(); +} + +// Reads a property that's inherited from a prototype object. The +// purpose of this benchmark is to measure the overhead of resolving a +// prototype property (i.e., how long does it take the binding to +// determine that the QObject doesn't have the property itself). +void tst_QScriptQObject::readButtonPrototypeProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QPushButton pb; + readPropertyHelper(engine, engine.newQObject(&pb), propertyName); +} + +void tst_QScriptQObject::readButtonScriptProperty_data() +{ + readScriptProperty_data(); +} + +// Reads a JS (non-Qt) property of a wrapper object. The purpose of +// this benchmark is to measure the overhead of reading a property +// that only exists on the wrapper object, not on the underlying +// QObject. +void tst_QScriptQObject::readButtonScriptProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QPushButton pb; + QScriptValue wrapper = engine.newQObject(&pb); + wrapper.setProperty(propertyName, 123); + QVERIFY(wrapper.property(propertyName).isValid()); + QVERIFY(!pb.property(propertyName.toLatin1()).isValid()); + + readPropertyHelper(engine, wrapper, propertyName); +} + +void tst_QScriptQObject::readNoSuchButtonProperty_data() +{ + readNoSuchProperty_data(); +} + +// Reads a non-existing (undefined) property of a wrapper object. The +// purpose of this benchmark is to measure the overhead of reading a +// property that doesn't exist (i.e., how long does it take the +// binding to determine that it doesn't exist). +void tst_QScriptQObject::readNoSuchButtonProperty() +{ + readButtonMetaProperty(); +} + +void tst_QScriptQObject::callButtonMethod_data() +{ + QTest::addColumn("propertyName"); + QTest::addColumn("arguments"); + + QTest::newRow("click()") << "click" << ""; + QTest::newRow("animateClick(50)") << "animateClick" << "10"; + QTest::newRow("setChecked(true)") << "setChecked" << "true"; + QTest::newRow("close()") << "close" << ""; + QTest::newRow("setWindowTitle('foo')") << "setWindowTitle" << "'foo'"; +} + +// Calls a slot from JS. The purpose of this benchmark is to measure +// the overhead of calling a slot from JS compared to calling the slot +// directly from C++ without introspection or value conversion (that's +// the fastest we could possibly hope to get). +void tst_QScriptQObject::callButtonMethod() +{ + QFETCH(QString, propertyName); + QFETCH(QString, arguments); + + QScriptEngine engine; + QPushButton pb; + callMethodHelper(engine, &pb, propertyName, arguments); +} + +// Reads all meta-object-defined properties from JS. The purpose of +// this benchmark is to measure the overhead of reading different +// properties in sequence, not just the same one repeatedly (like +// readButtonMetaProperty() does). +void tst_QScriptQObject::readAllButtonMetaProperties() +{ + QPushButton pb; + readAllMetaPropertiesHelper(&pb); +} + +void tst_QScriptQObject::readQScriptableMetaProperty_data() +{ + readMetaProperty_dataHelper(&QtScriptablePropertyTestObject::staticMetaObject); +} + +// Reads a meta-object-defined property from JS for an object that +// subclasses QScriptable. The purpose of this benchmark is to measure +// the overhead compared to reading a property of a non-QScriptable +// (see readMetaProperty()). +void tst_QScriptQObject::readQScriptableMetaProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QtScriptablePropertyTestObject testObject; + readPropertyHelper(engine, engine.newQObject(&testObject), propertyName); +} + +void tst_QScriptQObject::writeQScriptableMetaProperty_data() +{ + readMetaProperty_data(); +} + +// Writes a meta-object-defined property from JS for an object that +// subclasses QScriptable. The purpose of this benchmark is to measure +// the overhead compared to writing a property of a non-QScriptable +// object (see writeMetaProperty()). +void tst_QScriptQObject::writeQScriptableMetaProperty() +{ + QFETCH(QString, propertyName); + + QScriptEngine engine; + QtScriptablePropertyTestObject testObject; + QVariant value = testObject.property(propertyName.toLatin1()); + writePropertyHelper(engine, engine.newQObject(&testObject), propertyName, + qScriptValueFromValue(&engine, value)); +} + +void tst_QScriptQObject::callQScriptableSlot_data() +{ + callSlot_data(); +} + +// Calls a slot from JS for an object that subclasses QScriptable. The +// purpose of this benchmark is to measure the overhead compared to +// calling a slot of a non-QScriptable object (see callSlot()). +void tst_QScriptQObject::callQScriptableSlot() +{ + QFETCH(QString, propertyName); + QFETCH(QString, arguments); + + QScriptEngine engine; + QtScriptableSlotTestObject testObject; + callMethodHelper(engine, &testObject, propertyName, arguments); +} + +QTEST_MAIN(tst_QScriptQObject) +#include "tst_qscriptqobject.moc" -- 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 ffec9a89c3407b1d176e4e0689c3ee3ce5ad5763 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 4 Aug 2010 14:13:17 +0200 Subject: Cocoa: add better support for delayed message invocation This patch will make it easier to call methods that takes integer arguments. It will be used to bugfix native dialogs. --- src/gui/kernel/qcocoaapplication_mac.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm index 238b96b..9270213 100644 --- a/src/gui/kernel/qcocoaapplication_mac.mm +++ b/src/gui/kernel/qcocoaapplication_mac.mm @@ -117,15 +117,19 @@ QT_USE_NAMESPACE quint64 lower = [event data1]; quint64 upper = [event data2]; QCocoaPostMessageArgs *args = reinterpret_cast(lower | (upper << 32)); + // Special case for convenience: if the argument is an NSNumber, we unbox it directly. + // Use NSValue instead if this behaviour is unwanted. + id a1 = ([args->arg1 isKindOfClass:[NSNumber class]]) ? (id)[args->arg1 intValue] : args->arg1; + id a2 = ([args->arg2 isKindOfClass:[NSNumber class]]) ? (id)[args->arg2 intValue] : args->arg2; switch (args->argCount) { case 0: [args->target performSelector:args->selector]; break; case 1: - [args->target performSelector:args->selector withObject:args->arg1]; + [args->target performSelector:args->selector withObject:a1]; break; case 3: - [args->target performSelector:args->selector withObject:args->arg1 withObject:args->arg2]; + [args->target performSelector:args->selector withObject:a1 withObject:a2]; break; } -- cgit v0.12 From 5e06fcfa6139988cce2e88d604ba8e05d5e43dd0 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 4 Aug 2010 13:09:30 +0200 Subject: Implement QFontMetrics::inFont(uint) which takes UCS-4 encoded char Support unicode characters which are not representable in 16 bits in QFontMetrics::inFont() to enable font selection algorithms for unicode ranges that require surrogates. Task-number: QTBUG-12638 Reviewed-by: Simon Hausmann --- src/gui/text/qfontmetrics.cpp | 32 ++++++++++++++++++++++++++- src/gui/text/qfontmetrics.h | 2 ++ tests/auto/qfontmetrics/qfontmetrics.pro | 2 +- tests/auto/qfontmetrics/testfont.qrc | 5 +++++ tests/auto/qfontmetrics/tst_qfontmetrics.cpp | 22 ++++++++++++++++++ tests/auto/qfontmetrics/ucs4font.ttf | Bin 0 -> 3076 bytes 6 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tests/auto/qfontmetrics/testfont.qrc create mode 100644 tests/auto/qfontmetrics/ucs4font.ttf diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index d02e841..f2591ce 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -443,6 +443,21 @@ bool QFontMetrics::inFont(QChar ch) const } /*! + Returns true if the character encoded in UCS-4/UTF-32 is a valid + character in the font; otherwise returns false. +*/ +bool QFontMetrics::inFontUcs4(uint ucs4) const +{ + const int script = QUnicodeTables::script(ucs4); + QFontEngine *engine = d->engineForScript(script); + Q_ASSERT(engine != 0); + if (engine->type() == QFontEngine::Box) + return false; + QString utf16 = QString::fromUcs4(&ucs4, 1); + return engine->canRender(utf16.data(), utf16.length()); +} + +/*! Returns the left bearing of character \a ch in the font. The left bearing is the right-ward distance of the left-most pixel @@ -1315,6 +1330,21 @@ bool QFontMetricsF::inFont(QChar ch) const } /*! + Returns true if the character encoded in UCS-4/UTF-32 is a valid + character in the font; otherwise returns false. +*/ +bool QFontMetricsF::inFontUcs4(uint ucs4) const +{ + const int script = QUnicodeTables::script(ucs4); + QFontEngine *engine = d->engineForScript(script); + Q_ASSERT(engine != 0); + if (engine->type() == QFontEngine::Box) + return false; + QString utf16 = QString::fromUcs4(&ucs4, 1); + return engine->canRender(utf16.data(), utf16.length()); +} + +/*! Returns the left bearing of character \a ch in the font. The left bearing is the right-ward distance of the left-most pixel @@ -1779,7 +1809,7 @@ qreal QFontMetricsF::lineWidth() const Use the boundingRect() function in combination with QString::left() instead. - + \oldcode QRect rect = boundingRect(text, len); \newcode diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h index 2518b54..9911ad2 100644 --- a/src/gui/text/qfontmetrics.h +++ b/src/gui/text/qfontmetrics.h @@ -85,6 +85,7 @@ public: int averageCharWidth() const; bool inFont(QChar) const; + bool inFontUcs4(uint ucs4) const; int leftBearing(QChar) const; int rightBearing(QChar) const; @@ -162,6 +163,7 @@ public: qreal averageCharWidth() const; bool inFont(QChar) const; + bool inFontUcs4(uint ucs4) const; qreal leftBearing(QChar) const; qreal rightBearing(QChar) const; diff --git a/tests/auto/qfontmetrics/qfontmetrics.pro b/tests/auto/qfontmetrics/qfontmetrics.pro index 51a7057..c0dc1ab 100644 --- a/tests/auto/qfontmetrics/qfontmetrics.pro +++ b/tests/auto/qfontmetrics/qfontmetrics.pro @@ -1,4 +1,4 @@ load(qttest_p4) SOURCES += tst_qfontmetrics.cpp - +RESOURCES += testfont.qrc diff --git a/tests/auto/qfontmetrics/testfont.qrc b/tests/auto/qfontmetrics/testfont.qrc new file mode 100644 index 0000000..bc0c0b0 --- /dev/null +++ b/tests/auto/qfontmetrics/testfont.qrc @@ -0,0 +1,5 @@ + + + ucs4font.ttf + + diff --git a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp index a22d624..4250415 100644 --- a/tests/auto/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/qfontmetrics/tst_qfontmetrics.cpp @@ -74,6 +74,7 @@ private slots: void bypassShaping(); void elidedMultiLength(); void elidedMultiLengthF(); + void inFontUcs4(); }; tst_QFontMetrics::tst_QFontMetrics() @@ -266,5 +267,26 @@ void tst_QFontMetrics::elidedMultiLengthF() elidedMultiLength_helper(); } +void tst_QFontMetrics::inFontUcs4() +{ + int id = QFontDatabase::addApplicationFont(":/fonts/ucs4font.ttf"); + QVERIFY(id >= 0); + + QFont font("QtTestUcs4"); + { + QFontMetrics fm(font); + + QVERIFY(fm.inFontUcs4(0x1D7FF)); + } + + { + QFontMetricsF fm(font); + + QVERIFY(fm.inFontUcs4(0x1D7FF)); + } + + QFontDatabase::removeApplicationFont(id); +} + QTEST_MAIN(tst_QFontMetrics) #include "tst_qfontmetrics.moc" diff --git a/tests/auto/qfontmetrics/ucs4font.ttf b/tests/auto/qfontmetrics/ucs4font.ttf new file mode 100644 index 0000000..31b6997 Binary files /dev/null and b/tests/auto/qfontmetrics/ucs4font.ttf differ -- cgit v0.12 From 99160bb9f851bf02fe5345b5f52217b6c77a57c4 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Aug 2010 10:52:19 +0200 Subject: Deprecated qFindChild and qFindChildren Rev-by: dev mailing list --- src/corelib/kernel/qobject.cpp | 6 ++-- src/corelib/kernel/qobject.h | 65 +++++++++++++++++++++--------------------- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index dc3a9c3..0b96bda 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -1746,7 +1746,7 @@ QObjectList QObject::queryList(const char *inheritsClass, \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11 - \sa findChildren(), qFindChild() + \sa findChildren() */ /*! @@ -1766,7 +1766,7 @@ QObjectList QObject::queryList(const char *inheritsClass, \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 13 - \sa findChild(), qFindChildren() + \sa findChild() */ /*! @@ -1782,6 +1782,7 @@ QObjectList QObject::queryList(const char *inheritsClass, /*! \fn T qFindChild(const QObject *obj, const QString &name) \relates QObject + \obsolete This function is equivalent to \a{obj}->\l{QObject::findChild()}{findChild}(\a name). @@ -1796,6 +1797,7 @@ QObjectList QObject::queryList(const char *inheritsClass, /*! \fn QList qFindChildren(const QObject *obj, const QString &name) \relates QObject + \obsolete This function is equivalent to \a{obj}->\l{QObject::findChildren()}{findChildren}(\a name). diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index c8aa2b5..21bad16 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -77,11 +77,9 @@ class QObjectUserData; typedef QList QObjectList; -template inline T qFindChild(const QObject *, const QString & = QString()); -template inline QList qFindChildren(const QObject *, const QString & = QString()); -#ifndef QT_NO_REGEXP -template inline QList qFindChildren(const QObject *, const QRegExp &); -#endif +Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, + const QMetaObject &mo, QList *list); +Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); class #if defined(__INTEL_COMPILER) && defined(Q_OS_WIN) @@ -158,16 +156,34 @@ public: template inline T findChild(const QString &aName = QString()) const - { return qFindChild(this, aName); } + { return static_cast(qt_qFindChild_helper(this, aName, reinterpret_cast(0)->staticMetaObject)); } template inline QList findChildren(const QString &aName = QString()) const - { return qFindChildren(this, aName); } + { + QList list; + union { + QList *typedList; + QList *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(this, aName, 0, reinterpret_cast(0)->staticMetaObject, u.voidList); + return list; + } #ifndef QT_NO_REGEXP template inline QList findChildren(const QRegExp &re) const - { return qFindChildren(this, re); } + { + QList list; + union { + QList *typedList; + QList *voidList; + } u; + u.typedList = &list; + qt_qFindChildren_helper(this, QString(), &re, reinterpret_cast(0)->staticMetaObject, u.voidList); + return list; + } #endif #ifdef QT3_SUPPORT @@ -328,42 +344,27 @@ public: }; #endif -Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, - const QMetaObject &mo, QList *list); -Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo); - +#ifdef QT_DEPRECATED template -inline T qFindChild(const QObject *o, const QString &name) -{ return static_cast(qt_qFindChild_helper(o, name, reinterpret_cast(0)->staticMetaObject)); } +inline QT_DEPRECATED T qFindChild(const QObject *o, const QString &name = QString()) +{ return o->findChild(name); } template -inline QList qFindChildren(const QObject *o, const QString &name) +inline QList qFindChildren(const QObject *o, const QString &name = QString()) { - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, name, 0, reinterpret_cast(0)->staticMetaObject, u.voidList); - return list; + return o->findChildren(name); } #ifndef QT_NO_REGEXP template -inline QList qFindChildren(const QObject *o, const QRegExp &re) +inline QT_DEPRECATED QList qFindChildren(const QObject *o, const QRegExp &re) { - QList list; - union { - QList *typedList; - QList *voidList; - } u; - u.typedList = &list; - qt_qFindChildren_helper(o, QString(), &re, reinterpret_cast(0)->staticMetaObject, u.voidList); - return list; + return o->findChildren(re); } #endif +#endif //QT_DEPRECATED + template inline T qobject_cast(QObject *object) { -- cgit v0.12 From 13833beb641289c45faed337848d37280195aadc Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Aug 2010 18:29:09 +0200 Subject: Remove the use of deprecated qFindChild(ren) Test directory untouched. This just apply those regexp: git grep -O"sed -i 's/qF\(indChildr*e*n*<[^>]*>\)(this,* */f\\1(/'" qFindChild git grep -O"sed -i 's/qF\(indChildr*e*n*<[^>]*>\)(&\([^\(),]*\),* */\\2.f\\1(/'" qFindChild git grep -O"sed -i 's/qF\(indChildr*e*n*<[^>]*>\)(\([^\(),]*()\),* */\\2->f\\1(/'" qFindChild git grep -O"sed -i 's/qF\(indChildr*e*n*<[^>]*>\)(\([^\(),]*\):\([^\(),]*\),* */(\\2:\\3)->f\\1(/'" qFindChild git grep -O"sed -i 's/qF\(indChildr*e*n*<[^>]*>\)(\([^\(),]*\),* */\\2->f\\1(/'" qFindChild Rev-by: dev mailing list --- demos/affine/main.cpp | 2 +- demos/composition/main.cpp | 2 +- demos/deform/main.cpp | 2 +- demos/deform/pathdeform.cpp | 2 +- demos/gradients/main.cpp | 2 +- demos/mainwindow/colorswatch.cpp | 6 +- demos/mainwindow/toolbar.cpp | 2 +- demos/pathstroke/main.cpp | 2 +- demos/pathstroke/pathstroke.cpp | 2 +- demos/shared/arthurstyle.cpp | 2 +- demos/shared/arthurwidgets.cpp | 2 +- doc/src/snippets/code/doc_src_porting4.qdoc | 2 +- examples/activeqt/hierarchy/objects.cpp | 2 +- examples/animation/easing/window.cpp | 2 +- .../designer/calculatorbuilder/calculatorform.cpp | 6 +- examples/script/calculator/main.cpp | 2 +- examples/script/qstetrix/main.cpp | 2 +- examples/uitools/textfinder/textfinder.cpp | 6 +- examples/xmlpatterns/recipes/querymainwindow.cpp | 12 +-- .../graphics/qt/MediaPlayerPrivatePhonon.cpp | 2 +- src/activeqt/container/qaxwidget.cpp | 4 +- src/activeqt/control/qaxserver.cpp | 2 +- src/activeqt/control/qaxserverbase.cpp | 8 +- src/corelib/kernel/qobject.cpp | 2 +- src/corelib/statemachine/qstatemachine.cpp | 10 +-- src/gui/accessible/qaccessibleobject.cpp | 2 +- src/gui/dialogs/qdialog.cpp | 6 +- src/gui/dialogs/qmessagebox.cpp | 6 +- src/gui/kernel/qwidget.cpp | 2 +- src/gui/styles/qmacstyle_mac.mm | 2 +- src/gui/styles/qplastiquestyle.cpp | 2 +- src/gui/styles/qs60style.cpp | 2 +- src/gui/styles/qstylesheetstyle.cpp | 6 +- src/gui/styles/qwindowsstyle.cpp | 6 +- src/gui/styles/qwindowsvistastyle.cpp | 12 +-- src/gui/widgets/qabstractbutton.cpp | 2 +- src/gui/widgets/qdialogbuttonbox.cpp | 2 +- src/gui/widgets/qmainwindow.cpp | 4 +- src/gui/widgets/qmdisubwindow.cpp | 4 +- src/gui/widgets/qworkspace.cpp | 2 +- src/script/bridge/qscriptqobject.cpp | 6 +- .../tools/assistant/preferencesdialog.cpp | 4 +- tools/assistant/tools/assistant/searchwidget.cpp | 12 +-- .../src/components/buddyeditor/buddyeditor.cpp | 12 +-- .../src/components/formeditor/formwindow.cpp | 16 ++-- .../components/formeditor/qdesigner_resource.cpp | 6 +- .../formeditor/qmainwindow_container.cpp | 2 +- .../signalsloteditor/signalslot_utils.cpp | 2 +- .../signalsloteditor/signalsloteditor.cpp | 2 +- .../signalsloteditor/signalsloteditorwindow.cpp | 8 +- .../src/components/widgetbox/widgetbox_dnditem.cpp | 2 +- tools/designer/src/lib/shared/actioneditor.cpp | 4 +- tools/designer/src/lib/shared/connectionedit.cpp | 6 +- tools/designer/src/lib/shared/layoutinfo.cpp | 4 +- tools/designer/src/lib/shared/morphmenu.cpp | 2 +- .../designer/src/lib/shared/qdesigner_command.cpp | 4 +- .../src/lib/shared/qdesigner_formwindowcommand.cpp | 2 +- tools/designer/src/lib/shared/qdesigner_menu.cpp | 6 +- .../src/lib/shared/qdesigner_tabwidget.cpp | 2 +- tools/designer/src/lib/shared/widgetfactory.cpp | 2 +- tools/designer/src/lib/shared/zoomwidget.cpp | 2 +- .../designer/src/lib/uilib/abstractformbuilder.cpp | 10 +-- tools/designer/src/lib/uilib/formbuilder.cpp | 4 +- tools/designer/src/lib/uilib/formbuilderextra.cpp | 2 +- .../shared/qtpropertybrowser/qtvariantproperty.cpp | 88 +++++++++++----------- 65 files changed, 179 insertions(+), 179 deletions(-) diff --git a/demos/affine/main.cpp b/demos/affine/main.cpp index 85da546..e14dc6b 100644 --- a/demos/affine/main.cpp +++ b/demos/affine/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char **argv) QStyle *arthurStyle = new ArthurStyle(); xformWidget.setStyle(arthurStyle); - QList widgets = qFindChildren(&xformWidget); + QList widgets = xformWidget.findChildren(); foreach (QWidget *w, widgets) { w->setStyle(arthurStyle); w->setAttribute(Qt::WA_AcceptTouchEvents); diff --git a/demos/composition/main.cpp b/demos/composition/main.cpp index aa8c139..a528dff 100644 --- a/demos/composition/main.cpp +++ b/demos/composition/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char **argv) QStyle *arthurStyle = new ArthurStyle(); compWidget.setStyle(arthurStyle); - QList widgets = qFindChildren(&compWidget); + QList widgets = compWidget.findChildren(); foreach (QWidget *w, widgets) w->setStyle(arthurStyle); compWidget.show(); diff --git a/demos/deform/main.cpp b/demos/deform/main.cpp index bef075a..c5491b3 100644 --- a/demos/deform/main.cpp +++ b/demos/deform/main.cpp @@ -56,7 +56,7 @@ int main(int argc, char **argv) QStyle *arthurStyle = new ArthurStyle(); deformWidget.setStyle(arthurStyle); - QList widgets = qFindChildren(&deformWidget); + QList widgets = deformWidget.findChildren(); foreach (QWidget *w, widgets) w->setStyle(arthurStyle); diff --git a/demos/deform/pathdeform.cpp b/demos/deform/pathdeform.cpp index 636d103..d6ac19e 100644 --- a/demos/deform/pathdeform.cpp +++ b/demos/deform/pathdeform.cpp @@ -297,7 +297,7 @@ void PathDeformWidget::setStyle( QStyle * style ) { m_controls->setStyle(style); - QList widgets = qFindChildren(m_controls); + QList widgets = m_controls->findChildren(); foreach (QWidget *w, widgets) w->setStyle(style); } diff --git a/demos/gradients/main.cpp b/demos/gradients/main.cpp index 8291e85..6678fa2 100644 --- a/demos/gradients/main.cpp +++ b/demos/gradients/main.cpp @@ -52,7 +52,7 @@ int main(int argc, char **argv) GradientWidget gradientWidget(0); QStyle *arthurStyle = new ArthurStyle(); gradientWidget.setStyle(arthurStyle); - QList widgets = qFindChildren(&gradientWidget); + QList widgets = gradientWidget.findChildren(); foreach (QWidget *w, widgets) { w->setStyle(arthurStyle); w->setAttribute(Qt::WA_AcceptTouchEvents); diff --git a/demos/mainwindow/colorswatch.cpp b/demos/mainwindow/colorswatch.cpp index aab4f03..d4dbdca 100644 --- a/demos/mainwindow/colorswatch.cpp +++ b/demos/mainwindow/colorswatch.cpp @@ -454,7 +454,7 @@ void ColorSwatch::updateContextMenu() tabMenu->clear(); splitHMenu->clear(); splitVMenu->clear(); - QList dock_list = qFindChildren(mainWindow); + QList dock_list = mainWindow->findChildren(); foreach (ColorSwatch *dock, dock_list) { // if (!dock->isVisible() || dock->isFloating()) // continue; @@ -467,7 +467,7 @@ void ColorSwatch::updateContextMenu() void ColorSwatch::splitInto(QAction *action) { QMainWindow *mainWindow = qobject_cast(parentWidget()); - QList dock_list = qFindChildren(mainWindow); + QList dock_list = mainWindow->findChildren(); ColorSwatch *target = 0; foreach (ColorSwatch *dock, dock_list) { if (action->text() == dock->objectName()) { @@ -486,7 +486,7 @@ void ColorSwatch::splitInto(QAction *action) void ColorSwatch::tabInto(QAction *action) { QMainWindow *mainWindow = qobject_cast(parentWidget()); - QList dock_list = qFindChildren(mainWindow); + QList dock_list = mainWindow->findChildren(); ColorSwatch *target = 0; foreach (ColorSwatch *dock, dock_list) { if (action->text() == dock->objectName()) { diff --git a/demos/mainwindow/toolbar.cpp b/demos/mainwindow/toolbar.cpp index dd12419..a988d85 100644 --- a/demos/mainwindow/toolbar.cpp +++ b/demos/mainwindow/toolbar.cpp @@ -232,7 +232,7 @@ void ToolBar::updateMenu() void ToolBar::order() { QList ordered, actions1 = actions(), - actions2 = qFindChildren(this); + actions2 = findChildren(); while (!actions2.isEmpty()) { QAction *action = actions2.takeFirst(); if (!actions1.contains(action)) diff --git a/demos/pathstroke/main.cpp b/demos/pathstroke/main.cpp index 534b233..b10b2ea 100644 --- a/demos/pathstroke/main.cpp +++ b/demos/pathstroke/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char **argv) PathStrokeWidget pathStrokeWidget(smallScreen); QStyle *arthurStyle = new ArthurStyle(); pathStrokeWidget.setStyle(arthurStyle); - QList widgets = qFindChildren(&pathStrokeWidget); + QList widgets = pathStrokeWidget.findChildren(); foreach (QWidget *w, widgets) { w->setStyle(arthurStyle); w->setAttribute(Qt::WA_AcceptTouchEvents); diff --git a/demos/pathstroke/pathstroke.cpp b/demos/pathstroke/pathstroke.cpp index 257d02a..308c540 100644 --- a/demos/pathstroke/pathstroke.cpp +++ b/demos/pathstroke/pathstroke.cpp @@ -382,7 +382,7 @@ void PathStrokeWidget::setStyle( QStyle * style ) { m_controls->setStyle(style); - QList widgets = qFindChildren(m_controls); + QList widgets = m_controls->findChildren(); foreach (QWidget *w, widgets) w->setStyle(style); } diff --git a/demos/shared/arthurstyle.cpp b/demos/shared/arthurstyle.cpp index 4be9079..3a2a2cb 100644 --- a/demos/shared/arthurstyle.cpp +++ b/demos/shared/arthurstyle.cpp @@ -394,7 +394,7 @@ int ArthurStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWid void ArthurStyle::polish(QWidget *widget) { if (widget->layout() && qobject_cast(widget)) { - if (qFindChildren(widget).size() == 0) { + if (widget->findChildren().size() == 0) { widget->layout()->setSpacing(0); widget->layout()->setMargin(12); } else { diff --git a/demos/shared/arthurwidgets.cpp b/demos/shared/arthurwidgets.cpp index 4182ff1..2eaf96b 100644 --- a/demos/shared/arthurwidgets.cpp +++ b/demos/shared/arthurwidgets.cpp @@ -313,7 +313,7 @@ void ArthurFrame::loadSourceFile(const QString &sourceFile) void ArthurFrame::showSource() { // Check for existing source - if (qFindChild(this)) + if (findChild()) return; QString contents; diff --git a/doc/src/snippets/code/doc_src_porting4.qdoc b/doc/src/snippets/code/doc_src_porting4.qdoc index 7a39f2e..9ed557c 100644 --- a/doc/src/snippets/code/doc_src_porting4.qdoc +++ b/doc/src/snippets/code/doc_src_porting4.qdoc @@ -165,7 +165,7 @@ while (i.hasNext()) { //! [18] -QList myWidgets = qFindChildren(myParent); +QList myWidgets = myParent->findChildren(); //! [18] diff --git a/examples/activeqt/hierarchy/objects.cpp b/examples/activeqt/hierarchy/objects.cpp index 918f219..bb0b701 100644 --- a/examples/activeqt/hierarchy/objects.cpp +++ b/examples/activeqt/hierarchy/objects.cpp @@ -62,7 +62,7 @@ void QParentWidget::createSubWidget(const QString &name) //! [1] //! [2] QSubWidget *QParentWidget::subWidget(const QString &name) { - return qFindChild(this, name); + return findChild(name); } //! [2] diff --git a/examples/animation/easing/window.cpp b/examples/animation/easing/window.cpp index a555024..8d9775d 100644 --- a/examples/animation/easing/window.cpp +++ b/examples/animation/easing/window.cpp @@ -44,7 +44,7 @@ Window::Window(QWidget *parent) : QWidget(parent), m_iconSize(64, 64) { m_ui.setupUi(this); - QButtonGroup *buttonGroup = qFindChild(this); // ### workaround for uic in 4.4 + QButtonGroup *buttonGroup = findChild(); // ### workaround for uic in 4.4 m_ui.easingCurvePicker->setIconSize(m_iconSize); m_ui.easingCurvePicker->setMinimumHeight(m_iconSize.height() + 50); buttonGroup->setId(m_ui.lineRadio, 0); diff --git a/examples/designer/calculatorbuilder/calculatorform.cpp b/examples/designer/calculatorbuilder/calculatorform.cpp index 34c869e..fa6ccb3 100644 --- a/examples/designer/calculatorbuilder/calculatorform.cpp +++ b/examples/designer/calculatorbuilder/calculatorform.cpp @@ -58,9 +58,9 @@ CalculatorForm::CalculatorForm(QWidget *parent) //! [1] //! [2] - ui_inputSpinBox1 = qFindChild(this, "inputSpinBox1"); - ui_inputSpinBox2 = qFindChild(this, "inputSpinBox2"); - ui_outputWidget = qFindChild(this, "outputWidget"); + ui_inputSpinBox1 = findChild("inputSpinBox1"); + ui_inputSpinBox2 = findChild("inputSpinBox2"); + ui_outputWidget = findChild("outputWidget"); //! [2] //! [3] diff --git a/examples/script/calculator/main.cpp b/examples/script/calculator/main.cpp index 8030a87..c258a9b 100644 --- a/examples/script/calculator/main.cpp +++ b/examples/script/calculator/main.cpp @@ -89,7 +89,7 @@ int main(int argc, char **argv) //! [2] #if !defined(QT_NO_SCRIPTTOOLS) - QLineEdit *display = qFindChild(ui, "display"); + QLineEdit *display = ui->findChild("display"); QObject::connect(display, SIGNAL(returnPressed()), debugWindow, SLOT(show())); #endif diff --git a/examples/script/qstetrix/main.cpp b/examples/script/qstetrix/main.cpp index e12e26d..c802584 100644 --- a/examples/script/qstetrix/main.cpp +++ b/examples/script/qstetrix/main.cpp @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) QScriptValue tetrix = ctor.construct(QScriptValueList() << scriptUi); //! [3] - QPushButton *debugButton = qFindChild(ui, "debugButton"); + QPushButton *debugButton = ui->findChild("debugButton"); #if !defined(QT_NO_SCRIPTTOOLS) QObject::connect(debugButton, SIGNAL(clicked()), debugger.action(QScriptEngineDebugger::InterruptAction), diff --git a/examples/uitools/textfinder/textfinder.cpp b/examples/uitools/textfinder/textfinder.cpp index 4bb6600..1682acd 100644 --- a/examples/uitools/textfinder/textfinder.cpp +++ b/examples/uitools/textfinder/textfinder.cpp @@ -49,9 +49,9 @@ TextFinder::TextFinder(QWidget *parent) QWidget *formWidget = loadUiFile(); //! [1] - ui_findButton = qFindChild(this, "findButton"); - ui_textEdit = qFindChild(this, "textEdit"); - ui_lineEdit = qFindChild(this, "lineEdit"); + ui_findButton = findChild("findButton"); + ui_textEdit = findChild("textEdit"); + ui_lineEdit = findChild("lineEdit"); //! [0] //! [1] //! [2] diff --git a/examples/xmlpatterns/recipes/querymainwindow.cpp b/examples/xmlpatterns/recipes/querymainwindow.cpp index 0fd2483..8a4c606 100644 --- a/examples/xmlpatterns/recipes/querymainwindow.cpp +++ b/examples/xmlpatterns/recipes/querymainwindow.cpp @@ -49,10 +49,10 @@ QueryMainWindow::QueryMainWindow() : ui_defaultQueries(0) { setupUi(this); - new XmlSyntaxHighlighter(qFindChild(this, "inputTextEdit")->document()); - new XmlSyntaxHighlighter(qFindChild(this, "outputTextEdit")->document()); + new XmlSyntaxHighlighter(findChild("inputTextEdit")->document()); + new XmlSyntaxHighlighter(findChild("outputTextEdit")->document()); - ui_defaultQueries = qFindChild(this, "defaultQueries"); + ui_defaultQueries = findChild("defaultQueries"); QMetaObject::connectSlotsByName(this); connect(ui_defaultQueries, SIGNAL(currentIndexChanged(int)), SLOT(displayQuery(int))); @@ -71,7 +71,7 @@ void QueryMainWindow::displayQuery(int index) QFile queryFile(QString(":files/") + ui_defaultQueries->itemText(index)); queryFile.open(QIODevice::ReadOnly); const QString query(QString::fromLatin1(queryFile.readAll())); - qFindChild(this, "queryTextEdit")->setPlainText(query); + findChild("queryTextEdit")->setPlainText(query); evaluate(query); } @@ -90,7 +90,7 @@ void QueryMainWindow::loadInputFile() QTextStream in(&forView); QString inputDocument = in.readAll(); - qFindChild(this, "inputTextEdit")->setPlainText(inputDocument); + findChild("inputTextEdit")->setPlainText(inputDocument); } @@ -116,7 +116,7 @@ void QueryMainWindow::evaluate(const QString &str) return; buffer.close(); - qFindChild(this, "outputTextEdit")->setPlainText(QString::fromUtf8(outArray.constData())); + findChild("outputTextEdit")->setPlainText(QString::fromUtf8(outArray.constData())); } //! [2] diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp index 88c7a1c..9de5c08 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivatePhonon.cpp @@ -101,7 +101,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player) // Make sure we get updates for each frame m_videoWidget->installEventFilter(this); - foreach (QWidget* widget, qFindChildren(m_videoWidget)) + foreach (QWidget* widget, m_videoWidget->findChildren()) widget->installEventFilter(this); connect(m_mediaObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), diff --git a/src/activeqt/container/qaxwidget.cpp b/src/activeqt/container/qaxwidget.cpp index 7afce5b..d3f736b 100644 --- a/src/activeqt/container/qaxwidget.cpp +++ b/src/activeqt/container/qaxwidget.cpp @@ -1163,7 +1163,7 @@ HRESULT WINAPI QAxClientSite::InsertMenus(HMENU /*hmenuShared*/, LPOLEMENUGROUPW AX_DEBUG(QAxClientSite::InsertMenus); QMenuBar *mb = menuBar; if (!mb) - mb = qFindChild(widget->window()); + mb = widget->window()->findChild(); if (!mb) return E_NOTIMPL; menuBar = mb; @@ -1309,7 +1309,7 @@ HRESULT WINAPI QAxClientSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND m_menuOwner = hwndActiveObject; QMenuBar *mb = menuBar; if (!mb) - mb = qFindChild(widget->window()); + mb = widget->window()->findChild(); if (!mb) return E_NOTIMPL; menuBar = mb; diff --git a/src/activeqt/control/qaxserver.cpp b/src/activeqt/control/qaxserver.cpp index 7728e50..2512f05 100644 --- a/src/activeqt/control/qaxserver.cpp +++ b/src/activeqt/control/qaxserver.cpp @@ -285,7 +285,7 @@ HRESULT UpdateRegistry(BOOL bRegister) |OLEMISC_RECOMPOSEONRESIZE; if (!control) olemisc |= OLEMISC_INVISIBLEATRUNTIME; - else if (qFindChild(object) && !qax_disable_inplaceframe) + else if (object->findChild() && !qax_disable_inplaceframe) olemisc |= OLEMISC_WANTSTOMENUMERGE; settings.setValue(QLatin1Char('/') + module + QLatin1Char('.') + className + QLatin1Char('.') + classMajorVersion + QLatin1String("/."), className + QLatin1String(" Class")); diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index ca16b39..4d2d2f9 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -1313,7 +1313,7 @@ bool QAxServerBase::internalCreate() // install an event filter for stock events if (isWidget) { qt.object->installEventFilter(this); - const QList children = qFindChildren(qt.object); + const QList children = qt.object->findChildren(); QList::ConstIterator it = children.constBegin(); while (it != children.constEnd()) { (*it)->installEventFilter(this); @@ -3805,7 +3805,7 @@ HRESULT QAxServerBase::internalActivate() // Gone active by now, take care of UIACTIVATE canTakeFocus = qt.widget->focusPolicy() != Qt::NoFocus && !inDesignMode; if (!canTakeFocus && !inDesignMode) { - QList widgets = qFindChildren(qt.widget); + QList widgets = qt.widget->findChildren(); for (int w = 0; w < widgets.count(); ++w) { QWidget *widget = widgets[w]; canTakeFocus = widget->focusPolicy() != Qt::NoFocus; @@ -3831,13 +3831,13 @@ HRESULT QAxServerBase::internalActivate() if (m_spInPlaceFrame) { hr = m_spInPlaceFrame->SetActiveObject(this, QStringToBSTR(class_name)); if (!FAILED(hr)) { - menuBar = (qt.widget && !qax_disable_inplaceframe) ? qFindChild(qt.widget) : 0; + menuBar = (qt.widget && !qax_disable_inplaceframe) ? qt.widget->findChild() : 0; if (menuBar && !menuBar->isVisible()) { createMenu(menuBar); menuBar->hide(); menuBar->installEventFilter(this); } - statusBar = qt.widget ? qFindChild(qt.widget) : 0; + statusBar = qt.widget ? qt.widget->findChild() : 0; if (statusBar && !statusBar->isVisible()) { const int index = statusBar->metaObject()->indexOfSignal("messageChanged(QString)"); QMetaObject::connect(statusBar, index, this, -1); diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 0b96bda..143dbff 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3314,7 +3314,7 @@ void QMetaObject::connectSlotsByName(QObject *o) return; const QMetaObject *mo = o->metaObject(); Q_ASSERT(mo); - const QObjectList list = qFindChildren(o, QString()); + const QObjectList list = o->findChildren(QString()); for (int i = 0; i < mo->methodCount(); ++i) { const char *slot = mo->method(i).signature(); Q_ASSERT(slot); diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp index 9d5c49f..a3c702a 100644 --- a/src/corelib/statemachine/qstatemachine.cpp +++ b/src/corelib/statemachine/qstatemachine.cpp @@ -793,7 +793,7 @@ void QStateMachinePrivate::applyProperties(const QList &tr } // We require that at least one animation is valid. // ### generalize - QList variantAnims = qFindChildren(anim); + QList variantAnims = anim->findChildren(); if (QVariantAnimation *va = qobject_cast(anim)) variantAnims.append(va); @@ -1178,7 +1178,7 @@ void QStateMachinePrivate::removeStartState() void QStateMachinePrivate::clearHistory() { Q_Q(QStateMachine); - QList historyStates = qFindChildren(q); + QList historyStates = q->findChildren(); for (int i = 0; i < historyStates.size(); ++i) { QHistoryState *h = historyStates.at(i); QHistoryStatePrivate::get(h)->configuration.clear(); @@ -1440,7 +1440,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState) Q_ASSERT(sourceState != 0); // Reuse previous GoToStateTransition in case of several calls to // goToState() in a row. - GoToStateTransition *trans = qFindChild(sourceState); + GoToStateTransition *trans = sourceState->findChild(); if (!trans) { trans = new GoToStateTransition(targetState); sourceState->addTransition(trans); @@ -1562,7 +1562,7 @@ void QStateMachinePrivate::unregisterAllTransitions() { Q_Q(QStateMachine); { - QList transitions = qFindChildren(rootState()); + QList transitions = rootState()->findChildren(); for (int i = 0; i < transitions.size(); ++i) { QSignalTransition *t = transitions.at(i); if (t->machine() == q) @@ -1570,7 +1570,7 @@ void QStateMachinePrivate::unregisterAllTransitions() } } { - QList transitions = qFindChildren(rootState()); + QList transitions = rootState()->findChildren(); for (int i = 0; i < transitions.size(); ++i) { QEventTransition *t = transitions.at(i); if (t->machine() == q) diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/gui/accessible/qaccessibleobject.cpp index 7b2e7ce..3a4809e 100644 --- a/src/gui/accessible/qaccessibleobject.cpp +++ b/src/gui/accessible/qaccessibleobject.cpp @@ -276,7 +276,7 @@ QAccessible::Relation QAccessibleApplication::relationTo(int child, const for (int i = 0; i < tlw.count(); ++i) { QWidget *w = tlw.at(i); - QObjectList cl = qFindChildren(w, QString()); + QObjectList cl = w->findChildren(QString()); if (cl.contains(o)) return Ancestor; } diff --git a/src/gui/dialogs/qdialog.cpp b/src/gui/dialogs/qdialog.cpp index 9e0437c..5a791fc 100644 --- a/src/gui/dialogs/qdialog.cpp +++ b/src/gui/dialogs/qdialog.cpp @@ -337,7 +337,7 @@ void QDialogPrivate::setDefault(QPushButton *pushButton) { Q_Q(QDialog); bool hasMain = false; - QList list = qFindChildren(q); + QList list = q->findChildren(); for (int i=0; iwindow() == q) { @@ -372,7 +372,7 @@ void QDialogPrivate::setMainDefault(QPushButton *pushButton) void QDialogPrivate::hideDefault() { Q_Q(QDialog); - QList list = qFindChildren(q); + QList list = q->findChildren(); for (int i=0; isetDefault(false); } @@ -675,7 +675,7 @@ void QDialog::keyPressEvent(QKeyEvent *e) switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: { - QList list = qFindChildren(this); + QList list = findChildren(); for (int i=0; iisDefault() && pb->isVisible()) { diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp index fe25b0f..f849996 100644 --- a/src/gui/dialogs/qmessagebox.cpp +++ b/src/gui/dialogs/qmessagebox.cpp @@ -412,7 +412,7 @@ void QMessageBoxPrivate::updateSize() void QMessageBoxPrivate::hideSpecial() { Q_Q(QMessageBox); - QList list = qFindChildren(q); + QList list = q->findChildren(); for (int i=0; itext(); @@ -1266,7 +1266,7 @@ bool QMessageBox::event(QEvent *e) (e->type() == QEvent::OkRequest) ? QApplication::translate("QMessageBox", "OK") : QApplication::translate("QMessageBox", "Help"); - QList list = qFindChildren(this); + QList list = findChildren(); for (int i=0; itext() == bName) { @@ -1513,7 +1513,7 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, int(defaultButton), 0); QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent); - QDialogButtonBox *buttonBox = qFindChild(&msgBox); + QDialogButtonBox *buttonBox = msgBox.findChild(); Q_ASSERT(buttonBox != 0); uint mask = QMessageBox::FirstButton; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 8c6e05e..22123a0 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6527,7 +6527,7 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second) // that can take keyboard focus so that second is inserted after // that last child, and the focus order within first is (more // likely to be) preserved. - QList l = qFindChildren(first); + QList l = first->findChildren(); for (int i = l.size()-1; i >= 0; --i) { QWidget * next = l.at(i); if (next->window() == fp->window()) { diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 2005e4a..bdcf5d6 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -1629,7 +1629,7 @@ bool QMacStylePrivate::eventFilter(QObject *o, QEvent *e) case QEvent::FocusOut: case QEvent::Show: case QEvent::WindowActivate: { - QList list = qFindChildren(btn->window()); + QList list = btn->window()->findChildren(); for (int i = 0; i < list.size(); ++i) { QPushButton *pBtn = list.at(i); if ((e->type() == QEvent::FocusOut diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 20d9bd9..4690a71 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -1054,7 +1054,7 @@ void QPlastiqueStylePrivate::drawPartialFrame(QPainter *painter, const QStyleOpt bool reverse = option->direction == Qt::RightToLeft; QStyleOptionFrame frameOpt; #ifndef QT_NO_LINEEDIT - if (QLineEdit *lineedit = qFindChild(widget)) + if (QLineEdit *lineedit = widget->findChild()) frameOpt.initFrom(lineedit); #else Q_UNUSED(widget) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index e28403b..b11fb2b 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1412,7 +1412,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, bool isScrollBarVisible = false; int scrollBarWidth = 0; - QList scrollBars = qFindChildren(widget); + QList scrollBars = widget->findChildren(); for (int i = 0; i < scrollBars.size(); ++i) { QScrollBar *scrollBar = scrollBars.at(i); if (scrollBar && scrollBar->orientation() == Qt::Vertical) { diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 43fa4b9..5d984cf 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -2342,7 +2342,7 @@ static QWidget *embeddedWidget(QWidget *w) #ifndef QT_NO_SPINBOX if (QAbstractSpinBox *sb = qobject_cast(w)) - return qFindChild(sb); + return sb->findChild(); #endif #ifndef QT_NO_SCROLLAREA @@ -2795,7 +2795,7 @@ void QStyleSheetStyle::polish(QPalette &pal) void QStyleSheetStyle::repolish(QWidget *w) { - QList children = qFindChildren(w, QString()); + QList children = w->findChildren(QString()); children.append(w); styleSheetCache->remove(w); updateWidgets(children); @@ -5179,7 +5179,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi case SH_ComboBox_PopupFrameStyle: #ifndef QT_NO_COMBOBOX if (qobject_cast(w)) { - QAbstractItemView *view = qFindChild(w); + QAbstractItemView *view = w->findChild(); if (view) { view->ensurePolished(); QRenderRule subRule = renderRule(view, PseudoElement_None); diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 579dd0b..8f1accb 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -175,7 +175,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) widget = widget->window(); // Alt has been pressed - find all widgets that care - QList l = qFindChildren(widget); + QList l = widget->findChildren(); for (int pos=0 ; pos < l.size() ; ++pos) { QWidget *w = l.at(pos); if (w->isWindow() || !w->isVisible() || @@ -198,7 +198,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e) // Update state and repaint the menu bars. d->alt_down = false; #ifndef QT_NO_MENUBAR - QList l = qFindChildren(widget); + QList l = widget->findChildren(); for (int i = 0; i < l.size(); ++i) l.at(i)->update(); #endif @@ -1160,7 +1160,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid if (!menuBar && qobject_cast(widget)) { QWidget *w = QApplication::activeWindow(); if (w && w != widget) - menuBar = qFindChild(w); + menuBar = w->findChild(); } // If we paint a menu bar draw underlines if is in the keyboardState if (menuBar) { diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 8511592..8cb57d5 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -841,10 +841,10 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt const QDialogButtonBox *buttonBox = 0; if (qobject_cast (widget)) - buttonBox = qFindChild(widget,QLatin1String("qt_msgbox_buttonbox")); + buttonBox = widget->findChild(QLatin1String("qt_msgbox_buttonbox")); #ifndef QT_NO_INPUTDIALOG else if (qobject_cast (widget)) - buttonBox = qFindChild(widget,QLatin1String("qt_inputdlg_buttonbox")); + buttonBox = widget->findChild(QLatin1String("qt_inputdlg_buttonbox")); #endif // QT_NO_INPUTDIALOG if (buttonBox) { @@ -2395,14 +2395,14 @@ void QWindowsVistaStyle::polish(QWidget *widget) } } else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground); - QDialogButtonBox *buttonBox = qFindChild(widget,QLatin1String("qt_msgbox_buttonbox")); + QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_msgbox_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 9, 0, 0); } #ifndef QT_NO_INPUTDIALOG else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground); - QDialogButtonBox *buttonBox = qFindChild(widget,QLatin1String("qt_inputdlg_buttonbox")); + QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_inputdlg_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 9, 0, 0); } @@ -2434,14 +2434,14 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) widget->setAttribute(Qt::WA_Hover, false); else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground, false); - QDialogButtonBox *buttonBox = qFindChild(widget,QLatin1String("qt_msgbox_buttonbox")); + QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_msgbox_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 0, 0, 0); } #ifndef QT_NO_INPUTDIALOG else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground, false); - QDialogButtonBox *buttonBox = qFindChild(widget,QLatin1String("qt_inputdlg_buttonbox")); + QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_inputdlg_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 0, 0, 0); } diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp index 995d659..bd66843 100644 --- a/src/gui/widgets/qabstractbutton.cpp +++ b/src/gui/widgets/qabstractbutton.cpp @@ -319,7 +319,7 @@ QListQAbstractButtonPrivate::queryButtonList() const return group->d_func()->buttonList; #endif - QListcandidates = qFindChildren(parent); + QListcandidates = parent->findChildren(); if (autoExclusive) { for (int i = candidates.count() - 1; i >= 0; --i) { QAbstractButton *candidate = candidates.at(i); diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp index 732dbc9..9aea32a 100644 --- a/src/gui/widgets/qdialogbuttonbox.cpp +++ b/src/gui/widgets/qdialogbuttonbox.cpp @@ -1229,7 +1229,7 @@ bool QDialogButtonBox::event(QEvent *event) break; } - foreach (QPushButton *pb, qFindChildren(dialog ? dialog : this)) { + foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren()) { if (pb->isDefault() && pb != firstAcceptButton) { hasDefault = true; break; diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 44483ea..0378d2d 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -1573,7 +1573,7 @@ QMenu *QMainWindow::createPopupMenu() Q_D(QMainWindow); QMenu *menu = 0; #ifndef QT_NO_DOCKWIDGET - QList dockwidgets = qFindChildren(this); + QList dockwidgets = findChildren(); if (dockwidgets.size()) { menu = new QMenu(this); for (int i = 0; i < dockwidgets.size(); ++i) { @@ -1587,7 +1587,7 @@ QMenu *QMainWindow::createPopupMenu() } #endif // QT_NO_DOCKWIDGET #ifndef QT_NO_TOOLBAR - QList toolbars = qFindChildren(this); + QList toolbars = findChildren(); if (toolbars.size()) { if (!menu) menu = new QMenu(this); diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/gui/widgets/qmdisubwindow.cpp index 62d297e..3f4cdc3 100644 --- a/src/gui/widgets/qmdisubwindow.cpp +++ b/src/gui/widgets/qmdisubwindow.cpp @@ -2203,7 +2203,7 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) void QMdiSubWindowPrivate::setSizeGripVisible(bool visible) const { // See if we can find any size grips - QList sizeGrips = qFindChildren(q_func()); + QList sizeGrips = q_func()->findChildren(); foreach (QSizeGrip *grip, sizeGrips) grip->setVisible(visible); } @@ -2319,7 +2319,7 @@ void QMdiSubWindow::setWidget(QWidget *widget) widget->setParent(this); #ifndef QT_NO_SIZEGRIP - QSizeGrip *sizeGrip = qFindChild(widget); + QSizeGrip *sizeGrip = widget->findChild(); if (sizeGrip) sizeGrip->installEventFilter(this); if (d->sizeGrip) diff --git a/src/gui/widgets/qworkspace.cpp b/src/gui/widgets/qworkspace.cpp index 7180c4d..5cf67a5 100644 --- a/src/gui/widgets/qworkspace.cpp +++ b/src/gui/widgets/qworkspace.cpp @@ -2923,7 +2923,7 @@ void QWorkspaceChild::setActive(bool b) iconw->setActive(act); update(); - QList wl = qFindChildren(childWidget); + QList wl = childWidget->findChildren(); if (act) { for (int i = 0; i < wl.size(); ++i) { QWidget *w = wl.at(i); diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 5e4f097..9e26fbf 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -1668,7 +1668,7 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChild(JSC::ExecState *exec QString name; if (args.size() != 0) name = args.at(0).toString(exec); - QObject *child = qFindChild(obj, name); + QObject *child = obj->findChild(name); QScriptEngine::QObjectWrapOptions opt = QScriptEngine::PreferExistingWrapperObject; return engine->newQObject(child, QScriptEngine::QtOwnership, opt); } @@ -1709,10 +1709,10 @@ static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChildren(JSC::ExecState *e } } else { const QString name(args.at(0).toString(exec)); - children = qFindChildren(obj, name); + children = obj->findChildren(name); } } else { - children = qFindChildren(obj, QString()); + children = obj->findChildren(QString()); } // create the result array with the children const int length = children.size(); diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp index 3535e5a..40a449e 100644 --- a/tools/assistant/tools/assistant/preferencesdialog.cpp +++ b/tools/assistant/tools/assistant/preferencesdialog.cpp @@ -421,13 +421,13 @@ void PreferencesDialog::updateFontSettingsPage() connect(m_browserFontPanel, SIGNAL(toggled(bool)), this, SLOT(browserFontSettingToggled(bool))); - QList allCombos = qFindChildren(m_appFontPanel); + QList allCombos = m_appFontPanel->findChildren(); foreach (QComboBox* box, allCombos) { connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(appFontSettingChanged(int))); } - allCombos = qFindChildren(m_browserFontPanel); + allCombos = m_browserFontPanel->findChildren(); foreach (QComboBox* box, allCombos) { connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(browserFontSettingChanged(int))); diff --git a/tools/assistant/tools/assistant/searchwidget.cpp b/tools/assistant/tools/assistant/searchwidget.cpp index d83790d..9eb2106 100644 --- a/tools/assistant/tools/assistant/searchwidget.cpp +++ b/tools/assistant/tools/assistant/searchwidget.cpp @@ -86,7 +86,7 @@ SearchWidget::SearchWidget(QHelpSearchEngine *engine, QWidget *parent) connect(searchEngine, SIGNAL(searchingFinished(int)), this, SLOT(searchingFinished(int))); - QTextBrowser* browser = qFindChild(resultWidget); + QTextBrowser* browser = resultWidget->findChild(); if (browser) // Will be null if lib was configured not to use CLucene. browser->viewport()->installEventFilter(this); } @@ -100,7 +100,7 @@ SearchWidget::~SearchWidget() void SearchWidget::zoomIn() { TRACE_OBJ - QTextBrowser* browser = qFindChild(resultWidget); + QTextBrowser* browser = resultWidget->findChild(); if (browser && zoomCount != 10) { zoomCount++; browser->zoomIn(); @@ -110,7 +110,7 @@ void SearchWidget::zoomIn() void SearchWidget::zoomOut() { TRACE_OBJ - QTextBrowser* browser = qFindChild(resultWidget); + QTextBrowser* browser = resultWidget->findChild(); if (browser && zoomCount != -5) { zoomCount--; browser->zoomOut(); @@ -123,7 +123,7 @@ void SearchWidget::resetZoom() if (zoomCount == 0) return; - QTextBrowser* browser = qFindChild(resultWidget); + QTextBrowser* browser = resultWidget->findChild(); if (browser) { browser->zoomOut(zoomCount); zoomCount = 0; @@ -165,7 +165,7 @@ void SearchWidget::searchingFinished(int hits) bool SearchWidget::eventFilter(QObject* o, QEvent *e) { TRACE_OBJ - QTextBrowser* browser = qFindChild(resultWidget); + QTextBrowser* browser = resultWidget->findChild(); if (browser && o == browser->viewport() && e->type() == QEvent::MouseButtonRelease){ QMouseEvent *me = static_cast(e); @@ -196,7 +196,7 @@ void SearchWidget::contextMenuEvent(QContextMenuEvent *contextMenuEvent) QMenu menu; QPoint point = contextMenuEvent->globalPos(); - QTextBrowser* browser = qFindChild(resultWidget); + QTextBrowser* browser = resultWidget->findChild(); if (!browser) return; diff --git a/tools/designer/src/components/buddyeditor/buddyeditor.cpp b/tools/designer/src/components/buddyeditor/buddyeditor.cpp index e367f9a..4127d7c 100644 --- a/tools/designer/src/components/buddyeditor/buddyeditor.cpp +++ b/tools/designer/src/components/buddyeditor/buddyeditor.cpp @@ -153,13 +153,13 @@ void BuddyEditor::updateBackground() m_updating = true; QList newList; - const LabelList label_list = qFindChildren(background()); + const LabelList label_list = background()->findChildren(); foreach (QLabel *label, label_list) { const QString buddy_name = buddy(label, m_formWindow->core()); if (buddy_name.isEmpty()) continue; - const QList targets = qFindChildren(background(), buddy_name); + const QList targets = background()->findChildren(buddy_name); if (targets.isEmpty()) continue; @@ -238,12 +238,12 @@ void BuddyEditor::setBackground(QWidget *background) clear(); ConnectionEdit::setBackground(background); - const LabelList label_list = qFindChildren(background); + const LabelList label_list = background->findChildren(); foreach (QLabel *label, label_list) { const QString buddy_name = buddy(label, m_formWindow->core()); if (buddy_name.isEmpty()) continue; - QWidget *target = qFindChild(background, buddy_name); + QWidget *target = background->findChild(buddy_name); if (target == 0) continue; @@ -297,7 +297,7 @@ void BuddyEditor::endConnection(QWidget *target, const QPoint &pos) void BuddyEditor::widgetRemoved(QWidget *widget) { - QList child_list = qFindChildren(widget); + QList child_list = widget->findChildren(); child_list.prepend(widget); ConnectionSet remove_set; @@ -354,7 +354,7 @@ void BuddyEditor::deleteSelected() void BuddyEditor::autoBuddy() { // Any labels? - LabelList labelList = qFindChildren(background()); + LabelList labelList = background()->findChildren(); if (labelList.empty()) return; // Find already used buddies diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 15775f6..eeb63e5 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -387,7 +387,7 @@ void FormWindow::setCursorToAll(const QCursor &c, QWidget *start) { #ifndef QT_NO_CURSOR start->setCursor(c); - const QWidgetList widgets = qFindChildren(start); + const QWidgetList widgets = start->findChildren(); foreach (QWidget *widget, widgets) { if (!qobject_cast(widget)) { widget->setCursor(c); @@ -945,7 +945,7 @@ bool FormWindow::isMainContainer(const QWidget *w) const void FormWindow::updateChildSelections(QWidget *w) { - const QWidgetList l = qFindChildren(w); + const QWidgetList l = w->findChildren(); if (!l.empty()) { const QWidgetList::const_iterator lcend = l.constEnd(); for (QWidgetList::const_iterator it = l.constBegin(); it != lcend; ++it) { @@ -1155,19 +1155,19 @@ bool FormWindow::unify(QObject *w, QString &s, bool changeIt) existingNames.insert(main->objectName()); const QDesignerMetaDataBaseInterface *metaDataBase = core()->metaDataBase(); - const QWidgetList widgetChildren = qFindChildren(main); + const QWidgetList widgetChildren = main->findChildren(); if (!widgetChildren.empty()) insertNames(metaDataBase, widgetChildren.constBegin(), widgetChildren.constEnd(), w, existingNames); - const QList layoutChildren = qFindChildren(main); + const QList layoutChildren = main->findChildren(); if (!layoutChildren.empty()) insertNames(metaDataBase, layoutChildren.constBegin(), layoutChildren.constEnd(), w, existingNames); - const QList actionChildren = qFindChildren(main); + const QList actionChildren = main->findChildren(); if (!actionChildren.empty()) insertNames(metaDataBase, actionChildren.constBegin(), actionChildren.constEnd(), w, existingNames); - const QList buttonGroupChildren = qFindChildren(main); + const QList buttonGroupChildren = main->findChildren(); if (!buttonGroupChildren.empty()) insertNames(metaDataBase, buttonGroupChildren.constBegin(), buttonGroupChildren.constEnd(), w, existingNames); @@ -1283,7 +1283,7 @@ void FormWindow::resizeWidget(QWidget *widget, const QRect &geometry) void FormWindow::raiseChildSelections(QWidget *w) { - const QWidgetList l = qFindChildren(w); + const QWidgetList l = w->findChildren(); if (l.isEmpty()) return; m_selection->raiseList(l); @@ -1344,7 +1344,7 @@ QWidgetList FormWindow::selectedWidgets() const void FormWindow::selectWidgets() { bool selectionChanged = false; - const QWidgetList l = qFindChildren(mainContainer()); + const QWidgetList l = mainContainer()->findChildren(); QListIterator it(l); const QRect selRect(mapToGlobal(m_currRect.topLeft()), m_currRect.size()); while (it.hasNext()) { diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp index 1d78695..135e23b 100644 --- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp @@ -946,7 +946,7 @@ QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) w->addAction(a); } else if (QActionGroup *g = m_actionGroups.value(name)) { w->addActions(g->actions()); - } else if (QMenu *menu = qFindChild(w, name)) { + } else if (QMenu *menu = w->findChild(name)) { w->addAction(menu->menuAction()); addMenuAction(menu->menuAction()); } @@ -1320,7 +1320,7 @@ DomLayout *QDesignerResource::createDom(QLayout *layout, DomLayout *ui_parentLay QDesignerMetaDataBaseItemInterface *item = core()->metaDataBase()->item(layout); if (item == 0) { - layout = qFindChild(layout); + layout = layout->findChild(); // refresh the meta database item item = core()->metaDataBase()->item(layout); } @@ -1440,7 +1440,7 @@ void QDesignerResource::applyTabStops(QWidget *widget, DomTabStops *tabStops) QList tabOrder; foreach (const QString &widgetName, tabStops->elementTabStop()) { - if (QWidget *w = qFindChild(widget, widgetName)) { + if (QWidget *w = widget->findChild(widgetName)) { tabOrder.append(w); } } diff --git a/tools/designer/src/components/formeditor/qmainwindow_container.cpp b/tools/designer/src/components/formeditor/qmainwindow_container.cpp index 9b5326a..ef4ce85 100644 --- a/tools/designer/src/components/formeditor/qmainwindow_container.cpp +++ b/tools/designer/src/components/formeditor/qmainwindow_container.cpp @@ -104,7 +104,7 @@ Qt::DockWidgetArea dockWidgetArea(QDockWidget *me) QList candidates; if (mw->layout()) { candidates.append(mw->layout()); - candidates += qFindChildren(mw->layout()); + candidates += mw->layout()->findChildren(); } foreach (QLayout *l, candidates) { if (l->indexOf(me) != -1) { diff --git a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp index 8674ac1..09c2233 100644 --- a/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp +++ b/tools/designer/src/components/signalsloteditor/signalslot_utils.cpp @@ -245,7 +245,7 @@ namespace qdesigner_internal { ClassesMemberFunctions reverseClassesMemberFunctions(const QString &obj_name, MemberType member_type, const QString &peer, QDesignerFormWindowInterface *form) { - QObject *object = qFindChild(form, obj_name); + QObject *object = form->findChild(obj_name); if (!object) return ClassesMemberFunctions(); diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp index b801c5e..1d45ef5 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditor.cpp @@ -372,7 +372,7 @@ QObject *SignalSlotEditor::objectByName(QWidget *topLevel, const QString &name) if (topLevel->objectName() == name) object = topLevel; else - object = qFindChild(topLevel, name); + object = topLevel->findChild(name); const QDesignerMetaDataBaseInterface *mdb = formWindow()->core()->metaDataBase(); if (mdb->item(object)) return object; diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 5547761..530f176 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -117,7 +117,7 @@ static QStringList objectNameList(QDesignerFormWindowInterface *form) const QDesignerMetaDataBaseInterface *mdb = form->core()->metaDataBase(); // Add managed actions and actions with managed menus - const ActionList actions = qFindChildren(mainContainer); + const ActionList actions = mainContainer->findChildren(); if (!actions.empty()) { const ActionList::const_iterator cend = actions.constEnd(); for (ActionList::const_iterator it = actions.constBegin(); it != cend; ++it) { @@ -135,7 +135,7 @@ static QStringList objectNameList(QDesignerFormWindowInterface *form) } // Add managed buttons groups - const ButtonGroupList buttonGroups = qFindChildren(mainContainer); + const ButtonGroupList buttonGroups = mainContainer->findChildren(); if (!buttonGroups.empty()) { const ButtonGroupList::const_iterator cend = buttonGroups.constEnd(); for (ButtonGroupList::const_iterator it = buttonGroups.constBegin(); it != cend; ++it) @@ -658,7 +658,7 @@ QWidget *ConnectionDelegate::createEditor(QWidget *parent, const qdesigner_internal::ClassesMemberFunctions class_list = qdesigner_internal::reverseClassesMemberFunctions(obj_name, type, peer, m_form); - QObject *object = qFindChild(m_form, obj_name); + QObject *object = m_form->findChild(obj_name); inline_editor->addText(type == qdesigner_internal::SignalMember ? tr("") : tr("")); foreach (const qdesigner_internal::ClassMemberFunctions &class_info, class_list) { @@ -767,7 +767,7 @@ void SignalSlotEditorWindow::setActiveFormWindow(QDesignerFormWindowInterface *f } } - m_editor = qFindChild(form); + m_editor = form->findChild(); m_model->setEditor(m_editor); if (!m_editor.isNull()) { ConnectionDelegate *delegate diff --git a/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp b/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp index 25798d3..ac32795 100644 --- a/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp +++ b/tools/designer/src/components/widgetbox/widgetbox_dnditem.cpp @@ -185,7 +185,7 @@ static QWidget *decorationFromDomWidget(DomUI *dom_ui, QDesignerFormEditorInterf fakeTopLevel->setParent(0, Qt::ToolTip); // Container // Actual widget const DomWidget *domW = dom_ui->elementWidget()->elementWidget().front(); - QWidget *w = qFindChildren(fakeTopLevel).front(); + QWidget *w = fakeTopLevel->findChildren().front(); Q_ASSERT(w); // hack begin; // We set _q_dockDrag dynamic property which will be detected in drag enter event of form window. diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp index 26ac8a8..664921e 100644 --- a/tools/designer/src/lib/shared/actioneditor.cpp +++ b/tools/designer/src/lib/shared/actioneditor.cpp @@ -288,7 +288,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow) return; if (m_formWindow != 0) { - const ActionList actionList = qFindChildren(m_formWindow->mainContainer()); + const ActionList actionList = m_formWindow->mainContainer()->findChildren(); foreach (QAction *action, actionList) disconnect(action, SIGNAL(changed()), this, SLOT(slotActionChanged())); } @@ -311,7 +311,7 @@ void ActionEditor::setFormWindow(QDesignerFormWindowInterface *formWindow) m_actionNew->setEnabled(true); m_filterWidget->setEnabled(true); - const ActionList actionList = qFindChildren(formWindow->mainContainer()); + const ActionList actionList = formWindow->mainContainer()->findChildren(); foreach (QAction *action, actionList) if (!action->isSeparator() && core()->metaDataBase()->item(action) != 0) { // Show unless it has a menu. However, listen for change on menu actions also as it might be removed diff --git a/tools/designer/src/lib/shared/connectionedit.cpp b/tools/designer/src/lib/shared/connectionedit.cpp index 0bebe47..fb6cf60 100644 --- a/tools/designer/src/lib/shared/connectionedit.cpp +++ b/tools/designer/src/lib/shared/connectionedit.cpp @@ -1395,7 +1395,7 @@ void ConnectionEdit::widgetRemoved(QWidget *widget) if (m_con_list.empty()) return; - QWidgetList child_list = qFindChildren(widget); + QWidgetList child_list = widget->findChildren(); child_list.prepend(widget); const ConnectionSet remove_set = findConnectionsOf(m_con_list, child_list.constBegin(), child_list.constEnd()); @@ -1545,7 +1545,7 @@ void ConnectionEdit::setSource(Connection *con, const QString &obj_name) { QObject *object = 0; if (!obj_name.isEmpty()) { - object = qFindChild(m_bg_widget, obj_name); + object = m_bg_widget->findChild(obj_name); if (object == 0 && m_bg_widget->objectName() == obj_name) object = m_bg_widget; @@ -1559,7 +1559,7 @@ void ConnectionEdit::setTarget(Connection *con, const QString &obj_name) { QObject *object = 0; if (!obj_name.isEmpty()) { - object = qFindChild(m_bg_widget, obj_name); + object = m_bg_widget->findChild(obj_name); if (object == 0 && m_bg_widget->objectName() == obj_name) object = m_bg_widget; diff --git a/tools/designer/src/lib/shared/layoutinfo.cpp b/tools/designer/src/lib/shared/layoutinfo.cpp index ad2dda4..309aa37 100644 --- a/tools/designer/src/lib/shared/layoutinfo.cpp +++ b/tools/designer/src/lib/shared/layoutinfo.cpp @@ -190,7 +190,7 @@ LayoutInfo::Type LayoutInfo::laidoutWidgetType(const QDesignerFormEditorInterfac } // 3) Some child layout (see below comment about Q3GroupBox) - const QList childLayouts = qFindChildren(parentLayout); + const QList childLayouts = parentLayout->findChildren(); if (childLayouts.empty()) return NoLayout; const QList::const_iterator lcend = childLayouts.constEnd(); @@ -244,7 +244,7 @@ QLayout *LayoutInfo::managedLayout(const QDesignerFormEditorInterface *core, QLa * widget->layout() returns an internal VBoxLayout. */ const QDesignerMetaDataBaseItemInterface *item = metaDataBase->item(layout); if (item == 0) { - layout = qFindChild(layout); + layout = layout->findChild(); item = metaDataBase->item(layout); } if (!item) diff --git a/tools/designer/src/lib/shared/morphmenu.cpp b/tools/designer/src/lib/shared/morphmenu.cpp index de85d37..6dfac47 100644 --- a/tools/designer/src/lib/shared/morphmenu.cpp +++ b/tools/designer/src/lib/shared/morphmenu.cpp @@ -240,7 +240,7 @@ static QString suggestObjectName(const QString &oldClassName, const QString &new QLabel *buddyLabelOf(QDesignerFormWindowInterface *fw, QWidget *w) { typedef QList LabelList; - const LabelList labelList = qFindChildren(fw); + const LabelList labelList = fw->findChildren(); if (labelList.empty()) return 0; const LabelList::const_iterator cend = labelList.constEnd(); diff --git a/tools/designer/src/lib/shared/qdesigner_command.cpp b/tools/designer/src/lib/shared/qdesigner_command.cpp index 69206df..9fe0e89 100644 --- a/tools/designer/src/lib/shared/qdesigner_command.cpp +++ b/tools/designer/src/lib/shared/qdesigner_command.cpp @@ -247,7 +247,7 @@ void InsertWidgetCommand::refreshBuddyLabels() { typedef QList LabelList; - const LabelList label_list = qFindChildren(formWindow()); + const LabelList label_list = formWindow()->findChildren(); if (label_list.empty()) return; @@ -365,7 +365,7 @@ void ManageWidgetCommandHelper::init(const QDesignerFormWindowInterface *fw, QWi m_widget = widget; m_managedChildren.clear(); - const QWidgetList children = qFindChildren(m_widget); + const QWidgetList children = m_widget->findChildren(); if (children.empty()) return; diff --git a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index 490373e..675752e 100644 --- a/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -115,7 +115,7 @@ void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *for typedef QList LabelList; - const LabelList label_list = qFindChildren(form); + const LabelList label_list = form->findChildren(); if (label_list.empty()) return; diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp index 31a226a..bbab032 100644 --- a/tools/designer/src/lib/shared/qdesigner_menu.cpp +++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp @@ -630,7 +630,7 @@ QDesignerMenu *QDesignerMenu::findActivatedMenu() const { QList candidates; candidates.append(const_cast(this)); - candidates += qFindChildren(this); + candidates += findChildren(); foreach (QDesignerMenu *m, candidates) { if (m == qApp->activeWindow()) @@ -867,7 +867,7 @@ void QDesignerMenu::closeMenuChain() w = w->parentWidget(); if (w) { - foreach (QMenu *subMenu, qFindChildren(w)) { + foreach (QMenu *subMenu, w->findChildren()) { subMenu->hide(); } } @@ -1323,7 +1323,7 @@ QAction *QDesignerMenu::safeActionAt(int index) const void QDesignerMenu::hideSubMenu() { m_lastSubMenuIndex = -1; - foreach (QMenu *subMenu, qFindChildren(this)) { + foreach (QMenu *subMenu, findChildren()) { subMenu->hide(); } } diff --git a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp index ecd97fa..78c6bd9 100644 --- a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -134,7 +134,7 @@ QTabBar *QTabWidgetEventFilter::tabBar() const { // QTabWidget::tabBar() accessor is protected, grmbl... if (!m_cachedTabBar) { - const QList tabBars = qFindChildren(m_tabWidget); + const QList tabBars = m_tabWidget->findChildren(); Q_ASSERT(tabBars.size() == 1); m_cachedTabBar = tabBars.front(); } diff --git a/tools/designer/src/lib/shared/widgetfactory.cpp b/tools/designer/src/lib/shared/widgetfactory.cpp index c7b13a1..d686052 100644 --- a/tools/designer/src/lib/shared/widgetfactory.cpp +++ b/tools/designer/src/lib/shared/widgetfactory.cpp @@ -782,7 +782,7 @@ void WidgetFactory::applyStyleToTopLevel(QStyle *style, QWidget *widget) widget->setStyle(style); widget->setPalette(standardPalette); - const QWidgetList lst = qFindChildren(widget); + const QWidgetList lst = widget->findChildren(); const QWidgetList::const_iterator cend = lst.constEnd(); for (QWidgetList::const_iterator it = lst.constBegin(); it != cend; ++it) (*it)->setStyle(style); diff --git a/tools/designer/src/lib/shared/zoomwidget.cpp b/tools/designer/src/lib/shared/zoomwidget.cpp index f5d7434..5cf4ea2 100644 --- a/tools/designer/src/lib/shared/zoomwidget.cpp +++ b/tools/designer/src/lib/shared/zoomwidget.cpp @@ -328,7 +328,7 @@ void ZoomWidget::setWidget(QWidget *w, Qt::WindowFlags wFlags) scene().removeItem(m_proxy); if (QWidget *w = m_proxy->widget()) { // remove the event filter - if (QObject *evf = qFindChild(w, QLatin1String(zoomedEventFilterRedirectorNameC))) + if (QObject *evf = w->findChild(QLatin1String(zoomedEventFilterRedirectorNameC))) w->removeEventFilter(evf); } m_proxy->deleteLater(); diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index 6f009e3..a280876 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -341,7 +341,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge w->addAction(a); } else if (QActionGroup *g = m_actionGroups.value(name)) { w->addActions(g->actions()); - } else if (QMenu *menu = qFindChild(w, name)) { + } else if (QMenu *menu = w->findChild(name)) { w->addAction(menu->menuAction()); addMenuAction(menu->menuAction()); } @@ -365,7 +365,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge if (!zOrderNames.isEmpty()) { QList zOrder = qVariantValue(w->property("_q_zOrder")); foreach (const QString &widgetName, zOrderNames) { - if (QWidget *child = qFindChild(w, widgetName)) { + if (QWidget *child = w->findChild(widgetName)) { if (child->parentWidget() == w) { zOrder.removeAll(child); zOrder.append(child); @@ -1603,14 +1603,14 @@ void QAbstractFormBuilder::applyTabStops(QWidget *widget, DomTabStops *tabStops) for (int i=0; i(widget, name); + QWidget *child = widget->findChild(name); if (!child) { uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "While applying tab stops: The widget '%1' could not be found.").arg(name)); continue; } if (i == 0) { - lastWidget = qFindChild(widget, name); + lastWidget = widget->findChild(name); continue; } else if (!child || !lastWidget) { continue; @@ -1618,7 +1618,7 @@ void QAbstractFormBuilder::applyTabStops(QWidget *widget, DomTabStops *tabStops) QWidget::setTabOrder(lastWidget, child); - lastWidget = qFindChild(widget, name); + lastWidget = widget->findChild(name); } } diff --git a/tools/designer/src/lib/uilib/formbuilder.cpp b/tools/designer/src/lib/uilib/formbuilder.cpp index c97daac..c7d4e90 100644 --- a/tools/designer/src/lib/uilib/formbuilder.cpp +++ b/tools/designer/src/lib/uilib/formbuilder.cpp @@ -319,7 +319,7 @@ QWidget *QFormBuilder::widgetByName(QWidget *topLevel, const QString &name) if (topLevel->objectName() == name) return topLevel; - return qFindChild(topLevel, name); + return topLevel->findChild(name); } static QObject *objectByName(QWidget *topLevel, const QString &name) @@ -328,7 +328,7 @@ static QObject *objectByName(QWidget *topLevel, const QString &name) if (topLevel->objectName() == name) return topLevel; - return qFindChild(topLevel, name); + return topLevel->findChild(name); } /*! diff --git a/tools/designer/src/lib/uilib/formbuilderextra.cpp b/tools/designer/src/lib/uilib/formbuilderextra.cpp index 6c3357f..0747974 100644 --- a/tools/designer/src/lib/uilib/formbuilderextra.cpp +++ b/tools/designer/src/lib/uilib/formbuilderextra.cpp @@ -136,7 +136,7 @@ bool QFormBuilderExtra::applyBuddy(const QString &buddyName, BuddyMode applyMode return false; } - const QWidgetList widgets = qFindChildren(label->topLevelWidget(), buddyName); + const QWidgetList widgets = label->topLevelWidget()->findChildren(buddyName); if (widgets.empty()) { label->setBuddy(0); return false; diff --git a/tools/shared/qtpropertybrowser/qtvariantproperty.cpp b/tools/shared/qtpropertybrowser/qtvariantproperty.cpp index b16fac3..15b0ced 100644 --- a/tools/shared/qtpropertybrowser/qtvariantproperty.cpp +++ b/tools/shared/qtpropertybrowser/qtvariantproperty.cpp @@ -1997,87 +1997,87 @@ QtVariantEditorFactory::~QtVariantEditorFactory() */ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *manager) { - QList intPropertyManagers = qFindChildren(manager); + QList intPropertyManagers = manager->findChildren(); QListIterator itInt(intPropertyManagers); while (itInt.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itInt.next()); - QList doublePropertyManagers = qFindChildren(manager); + QList doublePropertyManagers = manager->findChildren(); QListIterator itDouble(doublePropertyManagers); while (itDouble.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itDouble.next()); - QList boolPropertyManagers = qFindChildren(manager); + QList boolPropertyManagers = manager->findChildren(); QListIterator itBool(boolPropertyManagers); while (itBool.hasNext()) d_ptr->m_checkBoxFactory->addPropertyManager(itBool.next()); - QList stringPropertyManagers = qFindChildren(manager); + QList stringPropertyManagers = manager->findChildren(); QListIterator itString(stringPropertyManagers); while (itString.hasNext()) d_ptr->m_lineEditFactory->addPropertyManager(itString.next()); - QList datePropertyManagers = qFindChildren(manager); + QList datePropertyManagers = manager->findChildren(); QListIterator itDate(datePropertyManagers); while (itDate.hasNext()) d_ptr->m_dateEditFactory->addPropertyManager(itDate.next()); - QList timePropertyManagers = qFindChildren(manager); + QList timePropertyManagers = manager->findChildren(); QListIterator itTime(timePropertyManagers); while (itTime.hasNext()) d_ptr->m_timeEditFactory->addPropertyManager(itTime.next()); - QList dateTimePropertyManagers = qFindChildren(manager); + QList dateTimePropertyManagers = manager->findChildren(); QListIterator itDateTime(dateTimePropertyManagers); while (itDateTime.hasNext()) d_ptr->m_dateTimeEditFactory->addPropertyManager(itDateTime.next()); - QList keySequencePropertyManagers = qFindChildren(manager); + QList keySequencePropertyManagers = manager->findChildren(); QListIterator itKeySequence(keySequencePropertyManagers); while (itKeySequence.hasNext()) d_ptr->m_keySequenceEditorFactory->addPropertyManager(itKeySequence.next()); - QList charPropertyManagers = qFindChildren(manager); + QList charPropertyManagers = manager->findChildren(); QListIterator itChar(charPropertyManagers); while (itChar.hasNext()) d_ptr->m_charEditorFactory->addPropertyManager(itChar.next()); - QList localePropertyManagers = qFindChildren(manager); + QList localePropertyManagers = manager->findChildren(); QListIterator itLocale(localePropertyManagers); while (itLocale.hasNext()) d_ptr->m_comboBoxFactory->addPropertyManager(itLocale.next()->subEnumPropertyManager()); - QList pointPropertyManagers = qFindChildren(manager); + QList pointPropertyManagers = manager->findChildren(); QListIterator itPoint(pointPropertyManagers); while (itPoint.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itPoint.next()->subIntPropertyManager()); - QList pointFPropertyManagers = qFindChildren(manager); + QList pointFPropertyManagers = manager->findChildren(); QListIterator itPointF(pointFPropertyManagers); while (itPointF.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itPointF.next()->subDoublePropertyManager()); - QList sizePropertyManagers = qFindChildren(manager); + QList sizePropertyManagers = manager->findChildren(); QListIterator itSize(sizePropertyManagers); while (itSize.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itSize.next()->subIntPropertyManager()); - QList sizeFPropertyManagers = qFindChildren(manager); + QList sizeFPropertyManagers = manager->findChildren(); QListIterator itSizeF(sizeFPropertyManagers); while (itSizeF.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itSizeF.next()->subDoublePropertyManager()); - QList rectPropertyManagers = qFindChildren(manager); + QList rectPropertyManagers = manager->findChildren(); QListIterator itRect(rectPropertyManagers); while (itRect.hasNext()) d_ptr->m_spinBoxFactory->addPropertyManager(itRect.next()->subIntPropertyManager()); - QList rectFPropertyManagers = qFindChildren(manager); + QList rectFPropertyManagers = manager->findChildren(); QListIterator itRectF(rectFPropertyManagers); while (itRectF.hasNext()) d_ptr->m_doubleSpinBoxFactory->addPropertyManager(itRectF.next()->subDoublePropertyManager()); - QList colorPropertyManagers = qFindChildren(manager); + QList colorPropertyManagers = manager->findChildren(); QListIterator itColor(colorPropertyManagers); while (itColor.hasNext()) { QtColorPropertyManager *manager = itColor.next(); @@ -2085,12 +2085,12 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); } - QList enumPropertyManagers = qFindChildren(manager); + QList enumPropertyManagers = manager->findChildren(); QListIterator itEnum(enumPropertyManagers); while (itEnum.hasNext()) d_ptr->m_comboBoxFactory->addPropertyManager(itEnum.next()); - QList sizePolicyPropertyManagers = qFindChildren(manager); + QList sizePolicyPropertyManagers = manager->findChildren(); QListIterator itSizePolicy(sizePolicyPropertyManagers); while (itSizePolicy.hasNext()) { QtSizePolicyPropertyManager *manager = itSizePolicy.next(); @@ -2098,7 +2098,7 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); } - QList fontPropertyManagers = qFindChildren(manager); + QList fontPropertyManagers = manager->findChildren(); QListIterator itFont(fontPropertyManagers); while (itFont.hasNext()) { QtFontPropertyManager *manager = itFont.next(); @@ -2108,12 +2108,12 @@ void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *ma d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager()); } - QList cursorPropertyManagers = qFindChildren(manager); + QList cursorPropertyManagers = manager->findChildren(); QListIterator itCursor(cursorPropertyManagers); while (itCursor.hasNext()) d_ptr->m_cursorEditorFactory->addPropertyManager(itCursor.next()); - QList flagPropertyManagers = qFindChildren(manager); + QList flagPropertyManagers = manager->findChildren(); QListIterator itFlag(flagPropertyManagers); while (itFlag.hasNext()) d_ptr->m_checkBoxFactory->addPropertyManager(itFlag.next()->subBoolPropertyManager()); @@ -2141,87 +2141,87 @@ QWidget *QtVariantEditorFactory::createEditor(QtVariantPropertyManager *manager, */ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager *manager) { - QList intPropertyManagers = qFindChildren(manager); + QList intPropertyManagers = manager->findChildren(); QListIterator itInt(intPropertyManagers); while (itInt.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itInt.next()); - QList doublePropertyManagers = qFindChildren(manager); + QList doublePropertyManagers = manager->findChildren(); QListIterator itDouble(doublePropertyManagers); while (itDouble.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itDouble.next()); - QList boolPropertyManagers = qFindChildren(manager); + QList boolPropertyManagers = manager->findChildren(); QListIterator itBool(boolPropertyManagers); while (itBool.hasNext()) d_ptr->m_checkBoxFactory->removePropertyManager(itBool.next()); - QList stringPropertyManagers = qFindChildren(manager); + QList stringPropertyManagers = manager->findChildren(); QListIterator itString(stringPropertyManagers); while (itString.hasNext()) d_ptr->m_lineEditFactory->removePropertyManager(itString.next()); - QList datePropertyManagers = qFindChildren(manager); + QList datePropertyManagers = manager->findChildren(); QListIterator itDate(datePropertyManagers); while (itDate.hasNext()) d_ptr->m_dateEditFactory->removePropertyManager(itDate.next()); - QList timePropertyManagers = qFindChildren(manager); + QList timePropertyManagers = manager->findChildren(); QListIterator itTime(timePropertyManagers); while (itTime.hasNext()) d_ptr->m_timeEditFactory->removePropertyManager(itTime.next()); - QList dateTimePropertyManagers = qFindChildren(manager); + QList dateTimePropertyManagers = manager->findChildren(); QListIterator itDateTime(dateTimePropertyManagers); while (itDateTime.hasNext()) d_ptr->m_dateTimeEditFactory->removePropertyManager(itDateTime.next()); - QList keySequencePropertyManagers = qFindChildren(manager); + QList keySequencePropertyManagers = manager->findChildren(); QListIterator itKeySequence(keySequencePropertyManagers); while (itKeySequence.hasNext()) d_ptr->m_keySequenceEditorFactory->removePropertyManager(itKeySequence.next()); - QList charPropertyManagers = qFindChildren(manager); + QList charPropertyManagers = manager->findChildren(); QListIterator itChar(charPropertyManagers); while (itChar.hasNext()) d_ptr->m_charEditorFactory->removePropertyManager(itChar.next()); - QList localePropertyManagers = qFindChildren(manager); + QList localePropertyManagers = manager->findChildren(); QListIterator itLocale(localePropertyManagers); while (itLocale.hasNext()) d_ptr->m_comboBoxFactory->removePropertyManager(itLocale.next()->subEnumPropertyManager()); - QList pointPropertyManagers = qFindChildren(manager); + QList pointPropertyManagers = manager->findChildren(); QListIterator itPoint(pointPropertyManagers); while (itPoint.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itPoint.next()->subIntPropertyManager()); - QList pointFPropertyManagers = qFindChildren(manager); + QList pointFPropertyManagers = manager->findChildren(); QListIterator itPointF(pointFPropertyManagers); while (itPointF.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itPointF.next()->subDoublePropertyManager()); - QList sizePropertyManagers = qFindChildren(manager); + QList sizePropertyManagers = manager->findChildren(); QListIterator itSize(sizePropertyManagers); while (itSize.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itSize.next()->subIntPropertyManager()); - QList sizeFPropertyManagers = qFindChildren(manager); + QList sizeFPropertyManagers = manager->findChildren(); QListIterator itSizeF(sizeFPropertyManagers); while (itSizeF.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itSizeF.next()->subDoublePropertyManager()); - QList rectPropertyManagers = qFindChildren(manager); + QList rectPropertyManagers = manager->findChildren(); QListIterator itRect(rectPropertyManagers); while (itRect.hasNext()) d_ptr->m_spinBoxFactory->removePropertyManager(itRect.next()->subIntPropertyManager()); - QList rectFPropertyManagers = qFindChildren(manager); + QList rectFPropertyManagers = manager->findChildren(); QListIterator itRectF(rectFPropertyManagers); while (itRectF.hasNext()) d_ptr->m_doubleSpinBoxFactory->removePropertyManager(itRectF.next()->subDoublePropertyManager()); - QList colorPropertyManagers = qFindChildren(manager); + QList colorPropertyManagers = manager->findChildren(); QListIterator itColor(colorPropertyManagers); while (itColor.hasNext()) { QtColorPropertyManager *manager = itColor.next(); @@ -2229,12 +2229,12 @@ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); } - QList enumPropertyManagers = qFindChildren(manager); + QList enumPropertyManagers = manager->findChildren(); QListIterator itEnum(enumPropertyManagers); while (itEnum.hasNext()) d_ptr->m_comboBoxFactory->removePropertyManager(itEnum.next()); - QList sizePolicyPropertyManagers = qFindChildren(manager); + QList sizePolicyPropertyManagers = manager->findChildren(); QListIterator itSizePolicy(sizePolicyPropertyManagers); while (itSizePolicy.hasNext()) { QtSizePolicyPropertyManager *manager = itSizePolicy.next(); @@ -2242,7 +2242,7 @@ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); } - QList fontPropertyManagers = qFindChildren(manager); + QList fontPropertyManagers = manager->findChildren(); QListIterator itFont(fontPropertyManagers); while (itFont.hasNext()) { QtFontPropertyManager *manager = itFont.next(); @@ -2252,12 +2252,12 @@ void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager()); } - QList cursorPropertyManagers = qFindChildren(manager); + QList cursorPropertyManagers = manager->findChildren(); QListIterator itCursor(cursorPropertyManagers); while (itCursor.hasNext()) d_ptr->m_cursorEditorFactory->removePropertyManager(itCursor.next()); - QList flagPropertyManagers = qFindChildren(manager); + QList flagPropertyManagers = manager->findChildren(); QListIterator itFlag(flagPropertyManagers); while (itFlag.hasNext()) d_ptr->m_checkBoxFactory->removePropertyManager(itFlag.next()->subBoolPropertyManager()); -- cgit v0.12 From 7b5e37cab738804d47b78582aa3d0f3bb6933e70 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Aug 2010 10:10:50 +0200 Subject: Deprecate qVariantValue qVariantCanConvert qVariantFromValue qVariantSetValue The template member equivalent should be used instead. qVariantFromValue and qVariantSetValue does not have the QT_DEPRECATED macro, as they have template specialisation which is not possible to acheive as member function. So they are called by the non-deprecated implementation. Rev-by: dev mailing list --- src/corelib/kernel/qvariant.cpp | 16 ++++++++++------ src/corelib/kernel/qvariant.h | 24 +++++++++--------------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index bbfbce8..feb85ce 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1076,7 +1076,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) dbg.nospace() << v.toFloat(); break; case QMetaType::QObjectStar: - dbg.nospace() << qVariantValue(v); + dbg.nospace() << qvariant_cast(v); break; case QVariant::Double: dbg.nospace() << v.toDouble(); @@ -1237,7 +1237,7 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler; conversion functions to data types defined in QtGui, such as QColor, QImage, and QPixmap. In other words, there is no \c toColor() function. Instead, you can use the QVariant::value() or - the qVariantValue() template function. For example: + the qvariant_cast() template function. For example: \snippet doc/src/snippets/code/src_corelib_kernel_qvariant.cpp 2 @@ -1352,12 +1352,12 @@ const QVariant::Handler *QVariant::handler = &qt_kernel_variant_handler; Note that you have to pass the address of the variable you want stored. - Usually, you never have to use this constructor, use qVariantFromValue() + Usually, you never have to use this constructor, use QVariant::fromValue() instead to construct variants from the pointer types represented by \c QMetaType::VoidStar, \c QMetaType::QObjectStar and \c QMetaType::QWidgetStar. - \sa qVariantFromValue(), Type + \sa QVariant::fromValue(), Type */ /*! @@ -3116,6 +3116,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) /*! \fn QVariant qVariantFromValue(const T &value) \relates QVariant + \obsolete Returns a variant containing a copy of the given \a value with template type \c{T}. @@ -3136,6 +3137,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) /*! \fn void qVariantSetValue(QVariant &variant, const T &value) \relates QVariant + \obsolete Sets the contents of the given \a variant to a copy of the \a value with the specified template type \c{T}. @@ -3155,13 +3157,14 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) Returns the given \a value converted to the template type \c{T}. - This function is equivalent to qVariantValue(). + This function is equivalent to QVariant::value(). - \sa qVariantValue(), QVariant::value() + \sa QVariant::value() */ /*! \fn T qVariantValue(const QVariant &value) \relates QVariant + \obsolete Returns the given \a value converted to the template type \c{T}. @@ -3177,6 +3180,7 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p) /*! \fn bool qVariantCanConvert(const QVariant &value) \relates QVariant + \obsolete Returns true if the given \a value can be converted to the template type specified; otherwise returns false. diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 73b00e9..432b708 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -86,14 +86,8 @@ class QVariantComparisonHelper; template inline QVariant qVariantFromValue(const T &); -template -inline void qVariantSetValue(QVariant &, const T &); - -template -inline T qVariantValue(const QVariant &); - template -inline bool qVariantCanConvert(const QVariant &); +inline T qvariant_cast(const QVariant &); class Q_CORE_EXPORT QVariant { @@ -330,7 +324,7 @@ class Q_CORE_EXPORT QVariant template inline T value() const - { return qVariantValue(*this); } + { return qvariant_cast(*this); } template static inline QVariant fromValue(const T &value) @@ -338,7 +332,7 @@ class Q_CORE_EXPORT QVariant template bool canConvert() const - { return qVariantCanConvert(*this); } + { return canConvert(Type(qMetaTypeId())); } public: #ifndef qdoc @@ -588,16 +582,16 @@ template<> inline QVariant qvariant_cast(const QVariant &v) return v; } +#ifdef QT_DEPRECATED template -inline T qVariantValue(const QVariant &variant) +inline QT_DEPRECATED T qVariantValue(const QVariant &variant) { return qvariant_cast(variant); } template -inline bool qVariantCanConvert(const QVariant &variant) -{ - return variant.canConvert(static_cast( - qMetaTypeId(static_cast(0)))); -} +inline QT_DEPRECATED bool qVariantCanConvert(const QVariant &variant) +{ return variant.canConvert(); } +#endif + #endif Q_DECLARE_SHARED(QVariant) Q_DECLARE_TYPEINFO(QVariant, Q_MOVABLE_TYPE); -- cgit v0.12 From 633f3f45e5420663cf4ceadea79e62fea44cd2eb Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 4 Aug 2010 18:29:09 +0200 Subject: Remove the use of deprecated qVariant* Test directory untouched. This just apply those regexp: git grep -O"sed -i 's/qVariantValue]*\)> *(\([^&*\(),]*\), */\\2.setValue<\\1>(/'" qVariantSetValue git grep -O"sed -i 's/qVariantCanConvert *<\([^>]*\)> *(\([^&*\(),]*\))/\\2.canConvert<\\1>()/g'" qVariantCanConvert git grep -O"sed -i 's/qVariantCanConvert *<\([^>]*\)> *(\([^&*\(),]*([^&*\(),]*)\))/\\2.canConvert<\\1>()/g'" qVariantCanConvert git grep -O"sed -i 's/qVariantFromValue\( *[(<]\)/QVariant::fromValue\\1/'" qVariantFromValue git checkout src/corelib/kernal/qvariant* Rev-by: dev mailing list --- demos/browser/browserapplication.cpp | 4 +- demos/browser/cookiejar.cpp | 2 +- demos/browser/settings.cpp | 4 +- demos/embeddeddialogs/customproxy.cpp | 2 +- demos/interview/model.cpp | 2 +- demos/spectrum/app/settingsdialog.cpp | 8 +- demos/spreadsheet/spreadsheetitem.cpp | 6 +- dist/changes-4.6.0 | 2 +- doc/src/examples/customtype.qdoc | 2 +- doc/src/snippets/accessibilityslidersnippet.cpp | 2 +- doc/src/snippets/code/doc_src_qtscript.qdoc | 2 +- .../snippets/code/src_corelib_kernel_qvariant.cpp | 2 +- .../code/src_xmlpatterns_api_qxmlquery.cpp | 2 +- doc/src/xml-processing/xml-patterns.qdoc | 2 +- examples/draganddrop/puzzle/pieceslist.cpp | 2 +- examples/graphicsview/diagramscene/mainwindow.cpp | 12 +-- examples/graphicsview/dragdroprobot/robot.cpp | 4 +- .../graphicsview/padnavigator/padnavigator.cpp | 14 +-- .../coloreditorfactory/colorlisteditor.cpp | 2 +- examples/itemviews/puzzle/piecesmodel.cpp | 2 +- examples/itemviews/stardelegate/main.cpp | 2 +- examples/itemviews/stardelegate/stardelegate.cpp | 18 ++-- examples/multimedia/audiodevices/audiodevices.cpp | 2 +- examples/multimedia/audioinput/audioinput.cpp | 2 +- examples/multimedia/audiooutput/audiooutput.cpp | 2 +- examples/network/torrent/bencodeparser.cpp | 4 +- examples/network/torrent/metainfo.cpp | 4 +- examples/network/torrent/trackerclient.cpp | 2 +- examples/richtext/textobject/svgtextobject.cpp | 4 +- examples/script/context2d/context2d.cpp | 4 +- examples/script/context2d/domimage.cpp | 2 +- examples/script/customclass/bytearrayclass.cpp | 4 +- examples/sql/querymodel/customsqlmodel.cpp | 2 +- examples/tools/customtype/main.cpp | 2 +- examples/widgets/validators/localeselector.cpp | 4 +- src/3rdparty/phonon/phonon/mediacontroller.cpp | 4 +- src/3rdparty/phonon/phonon/qsettingsgroup_p.h | 4 +- .../webkit/WebCore/bridge/qt/qt_runtime.cpp | 12 +-- .../platform/graphics/qt/MediaPlayerPrivateQt.cpp | 2 +- .../WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 28 +++--- src/activeqt/container/qaxbase.cpp | 12 +-- src/activeqt/control/qaxserverbase.cpp | 8 +- src/activeqt/shared/qaxtypes.cpp | 28 +++--- src/dbus/qdbusabstractinterface.cpp | 2 +- src/dbus/qdbusdemarshaller.cpp | 18 ++-- src/dbus/qdbusintegrator.cpp | 4 +- src/dbus/qdbusinternalfilters.cpp | 6 +- src/declarative/debugger/qdeclarativedebug.cpp | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 30 +++--- src/declarative/qml/qdeclarativesqldatabase.cpp | 8 +- .../qml/qdeclarativestringconverters.cpp | 2 +- src/declarative/qml/qdeclarativeworkerscript.cpp | 2 +- src/declarative/qml/qdeclarativexmlhttprequest.cpp | 8 +- src/declarative/util/qdeclarativelistmodel.cpp | 8 +- src/gui/accessible/qaccessiblewidget.cpp | 2 +- src/gui/graphicsview/qgraphicsitem.cpp | 42 ++++---- src/gui/graphicsview/qgraphicsscene.cpp | 8 +- src/gui/image/qimagereader.cpp | 2 +- src/gui/image/qmnghandler.cpp | 2 +- src/gui/itemviews/qabstractitemdelegate.cpp | 4 +- src/gui/itemviews/qheaderview.cpp | 8 +- src/gui/itemviews/qitemdelegate.cpp | 4 +- src/gui/itemviews/qstyleditemdelegate.cpp | 2 +- src/gui/kernel/qclipboard.cpp | 2 +- src/gui/kernel/qtooltip.cpp | 2 +- src/gui/painting/qpaintbuffer.cpp | 44 ++++---- src/gui/styles/qstylesheetstyle.cpp | 6 +- src/gui/text/qcssparser.cpp | 36 +++---- src/gui/text/qtextcontrol.cpp | 2 +- src/gui/text/qtextformat.cpp | 6 +- src/gui/widgets/qcombobox.cpp | 4 +- src/multimedia/video/qvideosurfaceformat.cpp | 26 ++--- src/network/access/qnetworkaccessmanager.cpp | 2 +- src/network/access/qnetworkrequest.cpp | 4 +- .../accessible/widgets/qaccessiblewidgets.cpp | 2 +- src/plugins/accessible/widgets/rangecontrols.cpp | 4 +- src/plugins/accessible/widgets/simplewidgets.cpp | 2 +- .../bearer/connman/qconnmanservice_linux.cpp | 12 +-- src/script/api/qscriptengine.cpp | 2 +- src/script/bridge/qscriptclassobject.cpp | 6 +- src/script/bridge/qscriptqobject.cpp | 4 +- .../debugging/qscriptdebuggercommand.cpp | 6 +- .../debugging/qscriptdebuggercommandexecutor.cpp | 8 +- src/scripttools/debugging/qscriptdebuggerevent.cpp | 2 +- .../debugging/qscriptdebuggerresponse.cpp | 16 +-- src/sql/drivers/mysql/qsql_mysql.cpp | 6 +- src/sql/drivers/oci/qsql_oci.cpp | 14 +-- src/sql/drivers/psql/qsql_psql.cpp | 4 +- src/sql/drivers/sqlite/qsql_sqlite.cpp | 4 +- src/sql/drivers/sqlite2/qsql_sqlite2.cpp | 4 +- src/testlib/qtest.h | 2 +- src/tools/uic3/converter.cpp | 2 +- src/tools/uic3/domtool.cpp | 14 +-- src/tools/uic3/domtool.h | 2 +- src/xmlpatterns/api/quriloader.cpp | 2 +- src/xmlpatterns/api/qvariableloader.cpp | 14 +-- src/xmlpatterns/api/qxmlquery.cpp | 6 +- src/xmlpatterns/data/qatomicvalue.cpp | 2 +- tools/activeqt/testcon/changeproperties.cpp | 6 +- .../assistant/tools/assistant/bookmarkmanager.cpp | 2 +- .../tools/assistant/helpenginewrapper.cpp | 4 +- .../src/components/formeditor/dpi_chooser.cpp | 4 +- .../src/components/formeditor/formwindow.cpp | 10 +- .../components/formeditor/qdesigner_resource.cpp | 94 ++++++++--------- .../objectinspector/objectinspectormodel.cpp | 2 +- .../propertyeditor/brushpropertymanager.cpp | 2 +- .../propertyeditor/designerpropertymanager.cpp | 112 ++++++++++----------- .../propertyeditor/fontpropertymanager.cpp | 12 +-- .../components/propertyeditor/paletteeditor.cpp | 14 +-- .../components/propertyeditor/propertyeditor.cpp | 8 +- .../components/signalsloteditor/connectdialog.cpp | 4 +- .../signalsloteditor/signalsloteditorwindow.cpp | 2 +- .../components/tabordereditor/tabordereditor.cpp | 2 +- .../src/components/taskmenu/button_taskmenu.cpp | 2 +- .../src/components/taskmenu/inplace_editor.cpp | 6 +- .../src/components/taskmenu/itemlisteditor.cpp | 40 ++++---- .../src/components/taskmenu/tablewidgeteditor.cpp | 12 +-- .../src/components/taskmenu/treewidgeteditor.cpp | 14 +-- tools/designer/src/designer/qdesigner_settings.cpp | 2 +- tools/designer/src/lib/shared/actioneditor.cpp | 14 +-- tools/designer/src/lib/shared/actionrepository.cpp | 2 +- tools/designer/src/lib/shared/formlayoutmenu.cpp | 6 +- tools/designer/src/lib/shared/formwindowbase.cpp | 4 +- tools/designer/src/lib/shared/grid.cpp | 2 +- tools/designer/src/lib/shared/morphmenu.cpp | 4 +- .../designer/src/lib/shared/qdesigner_command.cpp | 78 +++++++------- .../src/lib/shared/qdesigner_formbuilder.cpp | 4 +- tools/designer/src/lib/shared/qdesigner_menu.cpp | 2 +- .../designer/src/lib/shared/qdesigner_menubar.cpp | 2 +- .../src/lib/shared/qdesigner_propertycommand.cpp | 28 +++--- .../src/lib/shared/qdesigner_propertysheet.cpp | 94 ++++++++--------- .../src/lib/shared/qdesigner_tabwidget.cpp | 32 +++--- .../designer/src/lib/shared/qdesigner_taskmenu.cpp | 10 +- .../designer/src/lib/shared/qdesigner_toolbar.cpp | 6 +- .../designer/src/lib/shared/qdesigner_toolbox.cpp | 24 ++--- tools/designer/src/lib/shared/qdesigner_utils.cpp | 16 +-- tools/designer/src/lib/shared/qdesigner_utils_p.h | 8 +- tools/designer/src/lib/shared/stylesheeteditor.cpp | 4 +- .../designer/src/lib/uilib/abstractformbuilder.cpp | 34 +++---- tools/designer/src/lib/uilib/properties.cpp | 20 ++-- tools/designer/src/lib/uilib/resourcebuilder.cpp | 6 +- tools/designer/src/uitools/quiloader.cpp | 28 +++--- tools/linguist/linguist/formpreviewview.cpp | 14 +-- tools/linguist/linguist/mainwindow.cpp | 2 +- tools/linguist/linguist/messagemodel.cpp | 12 +-- tools/makeqpf/mainwindow.cpp | 4 +- tools/qdbus/qdbus/qdbus.cpp | 8 +- tools/qdbus/qdbusviewer/qdbusviewer.cpp | 4 +- tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp | 8 +- .../shared/qtpropertybrowser/qtvariantproperty.cpp | 94 ++++++++--------- tools/xmlpatterns/main.cpp | 14 +-- 151 files changed, 807 insertions(+), 807 deletions(-) diff --git a/demos/browser/browserapplication.cpp b/demos/browser/browserapplication.cpp index ed95d32..633307c 100644 --- a/demos/browser/browserapplication.cpp +++ b/demos/browser/browserapplication.cpp @@ -231,14 +231,14 @@ void BrowserApplication::loadSettings() QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); QFont standardFont = QFont(standardFontFamily, standardFontSize); - standardFont = qVariantValue(settings.value(QLatin1String("standardFont"), standardFont)); + standardFont = qvariant_cast(settings.value(QLatin1String("standardFont"), standardFont)); defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); - fixedFont = qVariantValue(settings.value(QLatin1String("fixedFont"), fixedFont)); + fixedFont = qvariant_cast(settings.value(QLatin1String("fixedFont"), fixedFont)); defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); diff --git a/demos/browser/cookiejar.cpp b/demos/browser/cookiejar.cpp index 835b61b..d318e3a 100644 --- a/demos/browser/cookiejar.cpp +++ b/demos/browser/cookiejar.cpp @@ -186,7 +186,7 @@ void CookieJar::save() if (cookies.at(i).isSessionCookie()) cookies.removeAt(i); } - cookieSettings.setValue(QLatin1String("cookies"), qVariantFromValue >(cookies)); + cookieSettings.setValue(QLatin1String("cookies"), QVariant::fromValue >(cookies)); cookieSettings.beginGroup(QLatin1String("Exceptions")); cookieSettings.setValue(QLatin1String("block"), m_exceptions_block); cookieSettings.setValue(QLatin1String("allow"), m_exceptions_allow); diff --git a/demos/browser/settings.cpp b/demos/browser/settings.cpp index 5ceca67..d83e6a4 100644 --- a/demos/browser/settings.cpp +++ b/demos/browser/settings.cpp @@ -121,8 +121,8 @@ void SettingsDialog::loadFromSettings() // Appearance settings.beginGroup(QLatin1String("websettings")); - fixedFont = qVariantValue(settings.value(QLatin1String("fixedFont"), fixedFont)); - standardFont = qVariantValue(settings.value(QLatin1String("standardFont"), standardFont)); + fixedFont = qvariant_cast(settings.value(QLatin1String("fixedFont"), fixedFont)); + standardFont = qvariant_cast(settings.value(QLatin1String("standardFont"), standardFont)); standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); diff --git a/demos/embeddeddialogs/customproxy.cpp b/demos/embeddeddialogs/customproxy.cpp index bd56f5a..a715f5e 100644 --- a/demos/embeddeddialogs/customproxy.cpp +++ b/demos/embeddeddialogs/customproxy.cpp @@ -113,7 +113,7 @@ QVariant CustomProxy::itemChange(GraphicsItemChange change, const QVariant &valu { if (change == ItemChildAddedChange || change == ItemChildRemovedChange) { if (change == ItemChildAddedChange) { - currentPopup = qVariantValue(value); + currentPopup = qvariant_cast(value); currentPopup->setCacheMode(ItemCoordinateCache); if (scene()) currentPopup->installSceneEventFilter(this); diff --git a/demos/interview/model.cpp b/demos/interview/model.cpp index 840bc60..88f200d 100644 --- a/demos/interview/model.cpp +++ b/demos/interview/model.cpp @@ -109,7 +109,7 @@ QVariant Model::headerData(int section, Qt::Orientation orientation, int role) c if (role == Qt::DisplayRole) return QString::number(section); if (role == Qt::DecorationRole) - return qVariantFromValue(services); + return QVariant::fromValue(services); return QAbstractItemModel::headerData(section, orientation, role); } diff --git a/demos/spectrum/app/settingsdialog.cpp b/demos/spectrum/app/settingsdialog.cpp index b5e8459..1f125c9 100644 --- a/demos/spectrum/app/settingsdialog.cpp +++ b/demos/spectrum/app/settingsdialog.cpp @@ -65,13 +65,13 @@ SettingsDialog::SettingsDialog( QAudioDeviceInfo device; foreach (device, availableInputDevices) m_inputDeviceComboBox->addItem(device.deviceName(), - qVariantFromValue(device)); + QVariant::fromValue(device)); foreach (device, availableOutputDevices) m_outputDeviceComboBox->addItem(device.deviceName(), - qVariantFromValue(device)); + QVariant::fromValue(device)); - m_windowFunctionComboBox->addItem(tr("None"), qVariantFromValue(int(NoWindow))); - m_windowFunctionComboBox->addItem("Hann", qVariantFromValue(int(HannWindow))); + m_windowFunctionComboBox->addItem(tr("None"), QVariant::fromValue(int(NoWindow))); + m_windowFunctionComboBox->addItem("Hann", QVariant::fromValue(int(HannWindow))); m_windowFunctionComboBox->setCurrentIndex(m_windowFunction); // Initialize default devices diff --git a/demos/spreadsheet/spreadsheetitem.cpp b/demos/spreadsheet/spreadsheetitem.cpp index e1f0143..93c82a0 100644 --- a/demos/spreadsheet/spreadsheetitem.cpp +++ b/demos/spreadsheet/spreadsheetitem.cpp @@ -72,10 +72,10 @@ QVariant SpreadSheetItem::data(int role) const if (role == Qt::TextColorRole) { if (!isNumber) - return qVariantFromValue(QColor(Qt::black)); + return QVariant::fromValue(QColor(Qt::black)); else if (number < 0) - return qVariantFromValue(QColor(Qt::red)); - return qVariantFromValue(QColor(Qt::blue)); + return QVariant::fromValue(QColor(Qt::red)); + return QVariant::fromValue(QColor(Qt::blue)); } if (role == Qt::TextAlignmentRole) diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 3e7d33b..2ebdc7c 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -177,7 +177,7 @@ QtCore * Many optimisations. * Added QVariant::toFloat() and QVariant::toReal(). * Added QVariant(float) constructor. - * qvariant_cast and qVariantFromValue are now + * qvariant_cast and QVariant::fromValue are now identity functions. * Added support for math3d types. diff --git a/doc/src/examples/customtype.qdoc b/doc/src/examples/customtype.qdoc index e003129..0765c5f 100644 --- a/doc/src/examples/customtype.qdoc +++ b/doc/src/examples/customtype.qdoc @@ -117,7 +117,7 @@ \snippet examples/tools/customtype/main.cpp storing a custom value - Alternatively, the qVariantFromValue() and qVariantSetValue() functions + Alternatively, the QVariant::fromValue() and qVariantSetValue() functions can be used if you are using a compiler without support for member template functions. diff --git a/doc/src/snippets/accessibilityslidersnippet.cpp b/doc/src/snippets/accessibilityslidersnippet.cpp index 466579d..05cbe40 100644 --- a/doc/src/snippets/accessibilityslidersnippet.cpp +++ b/doc/src/snippets/accessibilityslidersnippet.cpp @@ -227,7 +227,7 @@ QVariant QAccessibleAbstractSlider::invokeMethodEx(Method method, int child, con case ListSupportedMethods: { QSet set; set << ListSupportedMethods; - return qVariantFromValue(set | qvariant_cast >( + return QVariant::fromValue(set | qvariant_cast >( QAccessibleWidgetEx::invokeMethodEx(method, child, params))); } default: diff --git a/doc/src/snippets/code/doc_src_qtscript.qdoc b/doc/src/snippets/code/doc_src_qtscript.qdoc index 8effdf3..a81029e 100644 --- a/doc/src/snippets/code/doc_src_qtscript.qdoc +++ b/doc/src/snippets/code/doc_src_qtscript.qdoc @@ -964,7 +964,7 @@ QScriptValue constructXmlStreamReader(QScriptContext *context, QScriptEngine *en XmlStreamReaderPointer pointer(reader); // store the shared pointer in the script object that we are constructing - return engine->newVariant(context->thisObject(), qVariantFromValue(pointer)); + return engine->newVariant(context->thisObject(), QVariant::fromValue(pointer)); } //! [93] diff --git a/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp b/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp index fd3f5d2..e81745c 100644 --- a/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp +++ b/doc/src/snippets/code/src_corelib_kernel_qvariant.cpp @@ -132,5 +132,5 @@ return QVariant::fromValue(s); //! [8] QObject *object = getObjectFromSomewhere(); -QVariant data = qVariantFromValue(object); +QVariant data = QVariant::fromValue(object); //! [8] diff --git a/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp b/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp index 139e0a3..ef5cfb2 100644 --- a/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp +++ b/doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp @@ -163,7 +163,7 @@ break; default: if (v.userType() == qMetaTypeId()) { - QXmlName n = qVariantValue(v); + QXmlName n = qvariant_cast(v); // process QXmlName n... } else { diff --git a/doc/src/xml-processing/xml-patterns.qdoc b/doc/src/xml-processing/xml-patterns.qdoc index dcf92f6..3e591da 100644 --- a/doc/src/xml-processing/xml-patterns.qdoc +++ b/doc/src/xml-processing/xml-patterns.qdoc @@ -415,7 +415,7 @@ slight-of-hand using the \l{QMetaType} {Qt metatype system}. We must modify our example to use a couple of template functions, a friend of QMetaType (qMetaTypeId()) and a friend of QVariant - (qVariantValue()): + (qvariant_cast()): \snippet doc/src/snippets/code/src_xmlpatterns_api_qxmlquery.cpp 6 diff --git a/examples/draganddrop/puzzle/pieceslist.cpp b/examples/draganddrop/puzzle/pieceslist.cpp index 77e8723..6e82145 100644 --- a/examples/draganddrop/puzzle/pieceslist.cpp +++ b/examples/draganddrop/puzzle/pieceslist.cpp @@ -103,7 +103,7 @@ void PiecesList::startDrag(Qt::DropActions /*supportedActions*/) QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); - QPixmap pixmap = qVariantValue(item->data(Qt::UserRole)); + QPixmap pixmap = qvariant_cast(item->data(Qt::UserRole)); QPoint location = item->data(Qt::UserRole+1).toPoint(); dataStream << pixmap << location; diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp index f09c552..e4fe633 100644 --- a/examples/graphicsview/diagramscene/mainwindow.cpp +++ b/examples/graphicsview/diagramscene/mainwindow.cpp @@ -224,7 +224,7 @@ void MainWindow::textColorChanged() textAction = qobject_cast(sender()); fontColorToolButton->setIcon(createColorToolButtonIcon( ":/images/textpointer.png", - qVariantValue(textAction->data()))); + qvariant_cast(textAction->data()))); textButtonTriggered(); } //! [12] @@ -235,7 +235,7 @@ void MainWindow::itemColorChanged() fillAction = qobject_cast(sender()); fillColorToolButton->setIcon(createColorToolButtonIcon( ":/images/floodfill.png", - qVariantValue(fillAction->data()))); + qvariant_cast(fillAction->data()))); fillButtonTriggered(); } //! [13] @@ -246,7 +246,7 @@ void MainWindow::lineColorChanged() lineAction = qobject_cast(sender()); lineColorToolButton->setIcon(createColorToolButtonIcon( ":/images/linecolor.png", - qVariantValue(lineAction->data()))); + qvariant_cast(lineAction->data()))); lineButtonTriggered(); } //! [14] @@ -254,21 +254,21 @@ void MainWindow::lineColorChanged() //! [15] void MainWindow::textButtonTriggered() { - scene->setTextColor(qVariantValue(textAction->data())); + scene->setTextColor(qvariant_cast(textAction->data())); } //! [15] //! [16] void MainWindow::fillButtonTriggered() { - scene->setItemColor(qVariantValue(fillAction->data())); + scene->setItemColor(qvariant_cast(fillAction->data())); } //! [16] //! [17] void MainWindow::lineButtonTriggered() { - scene->setLineColor(qVariantValue(lineAction->data())); + scene->setLineColor(qvariant_cast(lineAction->data())); } //! [17] diff --git a/examples/graphicsview/dragdroprobot/robot.cpp b/examples/graphicsview/dragdroprobot/robot.cpp index 44ecda3..caca309 100644 --- a/examples/graphicsview/dragdroprobot/robot.cpp +++ b/examples/graphicsview/dragdroprobot/robot.cpp @@ -77,7 +77,7 @@ void RobotPart::dropEvent(QGraphicsSceneDragDropEvent *event) { dragOver = false; if (event->mimeData()->hasColor()) - color = qVariantValue(event->mimeData()->colorData()); + color = qvariant_cast(event->mimeData()->colorData()); update(); } //! [3] @@ -139,7 +139,7 @@ void RobotHead::dropEvent(QGraphicsSceneDragDropEvent *event) { if (event->mimeData()->hasImage()) { dragOver = false; - pixmap = qVariantValue(event->mimeData()->imageData()); + pixmap = qvariant_cast(event->mimeData()->imageData()); update(); } else { RobotPart::dropEvent(event); diff --git a/examples/graphicsview/padnavigator/padnavigator.cpp b/examples/graphicsview/padnavigator/padnavigator.cpp index 4988664..3ea68de 100644 --- a/examples/graphicsview/padnavigator/padnavigator.cpp +++ b/examples/graphicsview/padnavigator/padnavigator.cpp @@ -135,9 +135,9 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent) smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad); smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad); - smoothFlipScale->setKeyValueAt(0, qVariantValue(1.0)); - smoothFlipScale->setKeyValueAt(0.5, qVariantValue(0.7)); - smoothFlipScale->setKeyValueAt(1, qVariantValue(1.0)); + smoothFlipScale->setKeyValueAt(0, qvariant_cast(1.0)); + smoothFlipScale->setKeyValueAt(0.5, qvariant_cast(0.7)); + smoothFlipScale->setKeyValueAt(1, qvariant_cast(1.0)); flipAnimation->addAnimation(smoothFlipRotation); flipAnimation->addAnimation(smoothFlipScale); flipAnimation->addAnimation(smoothFlipXRotation); @@ -172,13 +172,13 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent) frontState->assignProperty(pad, "fill", false); frontState->assignProperty(splash, "opacity", 0.0); frontState->assignProperty(backItem, "visible", false); - frontState->assignProperty(flipRotation, "angle", qVariantValue(0.0)); + frontState->assignProperty(flipRotation, "angle", qvariant_cast(0.0)); frontState->assignProperty(selectionItem, "visible", true); backState->assignProperty(pad, "fill", true); backState->assignProperty(backItem, "visible", true); - backState->assignProperty(xRotation, "angle", qVariantValue(0.0)); - backState->assignProperty(yRotation, "angle", qVariantValue(0.0)); - backState->assignProperty(flipRotation, "angle", qVariantValue(180.0)); + backState->assignProperty(xRotation, "angle", qvariant_cast(0.0)); + backState->assignProperty(yRotation, "angle", qvariant_cast(0.0)); + backState->assignProperty(flipRotation, "angle", qvariant_cast(180.0)); backState->assignProperty(selectionItem, "visible", false); stateMachine->addDefaultAnimation(smoothXRotation); stateMachine->addDefaultAnimation(smoothYRotation); diff --git a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp index 1af5831..4f4a954 100644 --- a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp +++ b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp @@ -50,7 +50,7 @@ ColorListEditor::ColorListEditor(QWidget *widget) : QComboBox(widget) //! [0] QColor ColorListEditor::color() const { - return qVariantValue(itemData(currentIndex(), Qt::DecorationRole)); + return qvariant_cast(itemData(currentIndex(), Qt::DecorationRole)); } //! [0] diff --git a/examples/itemviews/puzzle/piecesmodel.cpp b/examples/itemviews/puzzle/piecesmodel.cpp index e110cf1..e55663b 100644 --- a/examples/itemviews/puzzle/piecesmodel.cpp +++ b/examples/itemviews/puzzle/piecesmodel.cpp @@ -124,7 +124,7 @@ QMimeData *PiecesModel::mimeData(const QModelIndexList &indexes) const foreach (QModelIndex index, indexes) { if (index.isValid()) { - QPixmap pixmap = qVariantValue(data(index, Qt::UserRole)); + QPixmap pixmap = qvariant_cast(data(index, Qt::UserRole)); QPoint location = data(index, Qt::UserRole+1).toPoint(); stream << pixmap << location; } diff --git a/examples/itemviews/stardelegate/main.cpp b/examples/itemviews/stardelegate/main.cpp index d9f655d..444017e 100644 --- a/examples/itemviews/stardelegate/main.cpp +++ b/examples/itemviews/stardelegate/main.cpp @@ -71,7 +71,7 @@ void populateTableWidget(QTableWidget *tableWidget) QTableWidgetItem *item2 = new QTableWidgetItem(staticData[row].artist); QTableWidgetItem *item3 = new QTableWidgetItem; item3->setData(0, - qVariantFromValue(StarRating(staticData[row].rating))); + QVariant::fromValue(StarRating(staticData[row].rating))); tableWidget->setItem(row, 0, item0); tableWidget->setItem(row, 1, item1); diff --git a/examples/itemviews/stardelegate/stardelegate.cpp b/examples/itemviews/stardelegate/stardelegate.cpp index 44dd54f..ebb2e38 100644 --- a/examples/itemviews/stardelegate/stardelegate.cpp +++ b/examples/itemviews/stardelegate/stardelegate.cpp @@ -48,8 +48,8 @@ void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (qVariantCanConvert(index.data())) { - StarRating starRating = qVariantValue(index.data()); + if (index.data().canConvert()) { + StarRating starRating = qvariant_cast(index.data()); if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); @@ -66,8 +66,8 @@ void StarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QSize StarDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (qVariantCanConvert(index.data())) { - StarRating starRating = qVariantValue(index.data()); + if (index.data().canConvert()) { + StarRating starRating = qvariant_cast(index.data()); return starRating.sizeHint(); } else { return QStyledItemDelegate::sizeHint(option, index); @@ -81,7 +81,7 @@ QWidget *StarDelegate::createEditor(QWidget *parent, const QModelIndex &index) const { - if (qVariantCanConvert(index.data())) { + if (index.data().canConvert()) { StarEditor *editor = new StarEditor(parent); connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor())); @@ -96,8 +96,8 @@ QWidget *StarDelegate::createEditor(QWidget *parent, void StarDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { - if (qVariantCanConvert(index.data())) { - StarRating starRating = qVariantValue(index.data()); + if (index.data().canConvert()) { + StarRating starRating = qvariant_cast(index.data()); StarEditor *starEditor = qobject_cast(editor); starEditor->setStarRating(starRating); } else { @@ -110,9 +110,9 @@ void StarDelegate::setEditorData(QWidget *editor, void StarDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { - if (qVariantCanConvert(index.data())) { + if (index.data().canConvert()) { StarEditor *starEditor = qobject_cast(editor); - model->setData(index, qVariantFromValue(starEditor->starRating())); + model->setData(index, QVariant::fromValue(starEditor->starRating())); } else { QStyledItemDelegate::setModelData(editor, model, index); } diff --git a/examples/multimedia/audiodevices/audiodevices.cpp b/examples/multimedia/audiodevices/audiodevices.cpp index 5ab4918..6eb0763 100644 --- a/examples/multimedia/audiodevices/audiodevices.cpp +++ b/examples/multimedia/audiodevices/audiodevices.cpp @@ -155,7 +155,7 @@ void AudioTest::modeChanged(int idx) deviceBox->clear(); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(mode)) - deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); + deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); deviceBox->setCurrentIndex(0); deviceChanged(0); diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 4e5f2a3..cf18335 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -237,7 +237,7 @@ void InputTest::initializeWindow() m_deviceBox = new QComboBox(this); QList devices = QAudioDeviceInfo::availableDevices(QAudio::AudioInput); for(int i = 0; i < devices.size(); ++i) - m_deviceBox->addItem(devices.at(i).deviceName(), qVariantFromValue(devices.at(i))); + m_deviceBox->addItem(devices.at(i).deviceName(), QVariant::fromValue(devices.at(i))); connect(m_deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int))); layout->addWidget(m_deviceBox); diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index bc2324e..4e74a25 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -176,7 +176,7 @@ void AudioTest::initializeWindow() m_deviceBox = new QComboBox(this); foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) - m_deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo)); + m_deviceBox->addItem(deviceInfo.deviceName(), QVariant::fromValue(deviceInfo)); connect(m_deviceBox,SIGNAL(activated(int)),SLOT(deviceChanged(int))); layout->addWidget(m_deviceBox); diff --git a/examples/network/torrent/bencodeparser.cpp b/examples/network/torrent/bencodeparser.cpp index d6b6078..aa498d6 100644 --- a/examples/network/torrent/bencodeparser.cpp +++ b/examples/network/torrent/bencodeparser.cpp @@ -171,7 +171,7 @@ bool BencodeParser::getList(QList *list) else if (getList(&tmpList)) tmp << tmpList; else if (getDictionary(&dictionary)) - tmp << qVariantFromValue >(dictionary); + tmp << QVariant::fromValue >(dictionary); else { errString = QString("error at index %1").arg(index); return false; @@ -217,7 +217,7 @@ bool BencodeParser::getDictionary(QMap *dictionary) else if (getList(&tmpList)) tmp.insert(key, tmpList); else if (getDictionary(&dictionary)) - tmp.insert(key, qVariantFromValue >(dictionary)); + tmp.insert(key, QVariant::fromValue >(dictionary)); else { errString = QString("error at index %1").arg(index); return false; diff --git a/examples/network/torrent/metainfo.cpp b/examples/network/torrent/metainfo.cpp index a6e7511..a7cd978 100644 --- a/examples/network/torrent/metainfo.cpp +++ b/examples/network/torrent/metainfo.cpp @@ -83,7 +83,7 @@ bool MetaInfo::parse(const QByteArray &data) if (!dict.contains("info")) return false; - QMap info = qVariantValue(dict.value("info")); + QMap info = qvariant_cast(dict.value("info")); if (info.contains("files")) { metaInfoFileForm = MultiFileForm; @@ -91,7 +91,7 @@ bool MetaInfo::parse(const QByteArray &data) QList files = info.value("files").toList(); for (int i = 0; i < files.size(); ++i) { - QMap file = qVariantValue(files.at(i)); + QMap file = qvariant_cast(files.at(i)); QList pathElements = file.value("path").toList(); QByteArray path; foreach (QVariant p, pathElements) { diff --git a/examples/network/torrent/trackerclient.cpp b/examples/network/torrent/trackerclient.cpp index 61d7e95..07194fa 100644 --- a/examples/network/torrent/trackerclient.cpp +++ b/examples/network/torrent/trackerclient.cpp @@ -210,7 +210,7 @@ void TrackerClient::httpRequestDone(bool error) QList peerTmp = peerEntry.toList(); for (int i = 0; i < peerTmp.size(); ++i) { TorrentPeer tmp; - QMap peer = qVariantValue >(peerTmp.at(i)); + QMap peer = qvariant_cast >(peerTmp.at(i)); tmp.id = QString::fromUtf8(peer.value("peer id").toByteArray()); tmp.address.setAddress(QString::fromUtf8(peer.value("ip").toByteArray())); tmp.port = peer.value("port").toInt(); diff --git a/examples/richtext/textobject/svgtextobject.cpp b/examples/richtext/textobject/svgtextobject.cpp index c84725d..2442623 100644 --- a/examples/richtext/textobject/svgtextobject.cpp +++ b/examples/richtext/textobject/svgtextobject.cpp @@ -48,7 +48,7 @@ QSizeF SvgTextObject::intrinsicSize(QTextDocument * /*doc*/, int /*posInDocument*/, const QTextFormat &format) { - QImage bufferedImage = qVariantValue(format.property(Window::SvgData)); + QImage bufferedImage = qvariant_cast(format.property(Window::SvgData)); QSize size = bufferedImage.size(); if (size.height() > 25) @@ -63,7 +63,7 @@ void SvgTextObject::drawObject(QPainter *painter, const QRectF &rect, QTextDocument * /*doc*/, int /*posInDocument*/, const QTextFormat &format) { - QImage bufferedImage = qVariantValue(format.property(Window::SvgData)); + QImage bufferedImage = qvariant_cast(format.property(Window::SvgData)); painter->drawImage(rect, bufferedImage); } diff --git a/examples/script/context2d/context2d.cpp b/examples/script/context2d/context2d.cpp index c408736..49fc3bc 100644 --- a/examples/script/context2d/context2d.cpp +++ b/examples/script/context2d/context2d.cpp @@ -278,7 +278,7 @@ QVariant Context2D::strokeStyle() const void Context2D::setStrokeStyle(const QVariant &style) { - if (qVariantCanConvert(style)) { + if (style.canConvert()) { CanvasGradient cg = qvariant_cast(style); m_state.strokeStyle = cg.value; } else { @@ -296,7 +296,7 @@ QVariant Context2D::fillStyle() const //! [3] void Context2D::setFillStyle(const QVariant &style) { - if (qVariantCanConvert(style)) { + if (style.canConvert()) { CanvasGradient cg = qvariant_cast(style); m_state.fillStyle = cg.value; } else { diff --git a/examples/script/context2d/domimage.cpp b/examples/script/context2d/domimage.cpp index 801e1a2..f655c6f 100644 --- a/examples/script/context2d/domimage.cpp +++ b/examples/script/context2d/domimage.cpp @@ -84,7 +84,7 @@ static QScriptValue Image(QScriptContext *context, QScriptEngine *env) { QScriptValue val = context->thisObject(); DomImage *image = new DomImage(); - QScriptValue klass = env->newVariant(qVariantFromValue(image)); + QScriptValue klass = env->newVariant(QVariant::fromValue(image)); klass.setPrototype(DomImage::s_self); return klass; } diff --git a/examples/script/customclass/bytearrayclass.cpp b/examples/script/customclass/bytearrayclass.cpp index 5ecee0a..0a1ad2d 100644 --- a/examples/script/customclass/bytearrayclass.cpp +++ b/examples/script/customclass/bytearrayclass.cpp @@ -204,7 +204,7 @@ QScriptValue ByteArrayClass::newInstance(int size) //! [1] QScriptValue ByteArrayClass::newInstance(const QByteArray &ba) { - QScriptValue data = engine()->newVariant(qVariantFromValue(ba)); + QScriptValue data = engine()->newVariant(QVariant::fromValue(ba)); return engine()->newObject(this, data); } //! [1] @@ -228,7 +228,7 @@ QScriptValue ByteArrayClass::toScriptValue(QScriptEngine *eng, const QByteArray QScriptValue ctor = eng->globalObject().property("ByteArray"); ByteArrayClass *cls = qscriptvalue_cast(ctor.data()); if (!cls) - return eng->newVariant(qVariantFromValue(ba)); + return eng->newVariant(QVariant::fromValue(ba)); return cls->newInstance(ba); } diff --git a/examples/sql/querymodel/customsqlmodel.cpp b/examples/sql/querymodel/customsqlmodel.cpp index f444acf..75d16b4 100644 --- a/examples/sql/querymodel/customsqlmodel.cpp +++ b/examples/sql/querymodel/customsqlmodel.cpp @@ -58,7 +58,7 @@ QVariant CustomSqlModel::data(const QModelIndex &index, int role) const return value.toString().toUpper(); } if (role == Qt::TextColorRole && index.column() == 1) - return qVariantFromValue(QColor(Qt::blue)); + return QVariant::fromValue(QColor(Qt::blue)); return value; } //! [0] diff --git a/examples/tools/customtype/main.cpp b/examples/tools/customtype/main.cpp index 229cd18..430613a 100644 --- a/examples/tools/customtype/main.cpp +++ b/examples/tools/customtype/main.cpp @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) //! [retrieving a custom value] Message retrieved = stored.value(); qDebug() << "Retrieved:" << retrieved; - retrieved = qVariantValue(stored); + retrieved = qvariant_cast(stored); qDebug() << "Retrieved:" << retrieved; //! [retrieving a custom value] diff --git a/examples/widgets/validators/localeselector.cpp b/examples/widgets/validators/localeselector.cpp index e4aae1a..0a48d66 100644 --- a/examples/widgets/validators/localeselector.cpp +++ b/examples/widgets/validators/localeselector.cpp @@ -294,7 +294,7 @@ LocaleSelector::LocaleSelector(QWidget *parent) QString text = QLocale::languageToString(QLocale::Language(l.lang)) + QLatin1Char('/') + QLocale::countryToString(QLocale::Country(l.country)); - addItem(text, qVariantFromValue(l)); + addItem(text, QVariant::fromValue(l)); } setCurrentIndex(curIndex); @@ -307,6 +307,6 @@ void LocaleSelector::emitLocaleSelected(int index) QVariant v = itemData(index); if (!v.isValid()) return; - SupportedLocale l = qVariantValue(v); + SupportedLocale l = qvariant_cast(v); emit localeSelected(QLocale(QLocale::Language(l.lang), QLocale::Country(l.country))); } diff --git a/src/3rdparty/phonon/phonon/mediacontroller.cpp b/src/3rdparty/phonon/phonon/mediacontroller.cpp index 59fd5c7..9f651d6 100644 --- a/src/3rdparty/phonon/phonon/mediacontroller.cpp +++ b/src/3rdparty/phonon/phonon/mediacontroller.cpp @@ -216,14 +216,14 @@ void MediaController::setCurrentAudioChannel(const Phonon::AudioChannelDescripti { IFACE; iface->interfaceCall(AddonInterface::AudioChannelInterface, - AddonInterface::setCurrentAudioChannel, QList() << qVariantFromValue(stream)); + AddonInterface::setCurrentAudioChannel, QList() << QVariant::fromValue(stream)); } void MediaController::setCurrentSubtitle(const Phonon::SubtitleDescription &stream) { IFACE; iface->interfaceCall(AddonInterface::SubtitleInterface, - AddonInterface::setCurrentSubtitle, QList() << qVariantFromValue(stream)); + AddonInterface::setCurrentSubtitle, QList() << QVariant::fromValue(stream)); } #undef IFACE diff --git a/src/3rdparty/phonon/phonon/qsettingsgroup_p.h b/src/3rdparty/phonon/phonon/qsettingsgroup_p.h index f28ecaa..f25b15e 100644 --- a/src/3rdparty/phonon/phonon/qsettingsgroup_p.h +++ b/src/3rdparty/phonon/phonon/qsettingsgroup_p.h @@ -54,7 +54,7 @@ class QSettingsGroup template inline T value(const QString &key, const T &def) const { - return qvariant_cast(value(key, qVariantFromValue(def))); + return qvariant_cast(value(key, QVariant::fromValue(def))); } inline QVariant value(const QString &key, const QVariant &def) const @@ -66,7 +66,7 @@ class QSettingsGroup inline void setValue(const QString &key, const T &value) { Q_ASSERT(m_mutableSettings); - m_mutableSettings->setValue(m_group + key, qVariantFromValue(value)); + m_mutableSettings->setValue(m_group + key, QVariant::fromValue(value)); } inline void removeEntry(const QString &key) diff --git a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp index a39dc7a..44c41c4 100644 --- a/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp +++ b/src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.cpp @@ -565,7 +565,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type if (qstring.mid(lastSlash + 1).contains(QLatin1Char('i'))) realRe.setCaseSensitivity(Qt::CaseInsensitive); - ret = qVariantFromValue(realRe); + ret = QVariant::fromValue(realRe); dist = 0; } else { qConvDebug() << "couldn't parse a JS regexp"; @@ -576,7 +576,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type QRegExp re(qstring); if (re.isValid()) { - ret = qVariantFromValue(re); + ret = QVariant::fromValue(re); dist = 10; } } @@ -588,7 +588,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type if (qtinst) { if (qtinst->getObject()) { qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject(); - ret = qVariantFromValue(qtinst->getObject()); + ret = QVariant::fromValue(qtinst->getObject()); qConvDebug() << ret; dist = 0; } else { @@ -599,7 +599,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type } } else if (type == Null) { QObject* nullobj = 0; - ret = qVariantFromValue(nullobj); + ret = QVariant::fromValue(nullobj); dist = 0; } else { qConvDebug() << "previous type was not an object:" << type; @@ -612,7 +612,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type if (qtinst) { if (qtinst->getObject()) { qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject(); - ret = qVariantFromValue((void *)qtinst->getObject()); + ret = QVariant::fromValue((void *)qtinst->getObject()); qConvDebug() << ret; dist = 0; } else { @@ -622,7 +622,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type qConvDebug() << "wasn't a qtinstance"; } } else if (type == Null) { - ret = qVariantFromValue((void*)0); + ret = QVariant::fromValue((void*)0); dist = 0; } else if (type == Number) { // I don't think that converting a double to a pointer is a wise diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp index 5db94a8..5004b67 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp @@ -185,7 +185,7 @@ void MediaPlayerPrivate::load(const String& url) // Don't set the header if there are no cookies. // This prevents a warning from being emitted. if (!cookies.isEmpty()) - request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies)); + request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies)); // Set the refferer, but not when requesting insecure content from a secure page QUrl documentUrl = QUrl(QString(document->documentURI())); diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp index e584f97..dcae35f 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp @@ -306,7 +306,7 @@ public: } Q_INVOKABLE QObjectList myInvokableWithQObjectListArg(const QObjectList &lst) { m_qtFunctionInvoked = 14; - m_actuals << qVariantFromValue(lst); + m_actuals << QVariant::fromValue(lst); return lst; } Q_INVOKABLE QVariant myInvokableWithVariantArg(const QVariant &v) { @@ -321,38 +321,38 @@ public: } Q_INVOKABLE QList myInvokableWithListOfIntArg(const QList &lst) { m_qtFunctionInvoked = 17; - m_actuals << qVariantFromValue(lst); + m_actuals << QVariant::fromValue(lst); return lst; } Q_INVOKABLE QObject* myInvokableWithQObjectStarArg(QObject* obj) { m_qtFunctionInvoked = 18; - m_actuals << qVariantFromValue(obj); + m_actuals << QVariant::fromValue(obj); return obj; } Q_INVOKABLE QBrush myInvokableWithQBrushArg(const QBrush &brush) { m_qtFunctionInvoked = 19; - m_actuals << qVariantFromValue(brush); + m_actuals << QVariant::fromValue(brush); return brush; } Q_INVOKABLE void myInvokableWithBrushStyleArg(Qt::BrushStyle style) { m_qtFunctionInvoked = 43; - m_actuals << qVariantFromValue(style); + m_actuals << QVariant::fromValue(style); } Q_INVOKABLE void myInvokableWithVoidStarArg(void* arg) { m_qtFunctionInvoked = 44; - m_actuals << qVariantFromValue(arg); + m_actuals << QVariant::fromValue(arg); } Q_INVOKABLE void myInvokableWithAmbiguousArg(int arg) { m_qtFunctionInvoked = 45; - m_actuals << qVariantFromValue(arg); + m_actuals << QVariant::fromValue(arg); } Q_INVOKABLE void myInvokableWithAmbiguousArg(uint arg) { m_qtFunctionInvoked = 46; - m_actuals << qVariantFromValue(arg); + m_actuals << QVariant::fromValue(arg); } Q_INVOKABLE void myInvokableWithDefaultArgs(int arg1, const QString &arg2 = "") { m_qtFunctionInvoked = 47; - m_actuals << qVariantFromValue(arg1) << qVariantFromValue(arg2); + m_actuals << QVariant::fromValue(arg1) << qVariantFromValue(arg2); } Q_INVOKABLE QObject& myInvokableReturningRef() { m_qtFunctionInvoked = 48; @@ -364,11 +364,11 @@ public: } Q_INVOKABLE void myInvokableWithPointArg(const QPoint &arg) { const_cast(this)->m_qtFunctionInvoked = 50; - m_actuals << qVariantFromValue(arg); + m_actuals << QVariant::fromValue(arg); } Q_INVOKABLE void myInvokableWithPointArg(const QPointF &arg) { const_cast(this)->m_qtFunctionInvoked = 51; - m_actuals << qVariantFromValue(arg); + m_actuals << QVariant::fromValue(arg); } Q_INVOKABLE void myInvokableWithBoolArg(bool arg) { m_qtFunctionInvoked = 52; @@ -416,7 +416,7 @@ public Q_SLOTS: } void myOverloadedSlot(QObject* arg) { m_qtFunctionInvoked = 41; - m_actuals << qVariantFromValue(arg); + m_actuals << QVariant::fromValue(arg); } void myOverloadedSlot(bool arg) { m_qtFunctionInvoked = 25; @@ -818,7 +818,7 @@ void tst_QWebFrame::getSetStaticProperty() QCOMPARE(evalJS("myObject.variantProperty === 'bar'"), sTrue); m_myObject->setVariantProperty(42); QCOMPARE(evalJS("myObject.variantProperty === 42"), sTrue); - m_myObject->setVariantProperty(qVariantFromValue(QBrush())); + m_myObject->setVariantProperty(QVariant::fromValue(QBrush())); //XFAIL // QCOMPARE(evalJS("typeof myObject.variantProperty"), sVariant); @@ -1240,7 +1240,7 @@ void tst_QWebFrame::callQtInvokable() /* XFAIL - variant support m_myObject->resetQtFunctionInvoked(); { - m_myObject->setVariantProperty(qVariantFromValue(QBrush())); + m_myObject->setVariantProperty(QVariant::fromValue(QBrush())); QVariant ret = evalJS("myObject.myInvokableWithVariantArg(myObject.variantProperty)"); QVERIFY(ret.isVariant()); QCOMPARE(m_myObject->qtFunctionInvoked(), 15); diff --git a/src/activeqt/container/qaxbase.cpp b/src/activeqt/container/qaxbase.cpp index 7692749..806e2b1 100644 --- a/src/activeqt/container/qaxbase.cpp +++ b/src/activeqt/container/qaxbase.cpp @@ -3540,7 +3540,7 @@ int QAxBase::internalProperty(QMetaObject::Call call, int index, void **v) proptype = 0; } else if (t == QVariant::UserType) { qvar = QVariant(qRegisterMetaType(prop.typeName()), (void**)v[0]); -// qVariantSetValue(qvar, *(void**)v[0], prop.typeName()); +// qvar.setValue(*(void**)v[0], prop.typeName()); } else { proptype = d->metaObject()->propertyType(propname); qvar = QVariant(t, v[0]); @@ -3628,9 +3628,9 @@ int QAxBase::internalInvoke(QMetaObject::Call call, int index, void **v) if (!qvar.isValid()) { if (type == "IDispatch*") - qVariantSetValue(qvar, *(IDispatch**)v[p+1]); + qvar.setValue(*(IDispatch**)v[p+1]); else if (type == "IUnknown*") - qVariantSetValue(qvar, *(IUnknown**)v[p+1]); + qvar.setValue(*(IUnknown**)v[p+1]); else if (type == "QVariant") qvar = *(QVariant*)v[p + 1]; else if (mo->indexOfEnumerator(type) != -1) @@ -4395,15 +4395,15 @@ QVariant QAxBase::asVariant() const QByteArray cn(className()); if (cn == "QAxObject" || cn == "QAxWidget" || cn == "QAxBase") { if (d->dispatch()) - qVariantSetValue(qvar, d->dispatch()); + qvar.setValue(d->dispatch()); else if (d->ptr) - qVariantSetValue(qvar, d->ptr); + qvar.setValue(d->ptr); } else { cn = cn.mid(cn.lastIndexOf(':') + 1); QObject *object = qObject(); if (QMetaType::type(cn)) qvar = QVariant(qRegisterMetaType(cn + '*'), &object); -// qVariantSetValue(qvar, qObject(), cn + '*'); +// qvar.setValue(qObject(), cn + '*'); } return qvar; diff --git a/src/activeqt/control/qaxserverbase.cpp b/src/activeqt/control/qaxserverbase.cpp index 4d2d2f9..32e2cf2 100644 --- a/src/activeqt/control/qaxserverbase.cpp +++ b/src/activeqt/control/qaxserverbase.cpp @@ -2047,10 +2047,10 @@ int QAxServerBase::qt_metacall(QMetaObject::Call call, int index, void **argv) if (vt == QVariant::UserType) { if (ptype.endsWith('*')) { variant = QVariant(QMetaType::type(ptype), (void**)argv[p+1]); - // qVariantSetValue(variant, *(void**)(argv[p + 1]), ptype); + // variant.setValue(*(void**)(argv[p + 1]), ptype); } else { variant = QVariant(QMetaType::type(ptype), argv[p+1]); - // qVariantSetValue(variant, argv[p + 1], ptype); + // variant.setValue(argv[p + 1], ptype); } } else { variant = QVariant(vt, argv[p + 1]); @@ -2537,7 +2537,7 @@ HRESULT WINAPI QAxServerBase::Invoke(DISPID dispidMember, REFIID riid, if (!type.isEmpty() && pvarResult) { if (!varp[0].isValid() && type != "QVariant") varp[0] = QVariant(QMetaType::type(type), argv_pointer); -// qVariantSetValue(varp[0], argv_pointer[0], type); +// varp[0].setValue(argv_pointer[0], type); ok = QVariantToVARIANT(varp[0], *pvarResult, type); } } @@ -3312,7 +3312,7 @@ HRESULT WINAPI QAxServerBase::OnAmbientPropertyChange(DISPID dispID) break; { QVariant qvar = VARIANTToQVariant(var, "QFont", QVariant::Font); - QFont qfont = qVariantValue(qvar); + QFont qfont = qvariant_cast(qvar); qt.widget->setFont(qfont); } break; diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index 0cfc7eb..7b2e802 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -954,20 +954,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint break; case VT_I4: if (type == QVariant::Color || (!type && typeName == "QColor")) - var = qVariantFromValue(OLEColorToQColor(arg.lVal)); + var = QVariant::fromValue(OLEColorToQColor(arg.lVal)); #ifndef QT_NO_CURSOR else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*"))) - var = qVariantFromValue(QCursor(static_cast(arg.lVal))); + var = QVariant::fromValue(QCursor(static_cast(arg.lVal))); #endif else var = (int)arg.lVal; break; case VT_I4|VT_BYREF: if (type == QVariant::Color || (!type && typeName == "QColor")) - var = qVariantFromValue(OLEColorToQColor((int)*arg.plVal)); + var = QVariant::fromValue(OLEColorToQColor((int)*arg.plVal)); #ifndef QT_NO_CURSOR else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*"))) - var = qVariantFromValue(QCursor(static_cast(*arg.plVal))); + var = QVariant::fromValue(QCursor(static_cast(*arg.plVal))); #endif else var = (int)*arg.plVal; @@ -992,20 +992,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint break; case VT_UI4: if (type == QVariant::Color || (!type && typeName == "QColor")) - var = qVariantFromValue(OLEColorToQColor(arg.ulVal)); + var = QVariant::fromValue(OLEColorToQColor(arg.ulVal)); #ifndef QT_NO_CURSOR else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*"))) - var = qVariantFromValue(QCursor(static_cast(arg.ulVal))); + var = QVariant::fromValue(QCursor(static_cast(arg.ulVal))); #endif else var = (int)arg.ulVal; break; case VT_UI4|VT_BYREF: if (type == QVariant::Color || (!type && typeName == "QColor")) - var = qVariantFromValue(OLEColorToQColor((uint)*arg.pulVal)); + var = QVariant::fromValue(OLEColorToQColor((uint)*arg.pulVal)); #ifndef QT_NO_CURSOR else if (type == QVariant::Cursor || (!type && (typeName == "QCursor" || typeName == "QCursor*"))) - var = qVariantFromValue(QCursor(static_cast(*arg.pulVal))); + var = QVariant::fromValue(QCursor(static_cast(*arg.pulVal))); #endif else var = (int)*arg.pulVal; @@ -1084,20 +1084,20 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint if (disp) disp->QueryInterface(IID_IFont, (void**)&ifont); if (ifont) { - var = qVariantFromValue(IFontToQFont(ifont)); + var = QVariant::fromValue(IFontToQFont(ifont)); ifont->Release(); } else { - var = qVariantFromValue(QFont()); + var = QVariant::fromValue(QFont()); } } else if (type == QVariant::Pixmap || (!type && (typeName == "QPixmap" || typeName == "QPixmap*"))) { IPicture *ipic = 0; if (disp) disp->QueryInterface(IID_IPicture, (void**)&ipic); if (ipic) { - var = qVariantFromValue(IPictureToQPixmap(ipic)); + var = QVariant::fromValue(IPictureToQPixmap(ipic)); ipic->Release(); } else { - var = qVariantFromValue(QPixmap()); + var = QVariant::fromValue(QPixmap()); } } else { #ifdef QAX_SERVER @@ -1118,7 +1118,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint #ifndef QAX_SERVER if (typeName == "QVariant") { QAxObject *object = new QAxObject(disp); - var = qVariantFromValue(object); + var = QVariant::fromValue(object); } else if (typeName != "IDispatch*" && QMetaType::type(typeName)) { QByteArray typeNameStr = QByteArray(typeName); int pIndex = typeName.lastIndexOf('*'); @@ -1145,7 +1145,7 @@ QVariant VARIANTToQVariant(const VARIANT &arg, const QByteArray &typeName, uint unkn = *arg.ppunkVal; else unkn = arg.punkVal; - qVariantSetValue(var, unkn); + var.setValue(unkn); } break; case VT_ARRAY|VT_VARIANT: diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 4e9c1ad..9ff0ff1 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -208,7 +208,7 @@ bool QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const Q QLatin1String(DBUS_INTERFACE_PROPERTIES), QLatin1String("Set")); QDBusMessagePrivate::setParametersValidated(msg, true); - msg << interface << QString::fromUtf8(mp.name()) << qVariantFromValue(QDBusVariant(value)); + msg << interface << QString::fromUtf8(mp.name()) << QVariant::fromValue(QDBusVariant(value)); QDBusMessage reply = connection.call(msg, QDBus::Block); if (reply.type() != QDBusMessage::ReplyMessage) { diff --git a/src/dbus/qdbusdemarshaller.cpp b/src/dbus/qdbusdemarshaller.cpp index 6e19218..0df4c6b 100644 --- a/src/dbus/qdbusdemarshaller.cpp +++ b/src/dbus/qdbusdemarshaller.cpp @@ -188,11 +188,11 @@ QVariant QDBusDemarshaller::toVariantInternal() { switch (q_dbus_message_iter_get_arg_type(&iterator)) { case DBUS_TYPE_BYTE: - return qVariantFromValue(toByte()); + return QVariant::fromValue(toByte()); case DBUS_TYPE_INT16: - return qVariantFromValue(toShort()); + return QVariant::fromValue(toShort()); case DBUS_TYPE_UINT16: - return qVariantFromValue(toUShort()); + return QVariant::fromValue(toUShort()); case DBUS_TYPE_INT32: return toInt(); case DBUS_TYPE_UINT32: @@ -208,11 +208,11 @@ QVariant QDBusDemarshaller::toVariantInternal() case DBUS_TYPE_STRING: return toString(); case DBUS_TYPE_OBJECT_PATH: - return qVariantFromValue(toObjectPath()); + return QVariant::fromValue(toObjectPath()); case DBUS_TYPE_SIGNATURE: - return qVariantFromValue(toSignature()); + return QVariant::fromValue(toSignature()); case DBUS_TYPE_VARIANT: - return qVariantFromValue(toVariant()); + return QVariant::fromValue(toVariant()); case DBUS_TYPE_ARRAY: switch (q_dbus_message_iter_get_element_type(&iterator)) { @@ -222,14 +222,14 @@ QVariant QDBusDemarshaller::toVariantInternal() case DBUS_TYPE_STRING: return toStringList(); case DBUS_TYPE_DICT_ENTRY: - return qVariantFromValue(duplicate()); + return QVariant::fromValue(duplicate()); default: - return qVariantFromValue(duplicate()); + return QVariant::fromValue(duplicate()); } case DBUS_TYPE_STRUCT: - return qVariantFromValue(duplicate()); + return QVariant::fromValue(duplicate()); default: qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'", diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 7951177..b479b32 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -806,14 +806,14 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu slotData.slotIdx = -1; slotData.metaTypes.clear(); slotCache.hash.insert(cacheKey, slotData); - object->setProperty(cachePropertyName, qVariantFromValue(slotCache)); + object->setProperty(cachePropertyName, QVariant::fromValue(slotCache)); return false; } } // save to the cache slotCache.hash.insert(cacheKey, slotData); - object->setProperty(cachePropertyName, qVariantFromValue(slotCache)); + object->setProperty(cachePropertyName, QVariant::fromValue(slotCache)); // found the slot to be called deliverCall(object, flags, msg, slotData.metaTypes, slotData.slotIdx); diff --git a/src/dbus/qdbusinternalfilters.cpp b/src/dbus/qdbusinternalfilters.cpp index 78abf94..b6cf1fd 100644 --- a/src/dbus/qdbusinternalfilters.cpp +++ b/src/dbus/qdbusinternalfilters.cpp @@ -264,7 +264,7 @@ QDBusMessage qDBusPropertyGet(const QDBusConnectionPrivate::ObjectTreeNode &node return propertyNotFoundError(msg, interface_name, property_name); } - return msg.createReply(qVariantFromValue(QDBusVariant(value))); + return msg.createReply(QVariant::fromValue(QDBusVariant(value))); } enum PropertyWriteResult { @@ -334,7 +334,7 @@ static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant // we have to demarshall before writing void *null = 0; QVariant other(id, null); - if (!QDBusMetaType::demarshall(qVariantValue(value), id, other.data())) { + if (!QDBusMetaType::demarshall(qvariant_cast(value), id, other.data())) { qWarning("QDBusConnection: type `%s' (%d) is not registered with QtDBus. " "Use qDBusRegisterMetaType to register it", mp.typeName(), id); @@ -495,7 +495,7 @@ QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &n return interfaceNotFoundError(msg, interface_name); } - return msg.createReply(qVariantFromValue(result)); + return msg.createReply(QVariant::fromValue(result)); } QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp index b950aef..19d8ab3 100644 --- a/src/declarative/debugger/qdeclarativedebug.cpp +++ b/src/declarative/debugger/qdeclarativedebug.cpp @@ -194,7 +194,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb { QDeclarativeDebugObjectReference obj; obj.m_debugId = prop.m_value.toInt(); - prop.m_value = qVariantFromValue(obj); + prop.m_value = QVariant::fromValue(obj); break; } case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Unknown: diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 346a2f4..a96e4f4 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1294,7 +1294,7 @@ QScriptValue QDeclarativeEnginePrivate::vector3d(QScriptContext *ctxt, QScriptEn qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); qsreal z = ctxt->argument(2).toNumber(); - return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QVector3D(x, y, z))); + return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QVector3D(x, y, z))); } /*! @@ -1314,14 +1314,14 @@ QScriptValue QDeclarativeEnginePrivate::formatDate(QScriptContext*ctxt, QScriptE QScriptValue formatArg = ctxt->argument(1); if (formatArg.isString()) { QString format = formatArg.toString(); - return engine->newVariant(qVariantFromValue(date.toString(format))); + return engine->newVariant(QVariant::fromValue(date.toString(format))); } else if (formatArg.isNumber()) { enumFormat = Qt::DateFormat(formatArg.toUInt32()); } else { return ctxt->throwError(QLatin1String("Qt.formatDate(): Invalid date format")); } } - return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); + return engine->newVariant(QVariant::fromValue(date.toString(enumFormat))); } /*! @@ -1342,14 +1342,14 @@ QScriptValue QDeclarativeEnginePrivate::formatTime(QScriptContext*ctxt, QScriptE QScriptValue formatArg = ctxt->argument(1); if (formatArg.isString()) { QString format = formatArg.toString(); - return engine->newVariant(qVariantFromValue(date.toString(format))); + return engine->newVariant(QVariant::fromValue(date.toString(format))); } else if (formatArg.isNumber()) { enumFormat = Qt::DateFormat(formatArg.toUInt32()); } else { return ctxt->throwError(QLatin1String("Qt.formatTime(): Invalid time format")); } } - return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); + return engine->newVariant(QVariant::fromValue(date.toString(enumFormat))); } /*! @@ -1433,14 +1433,14 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr QScriptValue formatArg = ctxt->argument(1); if (formatArg.isString()) { QString format = formatArg.toString(); - return engine->newVariant(qVariantFromValue(date.toString(format))); + return engine->newVariant(QVariant::fromValue(date.toString(format))); } else if (formatArg.isNumber()) { enumFormat = Qt::DateFormat(formatArg.toUInt32()); } else { return ctxt->throwError(QLatin1String("Qt.formatDateTime(): Invalid datetime format")); } } - return engine->newVariant(qVariantFromValue(date.toString(enumFormat))); + return engine->newVariant(QVariant::fromValue(date.toString(enumFormat))); } #endif // QT_NO_DATESTRING @@ -1469,7 +1469,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine if (a < 0.0) a=0.0; if (a > 1.0) a=1.0; - return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromRgbF(r, g, b, a))); + return qScriptValueFromValue(engine, QVariant::fromValue(QColor::fromRgbF(r, g, b, a))); } /*! @@ -1497,7 +1497,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine if (a < 0.0) a=0.0; if (a > 1.0) a=1.0; - return qScriptValueFromValue(engine, qVariantFromValue(QColor::fromHslF(h, s, l, a))); + return qScriptValueFromValue(engine, QVariant::fromValue(QColor::fromHslF(h, s, l, a))); } /*! @@ -1520,7 +1520,7 @@ QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine if (w < 0 || h < 0) return engine->nullValue(); - return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QRectF(x, y, w, h))); + return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QRectF(x, y, w, h))); } /*! @@ -1533,7 +1533,7 @@ QScriptValue QDeclarativeEnginePrivate::point(QScriptContext *ctxt, QScriptEngin return ctxt->throwError(QLatin1String("Qt.point(): Invalid arguments")); qsreal x = ctxt->argument(0).toNumber(); qsreal y = ctxt->argument(1).toNumber(); - return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QPointF(x, y))); + return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QPointF(x, y))); } /*! @@ -1546,7 +1546,7 @@ QScriptValue QDeclarativeEnginePrivate::size(QScriptContext *ctxt, QScriptEngine return ctxt->throwError(QLatin1String("Qt.size(): Invalid arguments")); qsreal w = ctxt->argument(0).toNumber(); qsreal h = ctxt->argument(1).toNumber(); - return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(qVariantFromValue(QSizeF(w, h))); + return QDeclarativeEnginePrivate::get(engine)->scriptValueFromVariant(QVariant::fromValue(QSizeF(w, h))); } /*! @@ -1582,7 +1582,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng if (ctxt->argumentCount() == 2) factor = ctxt->argument(1).toNumber(); color = color.lighter(int(qRound(factor*100.))); - return qScriptValueFromValue(engine, qVariantFromValue(color)); + return qScriptValueFromValue(engine, QVariant::fromValue(color)); } /*! @@ -1619,7 +1619,7 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi if (ctxt->argumentCount() == 2) factor = ctxt->argument(1).toNumber(); color = color.darker(int(qRound(factor*100.))); - return qScriptValueFromValue(engine, qVariantFromValue(color)); + return qScriptValueFromValue(engine, QVariant::fromValue(color)); } /*! @@ -1854,7 +1854,7 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine a + inv_a * color.alphaF()); } - return qScriptValueFromValue(engine, qVariantFromValue(finalColor)); + return qScriptValueFromValue(engine, QVariant::fromValue(finalColor)); } QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &val) diff --git a/src/declarative/qml/qdeclarativesqldatabase.cpp b/src/declarative/qml/qdeclarativesqldatabase.cpp index 45f277e..42b596a 100644 --- a/src/declarative/qml/qdeclarativesqldatabase.cpp +++ b/src/declarative/qml/qdeclarativesqldatabase.cpp @@ -237,7 +237,7 @@ static QScriptValue qmlsqldatabase_executeSql(QScriptContext *context, QScriptEn if (!qmlengine->sqlQueryClass) qmlengine->sqlQueryClass = new QDeclarativeSqlQueryScriptClass(engine); QScriptValue rows = engine->newObject(qmlengine->sqlQueryClass); - rows.setData(engine->newVariant(qVariantFromValue(query))); + rows.setData(engine->newVariant(QVariant::fromValue(query))); rows.setProperty(QLatin1String("item"), engine->newFunction(qmlsqldatabase_item,1), QScriptValue::SkipInEnumeration); result.setProperty(QLatin1String("rows"),rows); result.setProperty(QLatin1String("rowsAffected"),query.numRowsAffected()); @@ -275,7 +275,7 @@ static QScriptValue qmlsqldatabase_change_version(QScriptContext *context, QScri QScriptValue instance = engine->newObject(); instance.setProperty(QLatin1String("executeSql"), engine->newFunction(qmlsqldatabase_executeSql,1)); - QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db)); + QScriptValue tx = engine->newVariant(instance,QVariant::fromValue(db)); QString foundvers = context->thisObject().property(QLatin1String("version")).toString(); if (from_version!=foundvers) { @@ -319,7 +319,7 @@ static QScriptValue qmlsqldatabase_transaction_shared(QScriptContext *context, Q QScriptValue instance = engine->newObject(); instance.setProperty(QLatin1String("executeSql"), engine->newFunction(readOnly ? qmlsqldatabase_executeSql_readonly : qmlsqldatabase_executeSql,1)); - QScriptValue tx = engine->newVariant(instance,qVariantFromValue(db)); + QScriptValue tx = engine->newVariant(instance,QVariant::fromValue(db)); db.transaction(); callback.call(QScriptValue(), QScriptValueList() << tx); @@ -403,7 +403,7 @@ static QScriptValue qmlsqldatabase_open_sync(QScriptContext *context, QScriptEng instance.setProperty(QLatin1String("version"), version, QScriptValue::ReadOnly); instance.setProperty(QLatin1String("changeVersion"), engine->newFunction(qmlsqldatabase_change_version,3)); - QScriptValue result = engine->newVariant(instance,qVariantFromValue(database)); + QScriptValue result = engine->newVariant(instance,QVariant::fromValue(database)); if (created && dbcreationCallback.isFunction()) { dbcreationCallback.call(QScriptValue(), QScriptValueList() << result); diff --git a/src/declarative/qml/qdeclarativestringconverters.cpp b/src/declarative/qml/qdeclarativestringconverters.cpp index 7534a2c..8ec68ff 100644 --- a/src/declarative/qml/qdeclarativestringconverters.cpp +++ b/src/declarative/qml/qdeclarativestringconverters.cpp @@ -92,7 +92,7 @@ QVariant QDeclarativeStringConverters::variantFromString(const QString &s) QSizeF sz = sizeFFromString(s, &ok); if (ok) return QVariant(sz); QVector3D v = vector3DFromString(s, &ok); - if (ok) return qVariantFromValue(v); + if (ok) return QVariant::fromValue(v); return QVariant(s); } diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index aec84a6..a42f131 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -331,7 +331,7 @@ QVariant QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(const QScri QDeclarativeListModelWorkerAgent *agent = lm->agent(); if (agent) { QDeclarativeListModelWorkerAgent::VariantRef v(agent); - return qVariantFromValue(v); + return QVariant::fromValue(v); } else { return QVariant(); } diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp index acd1f51..ff3b13b 100644 --- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp +++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp @@ -508,7 +508,7 @@ QScriptValue Node::create(QScriptEngine *engine, NodeImpl *data) node.d = data; if (data) A(data); - return engine->newVariant(instance, qVariantFromValue(node)); + return engine->newVariant(instance, QVariant::fromValue(node)); } QScriptValue Element::prototype(QScriptEngine *engine) @@ -708,7 +708,7 @@ QScriptValue Document::load(QScriptEngine *engine, const QByteArray &data) instance.setPrototype(Document::prototype(engine)); Node documentNode; documentNode.d = document; - return engine->newVariant(instance, qVariantFromValue(documentNode)); + return engine->newVariant(instance, QVariant::fromValue(documentNode)); } Node::Node() @@ -759,7 +759,7 @@ QScriptValue NamedNodeMap::create(QScriptEngine *engine, NodeImpl *data, QListnewVariant(qVariantFromValue(map))); + instance.setData(engine->newVariant(QVariant::fromValue(map))); if (!QDeclarativeScriptEngine::get(engine)->namedNodeMapClass) QDeclarativeScriptEngine::get(engine)->namedNodeMapClass= new NamedNodeMapClass(engine); @@ -816,7 +816,7 @@ QScriptValue NodeList::create(QScriptEngine *engine, NodeImpl *data) list.d = data; if (data) A(data); - instance.setData(engine->newVariant(qVariantFromValue(list))); + instance.setData(engine->newVariant(QVariant::fromValue(list))); if (!QDeclarativeScriptEngine::get(engine)->nodeListClass) QDeclarativeScriptEngine::get(engine)->nodeListClass= new NodeListClass(engine); diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 3ede335..596c53b 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -708,7 +708,7 @@ void QDeclarativeListModelParser::setCustomData(QObject *obj, const QByteArray & { ModelNode *n = nodes.top(); ModelNode *n2 = new ModelNode; - n->values << qVariantFromValue(n2); + n->values << QVariant::fromValue(n2); nodes.push(n2); if (processingSet) n->isArray = true; @@ -1072,7 +1072,7 @@ bool NestedListModel::insert(int index, const QScriptValue& valuemap) ModelNode *mn = new ModelNode; mn->setObjectValue(valuemap); - _root->values.insert(index,qVariantFromValue(mn)); + _root->values.insert(index,QVariant::fromValue(mn)); return true; } @@ -1103,7 +1103,7 @@ bool NestedListModel::append(const QScriptValue& valuemap) _root = new ModelNode; ModelNode *mn = new ModelNode; mn->setObjectValue(valuemap); - _root->values << qVariantFromValue(mn); + _root->values << QVariant::fromValue(mn); return true; } @@ -1252,7 +1252,7 @@ void ModelNode::setListValue(const QScriptValue& valuelist) { } else { value->values << v.toVariant(); } - values.append(qVariantFromValue(value)); + values.append(QVariant::fromValue(value)); } } diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp index 7c13367..5b439a9 100644 --- a/src/gui/accessible/qaccessiblewidget.cpp +++ b/src/gui/accessible/qaccessiblewidget.cpp @@ -1015,7 +1015,7 @@ QVariant QAccessibleWidgetEx::invokeMethodEx(Method method, int child, const QVa case ListSupportedMethods: { QSet set; set << ListSupportedMethods << ForegroundColor << BackgroundColor; - return qVariantFromValue(set); + return QVariant::fromValue(set); } case ForegroundColor: return widget()->palette().color(widget()->foregroundRole()); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index d7a7c89..da69bee 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1700,12 +1700,12 @@ void QGraphicsItem::setParentItem(QGraphicsItem *newParent) return; const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange, - qVariantFromValue(newParent))); - newParent = qVariantValue(newParentVariant); + QVariant::fromValue(newParent))); + newParent = qvariant_cast(newParentVariant); if (newParent == d_ptr->parent) return; - const QVariant thisPointerVariant(qVariantFromValue(this)); + const QVariant thisPointerVariant(QVariant::fromValue(this)); d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant); } @@ -2125,7 +2125,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip) */ QCursor QGraphicsItem::cursor() const { - return qVariantValue(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor)); + return qvariant_cast(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor)); } /*! @@ -2145,8 +2145,8 @@ QCursor QGraphicsItem::cursor() const */ void QGraphicsItem::setCursor(const QCursor &cursor) { - const QVariant cursorVariant(itemChange(ItemCursorChange, qVariantFromValue(cursor))); - d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qVariantValue(cursorVariant)); + const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue(cursor))); + d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast(cursorVariant)); d_ptr->hasCursor = 1; if (d_ptr->scene) { d_ptr->scene->d_func()->allItemsUseDefaultCursor = false; @@ -2272,7 +2272,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo // Schedule redrawing if (update) { - QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue(extra(ExtraCacheData)); + QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast(extra(ExtraCacheData)); if (c) c->purge(); if (scene) { @@ -3691,7 +3691,7 @@ void QGraphicsItem::setPos(const QPointF &pos) } // Notify the item that the position is changing. - const QVariant newPosVariant(itemChange(ItemPositionChange, qVariantFromValue(pos))); + const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue(pos))); QPointF newPos = newPosVariant.toPointF(); if (newPos == d_ptr->pos) return; @@ -4045,7 +4045,7 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin) if (d_ptr->flags & ItemSendsGeometryChanges) { // Notify the item that the origin point is changing. const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange, - qVariantFromValue(origin))); + QVariant::fromValue(origin))); newOrigin = newOriginVariant.toPointF(); } @@ -4064,7 +4064,7 @@ void QGraphicsItem::setTransformOriginPoint(const QPointF &origin) // Send post-notification. if (d_ptr->flags & ItemSendsGeometryChanges) - itemChange(ItemTransformOriginPointHasChanged, qVariantFromValue(newOrigin)); + itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue(newOrigin)); } /*! @@ -4326,8 +4326,8 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) } // Notify the item that the transformation matrix is changing. - const QVariant newMatrixVariant = qVariantFromValue(newTransform.toAffine()); - newTransform = QTransform(qVariantValue(itemChange(ItemMatrixChange, newMatrixVariant))); + const QVariant newMatrixVariant = QVariant::fromValue(newTransform.toAffine()); + newTransform = QTransform(qvariant_cast(itemChange(ItemMatrixChange, newMatrixVariant))); if (d_ptr->transformData->transform == newTransform) return; @@ -4335,7 +4335,7 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) d_ptr->setTransformHelper(newTransform); // Send post-notification. - itemChange(ItemTransformHasChanged, qVariantFromValue(newTransform)); + itemChange(ItemTransformHasChanged, QVariant::fromValue(newTransform)); } /*! @@ -4376,8 +4376,8 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine) // Notify the item that the transformation matrix is changing. const QVariant newTransformVariant(itemChange(ItemTransformChange, - qVariantFromValue(newTransform))); - newTransform = qVariantValue(newTransformVariant); + QVariant::fromValue(newTransform))); + newTransform = qvariant_cast(newTransformVariant); if (d_ptr->transformData->transform == newTransform) return; @@ -5230,7 +5230,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c qreal QGraphicsItem::boundingRegionGranularity() const { return d_ptr->hasBoundingRegionGranularity - ? qVariantValue(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) + ? qvariant_cast(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0; } @@ -5266,7 +5266,7 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) } d_ptr->hasBoundingRegionGranularity = 1; d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity, - qVariantFromValue(granularity)); + QVariant::fromValue(granularity)); } /*! @@ -5441,7 +5441,7 @@ void QGraphicsItemPrivate::removeChild(QGraphicsItem *child) */ QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const { - return (QGraphicsItemCache *)qVariantValue(extra(ExtraCacheData)); + return (QGraphicsItemCache *)qvariant_cast(extra(ExtraCacheData)); } /*! @@ -5449,11 +5449,11 @@ QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const */ QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const { - QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue(extra(ExtraCacheData)); + QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast(extra(ExtraCacheData)); if (!c) { QGraphicsItemPrivate *that = const_cast(this); c = new QGraphicsItemCache; - that->setExtra(ExtraCacheData, qVariantFromValue(c)); + that->setExtra(ExtraCacheData, QVariant::fromValue(c)); } return c; } @@ -5463,7 +5463,7 @@ QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const */ void QGraphicsItemPrivate::removeExtraItemCache() { - QGraphicsItemCache *c = (QGraphicsItemCache *)qVariantValue(extra(ExtraCacheData)); + QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast(extra(ExtraCacheData)); if (c) { c->purge(); delete c; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 48a0093..654f60f 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -2543,8 +2543,8 @@ void QGraphicsScene::addItem(QGraphicsItem *item) // Notify the item that its scene is changing, and allow the item to // react. const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange, - qVariantFromValue(this))); - QGraphicsScene *targetScene = qVariantValue(newSceneVariant); + QVariant::fromValue(this))); + QGraphicsScene *targetScene = qvariant_cast(newSceneVariant); if (targetScene != this) { if (targetScene && item->d_ptr->scene != targetScene) targetScene->addItem(item); @@ -2955,8 +2955,8 @@ void QGraphicsScene::removeItem(QGraphicsItem *item) // Notify the item that it's scene is changing to 0, allowing the item to // react. const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange, - qVariantFromValue(0))); - QGraphicsScene *targetScene = qVariantValue(newSceneVariant); + QVariant::fromValue(0))); + QGraphicsScene *targetScene = qvariant_cast(newSceneVariant); if (targetScene != 0 && targetScene != this) { targetScene->addItem(item); return; diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index ec56af2..03ee902 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1092,7 +1092,7 @@ QColor QImageReader::backgroundColor() const if (!d->initHandler()) return QColor(); if (d->handler->supportsOption(QImageIOHandler::BackgroundColor)) - return qVariantValue(d->handler->option(QImageIOHandler::BackgroundColor)); + return qvariant_cast(d->handler->option(QImageIOHandler::BackgroundColor)); return QColor(); } diff --git a/src/gui/image/qmnghandler.cpp b/src/gui/image/qmnghandler.cpp index cf53af0..40f1b54 100644 --- a/src/gui/image/qmnghandler.cpp +++ b/src/gui/image/qmnghandler.cpp @@ -481,7 +481,7 @@ void QMngHandler::setOption(ImageOption option, const QVariant & value) { Q_D(QMngHandler); if (option == QImageIOHandler::BackgroundColor) - d->setBackgroundColor(qVariantValue(value)); + d->setBackgroundColor(qvariant_cast(value)); } /*! \reimp */ diff --git a/src/gui/itemviews/qabstractitemdelegate.cpp b/src/gui/itemviews/qabstractitemdelegate.cpp index 0ea6d67..edbeeb8 100644 --- a/src/gui/itemviews/qabstractitemdelegate.cpp +++ b/src/gui/itemviews/qabstractitemdelegate.cpp @@ -362,7 +362,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event, case QEvent::ToolTip: { QHelpEvent *he = static_cast(event); QVariant tooltip = index.data(Qt::ToolTipRole); - if (qVariantCanConvert(tooltip)) { + if (tooltip.canConvert()) { QToolTip::showText(he->globalPos(), tooltip.toString(), view); return true; } @@ -376,7 +376,7 @@ bool QAbstractItemDelegate::helpEvent(QHelpEvent *event, case QEvent::WhatsThis: { QHelpEvent *he = static_cast(event); QVariant whatsthis = index.data(Qt::WhatsThisRole); - if (qVariantCanConvert(whatsthis)) { + if (whatsthis.canConvert()) { QWhatsThis::showText(he->globalPos(), whatsthis.toString(), view); return true; } diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 67854a3..7eb3ddc 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -2105,7 +2105,7 @@ void QHeaderView::paintEvent(QPaintEvent *e) QVariant variant = d->model->headerData(logical, d->orientation, Qt::FontRole); - if (variant.isValid() && qVariantCanConvert(variant)) { + if (variant.isValid() && variant.canConvert()) { QFont sectionFont = qvariant_cast(variant); painter.setFont(sectionFont); } @@ -2485,13 +2485,13 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical opt.icon = qvariant_cast(variant); QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation, Qt::ForegroundRole); - if (qVariantCanConvert(foregroundBrush)) + if (foregroundBrush.canConvert()) opt.palette.setBrush(QPalette::ButtonText, qvariant_cast(foregroundBrush)); QPointF oldBO = painter->brushOrigin(); QVariant backgroundBrush = d->model->headerData(logicalIndex, d->orientation, Qt::BackgroundRole); - if (qVariantCanConvert(backgroundBrush)) { + if (backgroundBrush.canConvert()) { opt.palette.setBrush(QPalette::Button, qvariant_cast(backgroundBrush)); opt.palette.setBrush(QPalette::Window, qvariant_cast(backgroundBrush)); painter->setBrushOrigin(opt.rect.topLeft()); @@ -2552,7 +2552,7 @@ QSize QHeaderView::sectionSizeFromContents(int logicalIndex) const QVariant var = d->model->headerData(logicalIndex, d->orientation, Qt::FontRole); QFont fnt; - if (var.isValid() && qVariantCanConvert(var)) + if (var.isValid() && var.canConvert()) fnt = qvariant_cast(var); else fnt = font(); diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/gui/itemviews/qitemdelegate.cpp index 9bbfc23..bd2b401 100644 --- a/src/gui/itemviews/qitemdelegate.cpp +++ b/src/gui/itemviews/qitemdelegate.cpp @@ -850,7 +850,7 @@ void QItemDelegate::drawBackground(QPainter *painter, painter->fillRect(option.rect, option.palette.brush(cg, QPalette::Highlight)); } else { QVariant value = index.data(Qt::BackgroundRole); - if (qVariantCanConvert(value)) { + if (value.canConvert()) { QPointF oldBO = painter->brushOrigin(); painter->setBrushOrigin(option.rect.topLeft()); painter->fillRect(option.rect, qvariant_cast(value)); @@ -1326,7 +1326,7 @@ QStyleOptionViewItem QItemDelegate::setOptions(const QModelIndex &index, // set foreground brush value = index.data(Qt::ForegroundRole); - if (qVariantCanConvert(value)) + if (value.canConvert()) opt.palette.setBrush(QPalette::Text, qvariant_cast(value)); return opt; diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/gui/itemviews/qstyleditemdelegate.cpp index 880f8ab..115c734 100644 --- a/src/gui/itemviews/qstyleditemdelegate.cpp +++ b/src/gui/itemviews/qstyleditemdelegate.cpp @@ -326,7 +326,7 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option, option->displayAlignment = Qt::Alignment(value.toInt()); value = index.data(Qt::ForegroundRole); - if (qVariantCanConvert(value)) + if (value.canConvert()) option->palette.setBrush(QPalette::Text, qvariant_cast(value)); if (QStyleOptionViewItemV4 *v4 = qstyleoption_cast(option)) { diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index f7c0b6e..8c7c333 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -631,7 +631,7 @@ QByteArray QMimeDataWrapper::encodedData(const char *format) const return data->data(QLatin1String(format)); } else{ QVariant variant = data->imageData(); - QImage img = qVariantValue(variant); + QImage img = qvariant_cast(variant); QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); diff --git a/src/gui/kernel/qtooltip.cpp b/src/gui/kernel/qtooltip.cpp index c8fcf45..88fdbc6 100644 --- a/src/gui/kernel/qtooltip.cpp +++ b/src/gui/kernel/qtooltip.cpp @@ -353,7 +353,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) #ifndef QT_NO_STYLE_STYLESHEET if (testAttribute(Qt::WA_StyleSheet) || (w && qobject_cast(w->style()))) { //the stylesheet need to know the real parent - QTipLabel::instance->setProperty("_q_stylesheet_parent", qVariantFromValue(w)); + QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w)); //we force the style to be the QStyleSheetStyle, and force to clear the cache as well. QTipLabel::instance->setStyleSheet(QLatin1String("/* */")); diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 3a4c94c..d4a8213 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -130,7 +130,7 @@ QPaintBufferPrivate::~QPaintBufferPrivate() for (int i = 0; i < commands.size(); ++i) { const QPaintBufferCommand &cmd = commands.at(i); if (cmd.id == QPaintBufferPrivate::Cmd_DrawTextItem) - delete reinterpret_cast(qVariantValue(variants.at(cmd.offset))); + delete reinterpret_cast(qvariant_cast(variants.at(cmd.offset))); } } @@ -330,7 +330,7 @@ QString QPaintBuffer::commandDescription(int command) const break; } case QPaintBufferPrivate::Cmd_SetBrush: { - QBrush brush = qVariantValue(d_ptr->variants.at(cmd.offset)); + QBrush brush = qvariant_cast(d_ptr->variants.at(cmd.offset)); debug << "Cmd_SetBrush: " << brush; break; } @@ -354,27 +354,27 @@ QString QPaintBuffer::commandDescription(int command) const break; } case QPaintBufferPrivate::Cmd_StrokeVectorPath: { - QPen pen = qVariantValue(d_ptr->variants.at(cmd.extra)); + QPen pen = qvariant_cast(d_ptr->variants.at(cmd.extra)); debug << "ExCmd_StrokeVectorPath: size: " << cmd.size // << ", hints:" << d->ints[cmd.offset2+cmd.size] << "pts/elms:" << cmd.offset << cmd.offset2 << pen; break; } case QPaintBufferPrivate::Cmd_FillVectorPath: { - QBrush brush = qVariantValue(d_ptr->variants.at(cmd.extra)); + QBrush brush = qvariant_cast(d_ptr->variants.at(cmd.extra)); debug << "ExCmd_FillVectorPath: size: " << cmd.size // << ", hints:" << d->ints[cmd.offset2+cmd.size] << "pts/elms:" << cmd.offset << cmd.offset2 << brush; break; } case QPaintBufferPrivate::Cmd_FillRectBrush: { - QBrush brush = qVariantValue(d_ptr->variants.at(cmd.extra)); + QBrush brush = qvariant_cast(d_ptr->variants.at(cmd.extra)); QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset); debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush; break; } case QPaintBufferPrivate::Cmd_FillRectColor: { - QColor color = qVariantValue(d_ptr->variants.at(cmd.extra)); + QColor color = qvariant_cast(d_ptr->variants.at(cmd.extra)); QRectF *rect = (QRectF *)(d_ptr->floats.constData() + cmd.offset); debug << "ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color; break; } @@ -451,12 +451,12 @@ QString QPaintBuffer::commandDescription(int command) const break; } case QPaintBufferPrivate::Cmd_SetPen: { - QPen pen = qVariantValue(d_ptr->variants.at(cmd.offset)); + QPen pen = qvariant_cast(d_ptr->variants.at(cmd.offset)); debug << "Cmd_SetPen: " << pen; break; } case QPaintBufferPrivate::Cmd_SetTransform: { - QTransform xform = qVariantValue(d_ptr->variants.at(cmd.offset)); + QTransform xform = qvariant_cast(d_ptr->variants.at(cmd.offset)); debug << "Cmd_SetTransform, offset: " << cmd.offset << xform; break; } @@ -532,7 +532,7 @@ QString QPaintBuffer::commandDescription(int command) const case QPaintBufferPrivate::Cmd_DrawTextItem: { QPointF pos(d_ptr->floats.at(cmd.extra), d_ptr->floats.at(cmd.extra+1)); - QTextItemIntCopy *tiCopy = reinterpret_cast(qVariantValue(d_ptr->variants.at(cmd.offset))); + QTextItemIntCopy *tiCopy = reinterpret_cast(qvariant_cast(d_ptr->variants.at(cmd.offset))); QTextItemInt &ti = (*tiCopy)(); QString text(ti.text()); @@ -1287,7 +1287,7 @@ void QPaintBufferEngine::drawTextItem(const QPointF &pos, const QTextItem &ti) qDebug() << "QPaintBufferEngine: drawTextItem: pos:" << pos << ti.text(); #endif if (m_stream_raw_text_items) { - QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTextItem, qVariantFromValue(new QTextItemIntCopy(ti))); + QPaintBufferCommand *cmd = buffer->addCommand(QPaintBufferPrivate::Cmd_DrawTextItem, QVariant::fromValue(new QTextItemIntCopy(ti))); QFont font(ti.font()); font.setUnderline(false); @@ -1429,7 +1429,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_SetPen: { - QPen pen = qVariantValue(d->variants.at(cmd.offset)); + QPen pen = qvariant_cast(d->variants.at(cmd.offset)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_SetPen: " << pen; #endif @@ -1437,7 +1437,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_SetBrush: { - QBrush brush = qVariantValue(d->variants.at(cmd.offset)); + QBrush brush = qvariant_cast(d->variants.at(cmd.offset)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_SetBrush: " << brush; #endif @@ -1452,7 +1452,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_SetTransform: { - QTransform xform = qVariantValue(d->variants.at(cmd.offset)); + QTransform xform = qvariant_cast(d->variants.at(cmd.offset)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_SetTransform, offset: " << cmd.offset << xform; #endif @@ -1520,7 +1520,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_StrokeVectorPath: { - QPen pen = qVariantValue(d->variants.at(cmd.extra)); + QPen pen = qvariant_cast(d->variants.at(cmd.extra)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_StrokeVectorPath: size: " << cmd.size // << ", hints:" << d->ints[cmd.offset2+cmd.size] @@ -1531,7 +1531,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_FillVectorPath: { - QBrush brush = qVariantValue(d->variants.at(cmd.extra)); + QBrush brush = qvariant_cast(d->variants.at(cmd.extra)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_FillVectorPath: size: " << cmd.size // << ", hints:" << d->ints[cmd.offset2+cmd.size] @@ -1705,7 +1705,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_FillRectBrush: { - QBrush brush = qVariantValue(d->variants.at(cmd.extra)); + QBrush brush = qvariant_cast(d->variants.at(cmd.extra)); QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush; @@ -1714,7 +1714,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_FillRectColor: { - QColor color = qVariantValue(d->variants.at(cmd.extra)); + QColor color = qvariant_cast(d->variants.at(cmd.extra)); QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> Cmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color; @@ -1790,7 +1790,7 @@ void QPainterReplayer::process(const QPaintBufferCommand &cmd) case QPaintBufferPrivate::Cmd_DrawTextItem: { QPointF pos(d->floats.at(cmd.extra), d->floats.at(cmd.extra+1)); - QTextItemIntCopy *tiCopy = reinterpret_cast(qVariantValue(d->variants.at(cmd.offset))); + QTextItemIntCopy *tiCopy = reinterpret_cast(qvariant_cast(d->variants.at(cmd.offset))); QTextItemInt &ti = (*tiCopy)(); QString text(ti.text()); @@ -1885,7 +1885,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_StrokeVectorPath: { - QPen pen = qVariantValue(d->variants.at(cmd.extra)); + QPen pen = qvariant_cast(d->variants.at(cmd.extra)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> ExCmd_StrokeVectorPath: size: " << cmd.size // << ", hints:" << d->ints[cmd.offset2+cmd.size] @@ -1896,7 +1896,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_FillVectorPath: { - QBrush brush = qVariantValue(d->variants.at(cmd.extra)); + QBrush brush = qvariant_cast(d->variants.at(cmd.extra)); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> ExCmd_FillVectorPath: size: " << cmd.size // << ", hints:" << d->ints[cmd.offset2+cmd.size] @@ -1907,7 +1907,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_FillRectBrush: { - QBrush brush = qVariantValue(d->variants.at(cmd.extra)); + QBrush brush = qvariant_cast(d->variants.at(cmd.extra)); QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " brush: " << brush; @@ -1916,7 +1916,7 @@ void QPaintEngineExReplayer::process(const QPaintBufferCommand &cmd) break; } case QPaintBufferPrivate::Cmd_FillRectColor: { - QColor color = qVariantValue(d->variants.at(cmd.extra)); + QColor color = qvariant_cast(d->variants.at(cmd.extra)); QRectF *rect = (QRectF *)(d->floats.constData() + cmd.offset); #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << " -> ExCmd_FillRectBrush, offset: " << cmd.offset << " rect: " << *rect << " color: " << color; diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 5d984cf..272fb26 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -2583,7 +2583,7 @@ void QStyleSheetStyle::unsetPalette(QWidget *w) } QVariant oldFont = w->property("_q_styleSheetWidgetFont"); if (oldFont.isValid()) { - w->setFont(qVariantValue(oldFont)); + w->setFont(qvariant_cast(oldFont)); } if (autoFillDisabledWidgets->contains(w)) { embeddedWidget(w)->setAutoFillBackground(true); @@ -5067,7 +5067,7 @@ QIcon QStyleSheetStyle::standardIconImplementation(StandardPixmap standardIcon, if (!s.isEmpty()) { QRenderRule rule = renderRule(w, opt); if (rule.hasStyleHint(s)) - return qVariantValue(rule.styleHint(s)); + return qvariant_cast(rule.styleHint(s)); } return baseStyle()->standardIcon(standardIcon, opt, w); } @@ -5085,7 +5085,7 @@ QPixmap QStyleSheetStyle::standardPixmap(StandardPixmap standardPixmap, const QS if (!s.isEmpty()) { QRenderRule rule = renderRule(w, opt); if (rule.hasStyleHint(s)) { - QIcon icon = qVariantValue(rule.styleHint(s)); + QIcon icon = qvariant_cast(rule.styleHint(s)); return icon.pixmap(16, 16); // ###: unhard-code this if someone complains } } diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 39c4053..3fc6722 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -403,7 +403,7 @@ int ValueExtractor::lengthValue(const Declaration &decl) if (decl.d->values.count() < 1) return 0; LengthData data = lengthValue(decl.d->values.at(0)); - decl.d->parsed = qVariantFromValue(data); + decl.d->parsed = QVariant::fromValue(data); return lengthValueFromData(data,f); } @@ -435,7 +435,7 @@ void ValueExtractor::lengthValues(const Declaration &decl, int *m) QList v; for (i = 0; i < 4; i++) { - v += qVariantFromValue(datas[i]); + v += QVariant::fromValue(datas[i]); m[i] = lengthValueFromData(datas[i], f); } decl.d->parsed = v; @@ -541,7 +541,7 @@ QSize ValueExtractor::sizeValue(const Declaration &decl) else x[1] = x[0]; QList v; - v << qVariantFromValue(x[0]) << qVariantFromValue(x[1]); + v << QVariant::fromValue(x[0]) << qVariantFromValue(x[1]); decl.d->parsed = v; return QSize(lengthValueFromData(x[0], f), lengthValueFromData(x[1], f)); } @@ -916,7 +916,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord data.width = lengthValue(decl.d->values.at(i)); *width = lengthValueFromData(data.width, f); if (++i >= decl.d->values.count()) { - decl.d->parsed = qVariantFromValue(data); + decl.d->parsed = QVariant::fromValue(data); return; } } @@ -925,7 +925,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord if (data.style != BorderStyle_Unknown) { *style = data.style; if (++i >= decl.d->values.count()) { - decl.d->parsed = qVariantFromValue(data); + decl.d->parsed = QVariant::fromValue(data); return; } } else { @@ -935,7 +935,7 @@ void ValueExtractor::borderValue(const Declaration &decl, int *width, QCss::Bord data.color = parseBrushValue(decl.d->values.at(i), pal); *color = brushFromData(data.color, pal); if (data.color.type != BrushData::DependsOnThePalette) - decl.d->parsed = qVariantFromValue(data); + decl.d->parsed = QVariant::fromValue(data); } static void parseShorthandBackgroundProperty(const QVector &values, BrushData *brush, QString *image, Repeat *repeat, Qt::Alignment *alignment, const QPalette &pal) @@ -1033,7 +1033,7 @@ bool ValueExtractor::extractBackground(QBrush *brush, QString *image, Repeat *re *brush = brushFromData(brushData, pal); if (brushData.type != BrushData::DependsOnThePalette) { BackgroundData data = { brushData, *image, *repeat, *alignment }; - decl.d->parsed = qVariantFromValue(data); + decl.d->parsed = QVariant::fromValue(data); } } break; @@ -1311,10 +1311,10 @@ QColor Declaration::colorValue(const QPalette &pal) const ColorData color = parseColorValue(d->values.at(0)); if(color.type == ColorData::Role) { - d->parsed = qVariantFromValue(color.role); + d->parsed = QVariant::fromValue(color.role); return pal.color((QPalette::ColorRole)(color.role)); } else { - d->parsed = qVariantFromValue(color.color); + d->parsed = QVariant::fromValue(color.color); return color.color; } } @@ -1334,11 +1334,11 @@ QBrush Declaration::brushValue(const QPalette &pal) const BrushData data = parseBrushValue(d->values.at(0), pal); if(data.type == BrushData::Role) { - d->parsed = qVariantFromValue(data.role); + d->parsed = QVariant::fromValue(data.role); return pal.color((QPalette::ColorRole)(data.role)); } else { if (data.type != BrushData::DependsOnThePalette) - d->parsed = qVariantFromValue(data.brush); + d->parsed = QVariant::fromValue(data.brush); return data.brush; } } @@ -1368,11 +1368,11 @@ void Declaration::brushValues(QBrush *c, const QPalette &pal) const continue; BrushData data = parseBrushValue(d->values.at(i), pal); if(data.type == BrushData::Role) { - v += qVariantFromValue(data.role); + v += QVariant::fromValue(data.role); c[i] = pal.color((QPalette::ColorRole)(data.role)); } else { if (data.type != BrushData::DependsOnThePalette) { - v += qVariantFromValue(data.brush); + v += QVariant::fromValue(data.brush); } else { v += QVariant(); } @@ -1445,7 +1445,7 @@ QSize Declaration::sizeValue() const else x[1] = x[0]; QSize size(x[0], x[1]); - d->parsed = qVariantFromValue(size); + d->parsed = QVariant::fromValue(size); return size; } @@ -1467,7 +1467,7 @@ QRect Declaration::rectValue() const if (args.count() != 4) return QRect(); QRect rect(args[0].toInt(), args[1].toInt(), args[2].toInt(), args[3].toInt()); - d->parsed = qVariantFromValue(rect); + d->parsed = QVariant::fromValue(rect); return rect; } @@ -1488,10 +1488,10 @@ void Declaration::colorValues(QColor *c, const QPalette &pal) const for (i = 0; i < qMin(d->values.count(), 4); i++) { ColorData color = parseColorValue(d->values.at(i)); if(color.type == ColorData::Role) { - v += qVariantFromValue(color.role); + v += QVariant::fromValue(color.role); c[i] = pal.color((QPalette::ColorRole)(color.role)); } else { - v += qVariantFromValue(color.color); + v += QVariant::fromValue(color.color); c[i] = color.color; } } @@ -1683,7 +1683,7 @@ QIcon Declaration::iconValue() const i++; } - d->parsed = qVariantFromValue(icon); + d->parsed = QVariant::fromValue(icon); return icon; } diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 3d34687..32b1df9 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -2908,7 +2908,7 @@ QAbstractTextDocumentLayout::PaintContext QTextControl::getPaintContext(QWidget if (widget) style = widget->style(); style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret); - selection.format = qVariantValue(ret.variant).toCharFormat(); + selection.format = qvariant_cast(ret.variant).toCharFormat(); } else { QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive; selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight)); diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp index 46db253..e0a4096 100644 --- a/src/gui/text/qtextformat.cpp +++ b/src/gui/text/qtextformat.cpp @@ -925,7 +925,7 @@ qreal QTextFormat::doubleProperty(int propertyId) const const QVariant prop = d->property(propertyId); if (prop.userType() != QVariant::Double && prop.userType() != QMetaType::Float) return 0.; - return qVariantValue(prop); + return qvariant_cast(prop); } /*! @@ -1895,7 +1895,7 @@ void QTextBlockFormat::setTabPositions(const QList &tabs) QList::ConstIterator iter = tabs.constBegin(); while (iter != tabs.constEnd()) { QVariant v; - qVariantSetValue(v, *iter); + v.setValue(*iter); list.append(v); ++iter; } @@ -1917,7 +1917,7 @@ QList QTextBlockFormat::tabPositions() const QList variantsList = qvariant_cast >(variant); QList::Iterator iter = variantsList.begin(); while(iter != variantsList.end()) { - answer.append( qVariantValue(*iter)); + answer.append( qvariant_cast(*iter)); ++iter; } return answer; diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 88b3467..bb2da9a 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -116,7 +116,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); QVariant value = index.data(Qt::ForegroundRole); - if (qVariantCanConvert(value)) { + if (value.canConvert()) { resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast(value)); resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast(value)); resolvedpalette.setBrush(QPalette::Text, qvariant_cast(value)); @@ -152,7 +152,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt menuOption.icon = qvariant_cast(variant); break; } - if (qVariantCanConvert(index.data(Qt::BackgroundRole))) { + if (index.data(Qt::BackgroundRole).canConvert()) { menuOption.palette.setBrush(QPalette::All, QPalette::Background, qvariant_cast(index.data(Qt::BackgroundRole))); } diff --git a/src/multimedia/video/qvideosurfaceformat.cpp b/src/multimedia/video/qvideosurfaceformat.cpp index 1fc13a6..6cdf7c0 100644 --- a/src/multimedia/video/qvideosurfaceformat.cpp +++ b/src/multimedia/video/qvideosurfaceformat.cpp @@ -502,11 +502,11 @@ QList QVideoSurfaceFormat::propertyNames() const QVariant QVideoSurfaceFormat::property(const char *name) const { if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); + return QVariant::fromValue(d->handleType); } else if (qstrcmp(name, "pixelFormat") == 0) { - return qVariantFromValue(d->pixelFormat); + return QVariant::fromValue(d->pixelFormat); } else if (qstrcmp(name, "handleType") == 0) { - return qVariantFromValue(d->handleType); + return QVariant::fromValue(d->handleType); } else if (qstrcmp(name, "frameSize") == 0) { return d->frameSize; } else if (qstrcmp(name, "frameWidth") == 0) { @@ -516,15 +516,15 @@ QVariant QVideoSurfaceFormat::property(const char *name) const } else if (qstrcmp(name, "viewport") == 0) { return d->viewport; } else if (qstrcmp(name, "scanLineDirection") == 0) { - return qVariantFromValue(d->scanLineDirection); + return QVariant::fromValue(d->scanLineDirection); } else if (qstrcmp(name, "frameRate") == 0) { - return qVariantFromValue(d->frameRate); + return QVariant::fromValue(d->frameRate); } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - return qVariantFromValue(d->pixelAspectRatio); + return QVariant::fromValue(d->pixelAspectRatio); } else if (qstrcmp(name, "sizeHint") == 0) { return sizeHint(); } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - return qVariantFromValue(d->ycbcrColorSpace); + return QVariant::fromValue(d->ycbcrColorSpace); } else { int id = 0; for (; id < d->propertyNames.count() && d->propertyNames.at(id) != name; ++id) {} @@ -546,7 +546,7 @@ void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) } else if (qstrcmp(name, "pixelFormat") == 0) { // read only. } else if (qstrcmp(name, "frameSize") == 0) { - if (qVariantCanConvert(value)) { + if (value.canConvert()) { d->frameSize = qvariant_cast(value); d->viewport = QRect(QPoint(0, 0), d->frameSize); } @@ -555,21 +555,21 @@ void QVideoSurfaceFormat::setProperty(const char *name, const QVariant &value) } else if (qstrcmp(name, "frameHeight") == 0) { // read only. } else if (qstrcmp(name, "viewport") == 0) { - if (qVariantCanConvert(value)) + if (value.canConvert()) d->viewport = qvariant_cast(value); } else if (qstrcmp(name, "scanLineDirection") == 0) { - if (qVariantCanConvert(value)) + if (value.canConvert()) d->scanLineDirection = qvariant_cast(value); } else if (qstrcmp(name, "frameRate") == 0) { - if (qVariantCanConvert(value)) + if (value.canConvert()) d->frameRate = qvariant_cast(value); } else if (qstrcmp(name, "pixelAspectRatio") == 0) { - if (qVariantCanConvert(value)) + if (value.canConvert()) d->pixelAspectRatio = qvariant_cast(value); } else if (qstrcmp(name, "sizeHint") == 0) { // read only. } else if (qstrcmp(name, "yCbCrColorSpace") == 0) { - if (qVariantCanConvert(value)) + if (value.canConvert()) d->ycbcrColorSpace = qvariant_cast(value); } else { int id = 0; diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 80b74c7..f1054bd 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -991,7 +991,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera if (d->cookieJar) { QList cookies = d->cookieJar->cookiesForUrl(request.url()); if (!cookies.isEmpty()) - request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies)); + request.setHeader(QNetworkRequest::CookieHeader, QVariant::fromValue(cookies)); } } diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index fa592c2..f4284b8 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -768,7 +768,7 @@ static QVariant parseCookieHeader(const QByteArray &raw) result += parsed; } - return qVariantFromValue(result); + return QVariant::fromValue(result); } static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QByteArray &value) @@ -801,7 +801,7 @@ static QVariant parseHeaderValue(QNetworkRequest::KnownHeaders header, const QBy return parseCookieHeader(value); case QNetworkRequest::SetCookieHeader: - return qVariantFromValue(QNetworkCookie::parseCookies(value)); + return QVariant::fromValue(QNetworkCookie::parseCookies(value)); default: Q_ASSERT(0); diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp index 662663d..6eb0617 100644 --- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp +++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp @@ -348,7 +348,7 @@ QVariant QAccessibleTextEdit::invokeMethodEx(QAccessible::Method method, int chi case ListSupportedMethods: { QSet set; set << ListSupportedMethods << SetCursorPosition << GetCursorPosition; - return qVariantFromValue(set | qvariant_cast >( + return QVariant::fromValue(set | qvariant_cast >( QAccessibleWidgetEx::invokeMethodEx(method, child, params))); } case SetCursorPosition: diff --git a/src/plugins/accessible/widgets/rangecontrols.cpp b/src/plugins/accessible/widgets/rangecontrols.cpp index 4cd171b..bf7b561 100644 --- a/src/plugins/accessible/widgets/rangecontrols.cpp +++ b/src/plugins/accessible/widgets/rangecontrols.cpp @@ -233,7 +233,7 @@ QVariant QAccessibleAbstractSpinBox::invokeMethodEx(Method method, int child, co case ListSupportedMethods: { QSet set; set << ListSupportedMethods; - return qVariantFromValue(set | qvariant_cast >( + return QVariant::fromValue(set | qvariant_cast >( QAccessibleWidgetEx::invokeMethodEx(method, child, params))); } default: @@ -814,7 +814,7 @@ QVariant QAccessibleAbstractSlider::invokeMethodEx(Method method, int child, con case ListSupportedMethods: { QSet set; set << ListSupportedMethods; - return qVariantFromValue(set | qvariant_cast >( + return QVariant::fromValue(set | qvariant_cast >( QAccessibleWidgetEx::invokeMethodEx(method, child, params))); } default: diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index f39d538..d8b57af 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -732,7 +732,7 @@ QVariant QAccessibleLineEdit::invokeMethodEx(QAccessible::Method method, int chi case ListSupportedMethods: { QSet set; set << ListSupportedMethods << SetCursorPosition << GetCursorPosition; - return qVariantFromValue(set | qvariant_cast >( + return QVariant::fromValue(set | qvariant_cast >( QAccessibleWidgetEx::invokeMethodEx(method, child, params))); } case SetCursorPosition: diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index b20e7c1..da421bc 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -953,10 +953,10 @@ bool QConnmanDeviceInterface::setProperty(const QString &name, const QDBusVarian // QList args; qWarning() << __FUNCTION__ << name << value.variant(); -// args << qVariantFromValue(name); -// args << qVariantFromValue(value); +// args << QVariant::fromValue(name); +// args << QVariant::fromValue(value); - QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, qVariantFromValue(value)); + QDBusMessage reply = this->call(QLatin1String("SetProperty"),name, QVariant::fromValue(value)); qWarning() << reply.errorMessage(); return true; @@ -1020,7 +1020,7 @@ quint16 QConnmanDeviceInterface::getScanInterval() bool QConnmanDeviceInterface::setScanInterval(const QString & interval) { // QList args; -// args << qVariantFromValue(name) +// args << QVariant::fromValue(name) // << value.variant(); // QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); @@ -1043,8 +1043,8 @@ QStringList QConnmanDeviceInterface::getNetworks() bool QConnmanDeviceInterface::setEnabled(bool powered) { QList args; - args << qVariantFromValue(QString("Powered")) - << qVariantFromValue(QDBusVariant(powered)); + args << QVariant::fromValue(QString("Powered")) + << QVariant::fromValue(QDBusVariant(powered)); QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,QLatin1String("SetProperty"),args); qWarning() << reply.errorMessage() << reply.errorName(); diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 01f3c51..a7a20c1 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1711,7 +1711,7 @@ QVariant QScriptEnginePrivate::toVariant(JSC::ExecState *exec, JSC::JSValue valu return variantValue(value); #ifndef QT_NO_QOBJECT else if (isQObject(value)) - return qVariantFromValue(toQObject(exec, value)); + return QVariant::fromValue(toQObject(exec, value)); #endif else if (isDate(value)) return QVariant(toDateTime(exec, value)); diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp index dd229f1..28f7bd1 100644 --- a/src/script/bridge/qscriptclassobject.cpp +++ b/src/script/bridge/qscriptclassobject.cpp @@ -211,7 +211,7 @@ JSC::JSValue JSC_HOST_CALL ClassObjectDelegate::call(JSC::ExecState *exec, JSC:: eng_p->pushContext(exec, thisValue, args, callee); QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame); QScriptValue scriptObject = eng_p->scriptValueFromJSCValue(obj); - QVariant result = scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx)); + QVariant result = scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx)); eng_p->popContext(); eng_p->currentFrame = oldFrame; return QScriptEnginePrivate::jscValueFromVariant(exec, result); @@ -239,7 +239,7 @@ JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObjec QScriptContext *ctx = eng_p->contextForFrame(eng_p->currentFrame); QScriptValue defaultObject = ctx->thisObject(); - QScriptValue result = qvariant_cast(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx))); + QScriptValue result = qvariant_cast(scriptClass->extension(QScriptClass::Callable, QVariant::fromValue(ctx))); if (!result.isObject()) result = defaultObject; eng_p->popContext(); @@ -256,7 +256,7 @@ bool ClassObjectDelegate::hasInstance(QScriptObject* object, JSC::ExecState *exe QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec); QScript::SaveFrameHelper saveFrame(eng_p, exec); args << eng_p->scriptValueFromJSCValue(object) << eng_p->scriptValueFromJSCValue(value); - QVariant result = scriptClass()->extension(QScriptClass::HasInstance, qVariantFromValue(args)); + QVariant result = scriptClass()->extension(QScriptClass::HasInstance, QVariant::fromValue(args)); return result.toBool(); } diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index 9e26fbf..d24f2fe 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -664,7 +664,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c if (actual.isNumber()) { int ival = QScriptEnginePrivate::toInt32(exec, actual); if (m.valueToKey(ival) != 0) { - qVariantSetValue(v, ival); + v.setValue(ival); converted = true; matchDistance += 10; } @@ -672,7 +672,7 @@ static JSC::JSValue callQtMethod(JSC::ExecState *exec, QMetaMethod::MethodType c JSC::UString sval = QScriptEnginePrivate::toString(exec, actual); int ival = m.keyToValue(convertToLatin1(sval)); if (ival != -1) { - qVariantSetValue(v, ival); + v.setValue(ival); converted = true; matchDistance += 10; } diff --git a/src/scripttools/debugging/qscriptdebuggercommand.cpp b/src/scripttools/debugging/qscriptdebuggercommand.cpp index fa223ec..5ca0535 100644 --- a/src/scripttools/debugging/qscriptdebuggercommand.cpp +++ b/src/scripttools/debugging/qscriptdebuggercommand.cpp @@ -256,7 +256,7 @@ QScriptBreakpointData QScriptDebuggerCommand::breakpointData() const void QScriptDebuggerCommand::setBreakpointData(const QScriptBreakpointData &data) { Q_D(QScriptDebuggerCommand); - d->attributes[BreakpointData] = qVariantFromValue(data); + d->attributes[BreakpointData] = QVariant::fromValue(data); } QScriptDebuggerValue QScriptDebuggerCommand::scriptValue() const @@ -268,7 +268,7 @@ QScriptDebuggerValue QScriptDebuggerCommand::scriptValue() const void QScriptDebuggerCommand::setScriptValue(const QScriptDebuggerValue &value) { Q_D(QScriptDebuggerCommand); - d->attributes[ScriptValue] = qVariantFromValue(value); + d->attributes[ScriptValue] = QVariant::fromValue(value); } int QScriptDebuggerCommand::contextIndex() const @@ -316,7 +316,7 @@ QScriptDebuggerValue QScriptDebuggerCommand::subordinateScriptValue() const void QScriptDebuggerCommand::setSubordinateScriptValue(const QScriptDebuggerValue &value) { Q_D(QScriptDebuggerCommand); - d->attributes[SubordinateScriptValue] = qVariantFromValue(value); + d->attributes[SubordinateScriptValue] = QVariant::fromValue(value); } int QScriptDebuggerCommand::snapshotId() const diff --git a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp index 568af59..7616148 100644 --- a/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp +++ b/src/scripttools/debugging/qscriptdebuggercommandexecutor.cpp @@ -229,11 +229,11 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute( case QScriptDebuggerCommand::ScriptsCheckpoint: backend->scriptsCheckpoint(); - response.setResult(qVariantFromValue(backend->scriptsDelta())); + response.setResult(QVariant::fromValue(backend->scriptsDelta())); break; case QScriptDebuggerCommand::GetScriptsDelta: - response.setResult(qVariantFromValue(backend->scriptsDelta())); + response.setResult(QVariant::fromValue(backend->scriptsDelta())); break; case QScriptDebuggerCommand::ResolveScript: @@ -302,7 +302,7 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute( } break; case QScriptDebuggerCommand::ContextsCheckpoint: { - response.setResult(qVariantFromValue(backend->contextsCheckpoint())); + response.setResult(QVariant::fromValue(backend->contextsCheckpoint())); } break; case QScriptDebuggerCommand::GetPropertyExpressionValue: { @@ -441,7 +441,7 @@ QScriptDebuggerResponse QScriptDebuggerCommandExecutor::execute( result.addedProperties.append(dest); } backend->setIgnoreExceptions(didIgnoreExceptions); - response.setResult(qVariantFromValue(result)); + response.setResult(QVariant::fromValue(result)); } break; case QScriptDebuggerCommand::DeleteScriptObjectSnapshot: { diff --git a/src/scripttools/debugging/qscriptdebuggerevent.cpp b/src/scripttools/debugging/qscriptdebuggerevent.cpp index f5f20cf..55df35b 100644 --- a/src/scripttools/debugging/qscriptdebuggerevent.cpp +++ b/src/scripttools/debugging/qscriptdebuggerevent.cpp @@ -216,7 +216,7 @@ QScriptDebuggerValue QScriptDebuggerEvent::scriptValue() const void QScriptDebuggerEvent::setScriptValue(const QScriptDebuggerValue &value) { Q_D(QScriptDebuggerEvent); - d->attributes[Value] = qVariantFromValue(value); + d->attributes[Value] = QVariant::fromValue(value); } void QScriptDebuggerEvent::setNestedEvaluate(bool nested) diff --git a/src/scripttools/debugging/qscriptdebuggerresponse.cpp b/src/scripttools/debugging/qscriptdebuggerresponse.cpp index 0caa3e2..382e604e 100644 --- a/src/scripttools/debugging/qscriptdebuggerresponse.cpp +++ b/src/scripttools/debugging/qscriptdebuggerresponse.cpp @@ -162,49 +162,49 @@ void QScriptDebuggerResponse::setResult(const QString &value) void QScriptDebuggerResponse::setResult(const QScriptBreakpointData &data) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(data); + d->result = QVariant::fromValue(data); } void QScriptDebuggerResponse::setResult(const QScriptBreakpointMap &breakpoints) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(breakpoints); + d->result = QVariant::fromValue(breakpoints); } void QScriptDebuggerResponse::setResult(const QScriptScriptMap &scripts) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(scripts); + d->result = QVariant::fromValue(scripts); } void QScriptDebuggerResponse::setResult(const QScriptScriptData &data) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(data); + d->result = QVariant::fromValue(data); } void QScriptDebuggerResponse::setResult(const QScriptDebuggerValue &value) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(value); + d->result = QVariant::fromValue(value); } void QScriptDebuggerResponse::setResult(const QScriptDebuggerValueList &values) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(values); + d->result = QVariant::fromValue(values); } void QScriptDebuggerResponse::setResult(const QScriptDebuggerValuePropertyList &props) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(props); + d->result = QVariant::fromValue(props); } void QScriptDebuggerResponse::setResult(const QScriptContextInfo &info) { Q_D(QScriptDebuggerResponse); - d->result = qVariantFromValue(info); + d->result = QVariant::fromValue(info); } int QScriptDebuggerResponse::resultAsInt() const diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp index 2261887..a060a01 100644 --- a/src/sql/drivers/mysql/qsql_mysql.cpp +++ b/src/sql/drivers/mysql/qsql_mysql.cpp @@ -420,10 +420,10 @@ QVariant QMYSQLResult::handle() const { #if MYSQL_VERSION_ID >= 40108 if(d->preparedQuery) - return d->meta ? qVariantFromValue(d->meta) : qVariantFromValue(d->stmt); + return d->meta ? QVariant::fromValue(d->meta) : qVariantFromValue(d->stmt); else #endif - return qVariantFromValue(d->result); + return QVariant::fromValue(d->result); } void QMYSQLResult::cleanup() @@ -1432,7 +1432,7 @@ QSqlRecord QMYSQLDriver::record(const QString& tablename) const QVariant QMYSQLDriver::handle() const { - return qVariantFromValue(d->mysql); + return QVariant::fromValue(d->mysql); } bool QMYSQLDriver::beginTransaction() diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/sql/drivers/oci/qsql_oci.cpp index e11cf75..6870055 100644 --- a/src/sql/drivers/oci/qsql_oci.cpp +++ b/src/sql/drivers/oci/qsql_oci.cpp @@ -293,9 +293,9 @@ int QOCIResultPrivate::bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, in SQLT_FLT, indPtr, 0, 0, 0, 0, OCI_DEFAULT); break; case QVariant::UserType: - if (qVariantCanConvert(val) && !isOutValue(pos)) { + if (val.canConvert() && !isOutValue(pos)) { // use a const pointer to prevent a detach - const QOCIRowIdPointer rptr = qVariantValue(val); + const QOCIRowIdPointer rptr = qvariant_cast(val); r = OCIBindByPos(sql, hbnd, err, pos + 1, // it's an IN value, so const_cast is ok @@ -1364,8 +1364,8 @@ bool QOCICols::execBatch(QOCIResultPrivate *d, QVector &boundValues, b break; } case QVariant::UserType: - if (qVariantCanConvert(val)) { - const QOCIRowIdPointer rptr = qVariantValue(val); + if (val.canConvert()) { + const QOCIRowIdPointer rptr = qvariant_cast(val); *reinterpret_cast(dataPtr) = rptr->id; columns[i].lengths[row] = 0; break; @@ -1704,7 +1704,7 @@ QOCIResult::~QOCIResult() QVariant QOCIResult::handle() const { - return qVariantFromValue(d->sql); + return QVariant::fromValue(d->sql); } bool QOCIResult::reset (const QString& query) @@ -1932,7 +1932,7 @@ QVariant QOCIResult::lastInsertId() const int r = OCIAttrGet(d->sql, OCI_HTYPE_STMT, ptr.constData()->id, 0, OCI_ATTR_ROWID, d->err); if (r == OCI_SUCCESS) - return qVariantFromValue(ptr); + return QVariant::fromValue(ptr); } return QVariant(); } @@ -2534,7 +2534,7 @@ QString QOCIDriver::formatValue(const QSqlField &field, bool trimStrings) const QVariant QOCIDriver::handle() const { - return qVariantFromValue(d->env); + return QVariant::fromValue(d->env); } QString QOCIDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 2a4e595..179f7ba 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -279,7 +279,7 @@ QPSQLResult::~QPSQLResult() QVariant QPSQLResult::handle() const { - return qVariantFromValue(d->result); + return QVariant::fromValue(d->result); } void QPSQLResult::cleanup() @@ -706,7 +706,7 @@ QPSQLDriver::~QPSQLDriver() QVariant QPSQLDriver::handle() const { - return qVariantFromValue(d->connection); + return QVariant::fromValue(d->connection); } bool QPSQLDriver::hasFeature(DriverFeature f) const diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp index 4344af4..e5cc614 100644 --- a/src/sql/drivers/sqlite/qsql_sqlite.cpp +++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp @@ -452,7 +452,7 @@ QSqlRecord QSQLiteResult::record() const QVariant QSQLiteResult::handle() const { - return qVariantFromValue(d->stmt); + return QVariant::fromValue(d->stmt); } ///////////////////////////////////////////////////////// @@ -697,7 +697,7 @@ QSqlRecord QSQLiteDriver::record(const QString &tbl) const QVariant QSQLiteDriver::handle() const { - return qVariantFromValue(d->access); + return QVariant::fromValue(d->access); } QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierType type) const diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp index ea476e5..89f3ed3 100644 --- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp +++ b/src/sql/drivers/sqlite2/qsql_sqlite2.cpp @@ -342,7 +342,7 @@ QSqlRecord QSQLite2Result::record() const QVariant QSQLite2Result::handle() const { - return qVariantFromValue(d->currentMachine); + return QVariant::fromValue(d->currentMachine); } ///////////////////////////////////////////////////////// @@ -558,7 +558,7 @@ QSqlRecord QSQLite2Driver::record(const QString &tbl) const QVariant QSQLite2Driver::handle() const { - return qVariantFromValue(d->access); + return QVariant::fromValue(d->access); } QString QSQLite2Driver::escapeIdentifier(const QString &identifier, IdentifierType /*type*/) const diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index 633d635..aa9b2bd 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -159,7 +159,7 @@ template<> inline char *toString(const QVariant &v) if (!v.isNull()) { vstring.append(','); if (v.canConvert(QVariant::String)) { - vstring.append(qVariantValue(v).toLatin1()); + vstring.append(qvariant_cast(v).toLatin1()); } else { vstring.append(""); diff --git a/src/tools/uic3/converter.cpp b/src/tools/uic3/converter.cpp index 2ee939d..8fac4d1 100644 --- a/src/tools/uic3/converter.cpp +++ b/src/tools/uic3/converter.cpp @@ -864,7 +864,7 @@ DomLayoutItem *Ui3Reader::createLayoutItem(const QDomElement &e) Variant var; var.createSize(0, 0); - QVariant def = qVariantFromValue(var); + QVariant def = QVariant::fromValue(var); Size size = asVariant(DomTool::readProperty(e, QLatin1String("sizeHint"), def)).size; QString sizeType = QLatin1String("QSizePolicy::") + DomTool::readProperty(e, QLatin1String("sizeType"), QLatin1String("Expanding")).toString(); diff --git a/src/tools/uic3/domtool.cpp b/src/tools/uic3/domtool.cpp index 526b41c..cefbbb4 100644 --- a/src/tools/uic3/domtool.cpp +++ b/src/tools/uic3/domtool.cpp @@ -169,7 +169,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.createRect(x, y, w, h); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("point")) { QDomElement n3 = e.firstChild().toElement(); int x = 0, y = 0; @@ -181,7 +181,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.createPoint(x,y); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("size")) { QDomElement n3 = e.firstChild().toElement(); int w = 0, h = 0; @@ -193,10 +193,10 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.createSize(w, h); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("color")) { var.color = readColor(e); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("font")) { QDomElement n3 = e.firstChild().toElement(); Font f; @@ -217,7 +217,7 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu n3 = n3.nextSibling().toElement(); } var.font = f; - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("string")) { v = QVariant(e.firstChild().toText().data()); QDomElement n = e; @@ -258,10 +258,10 @@ QVariant DomTool::elementToVariant(const QDomElement& e, const QVariant& defValu var.sizePolicy.verstretch = n3.firstChild().toText().data().toInt(); n3 = n3.nextSibling().toElement(); } - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("cursor")) { var.createCursor(e.firstChild().toText().data().toInt()); - qVariantSetValue(v, var); + v.setValue(var); } else if (e.tagName() == QLatin1String("stringlist")) { QStringList lst; QDomElement n; diff --git a/src/tools/uic3/domtool.h b/src/tools/uic3/domtool.h index ad597a1..8fe0793 100644 --- a/src/tools/uic3/domtool.h +++ b/src/tools/uic3/domtool.h @@ -266,7 +266,7 @@ QT_BEGIN_NAMESPACE inline Variant asVariant(const QVariant &v) { Variant var; - var = qVariantValue(v); + var = qvariant_cast(v); return var; } diff --git a/src/xmlpatterns/api/quriloader.cpp b/src/xmlpatterns/api/quriloader.cpp index e0a7542..c653661 100644 --- a/src/xmlpatterns/api/quriloader.cpp +++ b/src/xmlpatterns/api/quriloader.cpp @@ -69,7 +69,7 @@ QNetworkReply *URILoader::createRequest(Operation op, const QNetworkRequest &req const QVariant variant(m_variableLoader->valueFor(m_namePool->allocateQName(QString(), name, QString()))); if(!variant.isNull() && variant.userType() == qMetaTypeId()) - return new QIODeviceDelegate(qVariantValue(variant)); + return new QIODeviceDelegate(qvariant_cast(variant)); else { /* If we're entering this code path, the variable URI identified a variable diff --git a/src/xmlpatterns/api/qvariableloader.cpp b/src/xmlpatterns/api/qvariableloader.cpp index 612fa67..648fda4 100644 --- a/src/xmlpatterns/api/qvariableloader.cpp +++ b/src/xmlpatterns/api/qvariableloader.cpp @@ -131,12 +131,12 @@ SequenceType::Ptr VariableLoader::announceExternalVariable(const QXmlName name, return CommonSequenceTypes::ExactlyOneAnyURI; else if(variant.userType() == qMetaTypeId()) { - const QXmlQuery variableQuery(qVariantValue(variant)); + const QXmlQuery variableQuery(qvariant_cast(variant)); return variableQuery.d->expression()->staticType(); } else { - return makeGenericSequenceType(AtomicValue::qtToXDMType(qVariantValue(variant)), + return makeGenericSequenceType(AtomicValue::qtToXDMType(qvariant_cast(variant)), Cardinality::exactlyOne()); } } @@ -154,12 +154,12 @@ Item::Iterator::Ptr VariableLoader::evaluateSequence(const QXmlName name, return makeSingletonIterator(itemForName(name)); else if(variant.userType() == qMetaTypeId()) { - const QXmlQuery variableQuery(qVariantValue(variant)); + const QXmlQuery variableQuery(qvariant_cast(variant)); return variableQuery.d->expression()->evaluateSequence(DynamicContext::Ptr(new TemporaryTreesRedirectingContext(variableQuery.d->dynamicContext(), context))); } - const QVariant v(qVariantValue(variant).toAtomicValue()); + const QVariant v(qvariant_cast(variant).toAtomicValue()); switch(v.type()) { @@ -179,7 +179,7 @@ Item VariableLoader::itemForName(const QXmlName &name) const if(variant.userType() == qMetaTypeId()) return Item(AnyURI::fromValue(QLatin1String("tag:trolltech.com,2007:QtXmlPatterns:QIODeviceVariable:") + m_namePool->stringForLocalName(name.localName()))); - const QXmlItem item(qVariantValue(variant)); + const QXmlItem item(qvariant_cast(variant)); if(item.isNode()) return Item::fromPublic(item); @@ -210,8 +210,8 @@ bool VariableLoader::isSameType(const QVariant &v1, return true; /* Ok, we have two QXmlItems. */ - const QXmlItem i1(qVariantValue(v1)); - const QXmlItem i2(qVariantValue(v2)); + const QXmlItem i1(qvariant_cast(v1)); + const QXmlItem i2(qvariant_cast(v2)); if(i1.isNode()) { diff --git a/src/xmlpatterns/api/qxmlquery.cpp b/src/xmlpatterns/api/qxmlquery.cpp index e106d74..0129af7 100644 --- a/src/xmlpatterns/api/qxmlquery.cpp +++ b/src/xmlpatterns/api/qxmlquery.cpp @@ -535,7 +535,7 @@ void QXmlQuery::bindVariable(const QXmlName &name, const QXmlItem &value) } const QPatternist::VariableLoader::Ptr vl(d->variableLoader()); - const QVariant variant(qVariantFromValue(value)); + const QVariant variant(QVariant::fromValue(value)); /* If the type of the variable changed(as opposed to only the value), * we will have to recompile. */ @@ -611,7 +611,7 @@ void QXmlQuery::bindVariable(const QXmlName &name, QIODevice *device) if(device) { - const QVariant variant(qVariantFromValue(device)); + const QVariant variant(QVariant::fromValue(device)); if(vl->invalidationRequired(name, variant)) d->recompileRequired(); @@ -1185,7 +1185,7 @@ void QXmlQuery::bindVariable(const QXmlName &name, const QXmlQuery &query) Q_ASSERT_X(query.isValid(), Q_FUNC_INFO, "The query being bound must be valid."); const QPatternist::VariableLoader::Ptr vl(d->variableLoader()); - const QVariant variant(qVariantFromValue(query)); + const QVariant variant(QVariant::fromValue(query)); if(vl->invalidationRequired(name, variant)) d->recompileRequired(); diff --git a/src/xmlpatterns/data/qatomicvalue.cpp b/src/xmlpatterns/data/qatomicvalue.cpp index c4f3578..5bb9a4f 100644 --- a/src/xmlpatterns/data/qatomicvalue.cpp +++ b/src/xmlpatterns/data/qatomicvalue.cpp @@ -121,7 +121,7 @@ QVariant AtomicValue::toQt(const AtomicValue *const value) || BuiltinTypes::xsHexBinary->xdtTypeMatches(t)) return QVariant(value->as()->asByteArray()); else if(BuiltinTypes::xsQName->xdtTypeMatches(t)) - return qVariantFromValue(value->as()->qName()); + return QVariant::fromValue(value->as()->qName()); else { /* A type we don't support in Qt. Includes xs:time currently. */ diff --git a/tools/activeqt/testcon/changeproperties.cpp b/tools/activeqt/testcon/changeproperties.cpp index e2ad601..b0609b0 100644 --- a/tools/activeqt/testcon/changeproperties.cpp +++ b/tools/activeqt/testcon/changeproperties.cpp @@ -108,7 +108,7 @@ void ChangeProperties::on_buttonSet_clicked() QColor col; col.setNamedColor(editValue->text()); if (col.isValid()) { - value = qVariantFromValue(col); + value = QVariant::fromValue(col); } else { QMessageBox::warning(this, tr("Can't parse input"), QString(tr("Failed to create a color from %1\n" @@ -122,7 +122,7 @@ void ChangeProperties::on_buttonSet_clicked() { QFont fnt; if (fnt.fromString(editValue->text())) { - value = qVariantFromValue(fnt); + value = QVariant::fromValue(fnt); } else { QMessageBox::warning(this, tr("Can't parse input"), (tr("Failed to create a font from %1\n" @@ -141,7 +141,7 @@ void ChangeProperties::on_buttonSet_clicked() if (pm.isNull()) return; - value = qVariantFromValue(pm); + value = QVariant::fromValue(pm); } break; case QVariant::Bool: diff --git a/tools/assistant/tools/assistant/bookmarkmanager.cpp b/tools/assistant/tools/assistant/bookmarkmanager.cpp index 23632b1..65888fe 100644 --- a/tools/assistant/tools/assistant/bookmarkmanager.cpp +++ b/tools/assistant/tools/assistant/bookmarkmanager.cpp @@ -283,7 +283,7 @@ void BookmarkManager::buildBookmarksMenu(const QModelIndex &index, QMenu* menu) return; const QString &text = index.data().toString(); - const QIcon &icon = qVariantValue(index.data(Qt::DecorationRole)); + const QIcon &icon = qvariant_cast(index.data(Qt::DecorationRole)); if (index.data(UserRoleFolder).toBool()) { if (QMenu* subMenu = menu->addMenu(icon, text)) { for (int i = 0; i < bookmarkModel->rowCount(index); ++i) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index 60b83f7..0a5445a 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -643,7 +643,7 @@ void HelpEngineWrapper::setUseBrowserFont(bool useBrowserFont) const QFont HelpEngineWrapper::appFont() const { TRACE_OBJ - return qVariantValue(d->m_helpEngine->customValue(AppFontKey)); + return qvariant_cast(d->m_helpEngine->customValue(AppFontKey)); } void HelpEngineWrapper::setAppFont(const QFont &font) @@ -668,7 +668,7 @@ void HelpEngineWrapper::setAppWritingSystem(QFontDatabase::WritingSystem system) const QFont HelpEngineWrapper::browserFont() const { TRACE_OBJ - return qVariantValue(d->m_helpEngine->customValue(BrowserFontKey)); + return qvariant_cast(d->m_helpEngine->customValue(BrowserFontKey)); } void HelpEngineWrapper::setBrowserFont(const QFont &font) diff --git a/tools/designer/src/components/formeditor/dpi_chooser.cpp b/tools/designer/src/components/formeditor/dpi_chooser.cpp index e79c757..1eadfa5 100644 --- a/tools/designer/src/components/formeditor/dpi_chooser.cpp +++ b/tools/designer/src/components/formeditor/dpi_chooser.cpp @@ -97,13 +97,13 @@ DPI_Chooser::DPI_Chooser(QWidget *parent) : m_systemEntry->description = 0; const struct DPI_Entry *systemEntry = m_systemEntry; //: System resolution - m_predefinedCombo->addItem(tr("System (%1 x %2)").arg(m_systemEntry->dpiX).arg(m_systemEntry->dpiY), qVariantFromValue(systemEntry)); + m_predefinedCombo->addItem(tr("System (%1 x %2)").arg(m_systemEntry->dpiX).arg(m_systemEntry->dpiY), QVariant::fromValue(systemEntry)); // Devices. Exclude the system values as not to duplicate the entries const int predefinedCount = sizeof(dpiEntries)/sizeof(DPI_Entry); const struct DPI_Entry *ecend = dpiEntries + predefinedCount; for (const struct DPI_Entry *it = dpiEntries; it < ecend; ++it) if (it->dpiX != m_systemEntry->dpiX || it->dpiY != m_systemEntry->dpiY) - m_predefinedCombo->addItem(tr(it->description), qVariantFromValue(it)); + m_predefinedCombo->addItem(tr(it->description), QVariant::fromValue(it)); m_predefinedCombo->addItem(tr("User defined")); setFocusProxy(m_predefinedCombo); diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index eeb63e5..ebf00f9 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -1523,7 +1523,7 @@ void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) QObjectList ol; foreach(QWidget *w, l) ol.push_back(w); - SetPropertyCommand::init(ol, QLatin1String("geometry"), qVariantFromValue(op)); + SetPropertyCommand::init(ol, QLatin1String("geometry"), QVariant::fromValue(op)); setText(op.resize ? FormWindow::tr("Key Resize") : FormWindow::tr("Key Move")); } @@ -1531,14 +1531,14 @@ void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) QVariant ArrowKeyPropertyCommand::mergeValue(const QVariant &newMergeValue) { // Merge move operations of the same arrow key - if (!qVariantCanConvert(newMergeValue)) + if (!newMergeValue.canConvert()) return QVariant(); ArrowKeyOperation mergedOperation = qvariant_cast(newValue()); const ArrowKeyOperation newMergeOperation = qvariant_cast(newMergeValue); if (mergedOperation.resize != newMergeOperation.resize || mergedOperation.arrowKey != newMergeOperation.arrowKey) return QVariant(); mergedOperation.distance += newMergeOperation.distance; - return qVariantFromValue(mergedOperation); + return QVariant::fromValue(mergedOperation); } void FormWindow::handleArrowKeyEvent(int key, Qt::KeyboardModifiers modifiers) @@ -2241,7 +2241,7 @@ QAction *FormWindow::createSelectAncestorSubMenu(QWidget *w) for (int i = 0; i < size; i++) { QWidget *w = parents.at(i); QAction *a = ag->addAction(objectNameOf(w)); - a->setData(qVariantFromValue(w)); + a->setData(QVariant::fromValue(w)); menu->addAction(a); } QAction *ma = new QAction(tr("Select Ancestor"), 0); @@ -2796,7 +2796,7 @@ bool FormWindow::dropDockWidget(QDesignerDnDItemInterface *item, const QPoint &g PropertySheetEnumValue e = qvariant_cast(propertySheet->property(propertySheet->indexOf(dockWidgetAreaName))); e.value = area; QVariant v; - qVariantSetValue(v, e); + v.setValue(e); SetPropertyCommand *cmd = new SetPropertyCommand(this); cmd->init(widget, dockWidgetAreaName, v); m_undoStack.push(cmd); diff --git a/tools/designer/src/components/formeditor/qdesigner_resource.cpp b/tools/designer/src/components/formeditor/qdesigner_resource.cpp index 135e23b..6c458f3 100644 --- a/tools/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/tools/designer/src/components/formeditor/qdesigner_resource.cpp @@ -197,7 +197,7 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co m_loadedQrcFiles.insert(QFileInfo(workingDirectory, dp->attributeResource()).absoluteFilePath(), false); #endif } - return qVariantFromValue(pixmap); + return QVariant::fromValue(pixmap); } case DomProperty::IconSet: { @@ -227,7 +227,7 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co m_loadedQrcFiles.insert(QFileInfo(workingDirectory, di->attributeResource()).absoluteFilePath(), false); #endif } - return qVariantFromValue(icon); + return QVariant::fromValue(icon); } default: break; @@ -237,12 +237,12 @@ QVariant QDesignerResourceBuilder::loadResource(const QDir &workingDirectory, co QVariant QDesignerResourceBuilder::toNativeValue(const QVariant &value) const { - if (qVariantCanConvert(value)) { + if (value.canConvert()) { if (m_pixmapCache) - return m_pixmapCache->pixmap(qVariantValue(value)); - } else if (qVariantCanConvert(value)) { + return m_pixmapCache->pixmap(qvariant_cast(value)); + } else if (value.canConvert()) { if (m_iconCache) - return m_iconCache->icon(qVariantValue(value)); + return m_iconCache->icon(qvariant_cast(value)); } return value; } @@ -250,7 +250,7 @@ QVariant QDesignerResourceBuilder::toNativeValue(const QVariant &value) const DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory, const QVariant &value) const { DomProperty *p = new DomProperty; - if (qVariantCanConvert(value)) { + if (value.canConvert()) { const PropertySheetPixmapValue pix = qvariant_cast(value); DomResourcePixmap *rp = new DomResourcePixmap; const QString pixPath = pix.path(); @@ -275,7 +275,7 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory } p->setElementPixmap(rp); return p; - } else if (qVariantCanConvert(value)) { + } else if (value.canConvert()) { const PropertySheetIconValue icon = qvariant_cast(value); const QMap, PropertySheetPixmapValue> pixmaps = icon.paths(); if (!pixmaps.isEmpty()) { @@ -331,7 +331,7 @@ DomProperty *QDesignerResourceBuilder::saveResource(const QDir &workingDirectory bool QDesignerResourceBuilder::isResourceType(const QVariant &value) const { - if (qVariantCanConvert(value) || qVariantCanConvert(value)) + if (value.canConvert() || value.canConvert()) return true; return false; } @@ -364,26 +364,26 @@ QVariant QDesignerTextBuilder::loadText(const DomProperty *text) const if (!translatable) strVal.setTranslatable(translatable); } - return qVariantFromValue(strVal); + return QVariant::fromValue(strVal); } QVariant QDesignerTextBuilder::toNativeValue(const QVariant &value) const { - if (qVariantCanConvert(value)) - return qVariantFromValue(qVariantValue(value).value()); + if (value.canConvert()) + return QVariant::fromValue(qvariant_cast(value).value()); return value; } DomProperty *QDesignerTextBuilder::saveText(const QVariant &value) const { - if (!qVariantCanConvert(value) && !qVariantCanConvert(value)) + if (!value.canConvert() && !value.canConvert()) return 0; DomProperty *property = new DomProperty(); DomString *domStr = new DomString(); - if (qVariantCanConvert(value)) { - PropertySheetStringValue str = qVariantValue(value); + if (value.canConvert()) { + PropertySheetStringValue str = qvariant_cast(value); domStr->setText(str.value()); @@ -475,7 +475,7 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) if (classVar.canConvert(QVariant::String)) classStr = classVar.toString(); else - classStr = qVariantValue(classVar).value(); + classStr = qvariant_cast(classVar).value(); ui->setElementClass(classStr); for (int index = 0; index < m_formWindow->toolCount(); ++index) { @@ -1045,7 +1045,7 @@ static bool readDomEnumerationValue(const DomProperty *p, switch (p->kind()) { case DomProperty::Set: { const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert(sheetValue)) { + if (sheetValue.canConvert()) { const PropertySheetFlagValue f = qvariant_cast(sheetValue); bool ok = false; v = f.metaFlags.parseFlags(p->elementSet(), &ok); @@ -1057,7 +1057,7 @@ static bool readDomEnumerationValue(const DomProperty *p, break; case DomProperty::Enum: { const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert(sheetValue)) { + if (sheetValue.canConvert()) { const PropertySheetEnumValue e = qvariant_cast(sheetValue); bool ok = false; v = e.metaEnum.parseEnum(p->elementEnum(), &ok); @@ -1110,7 +1110,7 @@ void QDesignerResource::applyProperties(QObject *o, const QList &p if (!translatable) keyVal.setTranslatable(translatable); } - v = qVariantFromValue(keyVal); + v = QVariant::fromValue(keyVal); } else { const DomString *str = p->elementString(); PropertySheetStringValue strVal(v.toString()); @@ -1124,7 +1124,7 @@ void QDesignerResource::applyProperties(QObject *o, const QList &p if (!translatable) strVal.setTranslatable(translatable); } - v = qVariantFromValue(strVal); + v = QVariant::fromValue(strVal); } } @@ -1135,18 +1135,18 @@ void QDesignerResource::applyProperties(QObject *o, const QList &p } else if (dynamicPropertiesAllowed) { QVariant defaultValue = QVariant(v.type()); bool isDefault = (v == defaultValue); - if (qVariantCanConvert(v)) { + if (v.canConvert()) { defaultValue = QVariant(QVariant::Icon); - isDefault = (qVariantValue(v) == PropertySheetIconValue()); - } else if (qVariantCanConvert(v)) { + isDefault = (qvariant_cast(v) == PropertySheetIconValue()); + } else if (v.canConvert()) { defaultValue = QVariant(QVariant::Pixmap); - isDefault = (qVariantValue(v) == PropertySheetPixmapValue()); - } else if (qVariantCanConvert(v)) { + isDefault = (qvariant_cast(v) == PropertySheetPixmapValue()); + } else if (v.canConvert()) { defaultValue = QVariant(QVariant::String); - isDefault = (qVariantValue(v) == PropertySheetStringValue()); - } else if (qVariantCanConvert(v)) { + isDefault = (qvariant_cast(v) == PropertySheetStringValue()); + } else if (v.canConvert()) { defaultValue = QVariant(QVariant::KeySequence); - isDefault = (qVariantValue(v) == PropertySheetKeySequenceValue()); + isDefault = (qvariant_cast(v) == PropertySheetKeySequenceValue()); } if (defaultValue.type() != QVariant::UserType) { const int idx = dynamicSheet->addDynamicProperty(p->attributeName(), defaultValue); @@ -1185,12 +1185,12 @@ QWidget *QDesignerResource::createWidget(const QString &widgetName, QWidget *par if (!qobject_cast(w) && (!parentWidget || !container)) { m_formWindow->manageWidget(w); if (parentWidget) { - QList list = qVariantValue(parentWidget->property("_q_widgetOrder")); + QList list = qvariant_cast(parentWidget->property("_q_widgetOrder")); list.append(w); - parentWidget->setProperty("_q_widgetOrder", qVariantFromValue(list)); - QList zOrder = qVariantValue(parentWidget->property("_q_zOrder")); + parentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(list)); + QList zOrder = qvariant_cast(parentWidget->property("_q_zOrder")); zOrder.append(w); - parentWidget->setProperty("_q_zOrder", qVariantFromValue(list)); + parentWidget->setProperty("_q_zOrder", QVariant::fromValue(list)); } } else { core()->metaDataBase()->add(w); @@ -1605,8 +1605,8 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `icon' widget->setCurrentIndex(i); QDesignerPropertySheetExtension *sheet = qt_extension(core()->extensionManager(), widget); - PropertySheetIconValue icon = qVariantValue(sheet->property(sheet->indexOf(QLatin1String("currentTabIcon")))); - DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), qVariantFromValue(icon)); + PropertySheetIconValue icon = qvariant_cast(sheet->property(sheet->indexOf(QLatin1String("currentTabIcon")))); + DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon)); if (p) { p->setAttributeName(strings.iconAttribute); ui_attribute_list.append(p); @@ -1620,7 +1620,7 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `toolTip' QVariant v = sheet->property(sheet->indexOf(QLatin1String("currentTabToolTip"))); - if (!qVariantValue(v).value().isEmpty()) { + if (!qvariant_cast(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { p->setAttributeName(strings.toolTipAttribute); @@ -1630,7 +1630,7 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `whatsThis' v = sheet->property(sheet->indexOf(QLatin1String("currentTabWhatsThis"))); - if (!qVariantValue(v).value().isEmpty()) { + if (!qvariant_cast(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { p->setAttributeName(strings.whatsThisAttribute); @@ -1676,8 +1676,8 @@ DomWidget *QDesignerResource::saveWidget(QToolBox *widget, DomWidget *ui_parentW // attribute `icon' widget->setCurrentIndex(i); QDesignerPropertySheetExtension *sheet = qt_extension(core()->extensionManager(), widget); - PropertySheetIconValue icon = qVariantValue(sheet->property(sheet->indexOf(QLatin1String("currentItemIcon")))); - DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), qVariantFromValue(icon)); + PropertySheetIconValue icon = qvariant_cast(sheet->property(sheet->indexOf(QLatin1String("currentItemIcon")))); + DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon)); if (p) { p->setAttributeName(strings.iconAttribute); ui_attribute_list.append(p); @@ -1690,7 +1690,7 @@ DomWidget *QDesignerResource::saveWidget(QToolBox *widget, DomWidget *ui_parentW // attribute `toolTip' QVariant v = sheet->property(sheet->indexOf(QLatin1String("currentItemToolTip"))); - if (!qVariantValue(v).value().isEmpty()) { + if (!qvariant_cast(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { p->setAttributeName(strings.toolTipAttribute); @@ -2209,8 +2209,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p return 0; } - if (qVariantCanConvert(value)) { - const PropertySheetFlagValue f = qVariantValue(value); + if (value.canConvert()) { + const PropertySheetFlagValue f = qvariant_cast(value); const QString flagString = f.metaFlags.toString(f.value, DesignerMetaFlags::FullyQualified); if (flagString.isEmpty()) return 0; @@ -2222,8 +2222,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p p->setAttributeName(propertyName); p->setElementSet(flagString); return applyProperStdSetAttribute(object, propertyName, p); - } else if (qVariantCanConvert(value)) { - const PropertySheetEnumValue e = qVariantValue(value); + } else if (value.canConvert()) { + const PropertySheetEnumValue e = qvariant_cast(value); bool ok; const QString id = e.metaEnum.toString(e.value, DesignerMetaEnum::FullyQualified, &ok); if (!ok) @@ -2238,8 +2238,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p p->setAttributeName(propertyName); p->setElementEnum(id); return applyProperStdSetAttribute(object, propertyName, p); - } else if (qVariantCanConvert(value)) { - const PropertySheetStringValue strVal = qVariantValue(value); + } else if (value.canConvert()) { + const PropertySheetStringValue strVal = qvariant_cast(value); DomProperty *p = new DomProperty; if (!hasSetter(core(), object, propertyName)) p->setAttributeStdset(0); @@ -2249,8 +2249,8 @@ DomProperty *QDesignerResource::createProperty(QObject *object, const QString &p saveStringProperty(p, strVal); return applyProperStdSetAttribute(object, propertyName, p); - } else if (qVariantCanConvert(value)) { - const PropertySheetKeySequenceValue keyVal = qVariantValue(value); + } else if (value.canConvert()) { + const PropertySheetKeySequenceValue keyVal = qvariant_cast(value); DomProperty *p = new DomProperty; if (!hasSetter(core(), object, propertyName)) p->setAttributeStdset(0); diff --git a/tools/designer/src/components/objectinspector/objectinspectormodel.cpp b/tools/designer/src/components/objectinspector/objectinspectormodel.cpp index 93e1df1..4bbacdb 100644 --- a/tools/designer/src/components/objectinspector/objectinspectormodel.cpp +++ b/tools/designer/src/components/objectinspector/objectinspectormodel.cpp @@ -273,7 +273,7 @@ namespace qdesigner_internal { void ObjectData::setItems(const StandardItemList &row, const ObjectInspectorIcons &icons) const { - const QVariant object = qVariantFromValue(m_object); + const QVariant object = QVariant::fromValue(m_object); row[ObjectInspectorModel::ObjectNameColumn]->setData(object, DataRole); row[ObjectInspectorModel::ClassNameColumn]->setData(object, DataRole); setItemsDisplayData(row, icons, ClassNameChanged|ObjectNameChanged|ClassIconChanged|TypeChanged|LayoutTypeChanged); diff --git a/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp b/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp index 2300b47..fffdc29 100644 --- a/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/tools/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -163,7 +163,7 @@ void BrushPropertyManager::initializeProperty(QtVariantPropertyManager *vm, QtPr for (int i = 0; i < brushStyleCount; i++) styles.push_back(QCoreApplication::translate("BrushPropertyManager", brushStyles[i])); styleSubProperty->setAttribute(QLatin1String("enumNames"), styles); - styleSubProperty->setAttribute(QLatin1String("enumIcons"), qVariantFromValue(brushStyleIcons())); + styleSubProperty->setAttribute(QLatin1String("enumIcons"), QVariant::fromValue(brushStyleIcons())); m_brushPropertyToStyleSubProperty.insert(property, styleSubProperty); m_brushStyleSubPropertyToProperty.insert(styleSubProperty, property); // color diff --git a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp index 9ab2940..e251511 100644 --- a/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/tools/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -740,7 +740,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari m_changingSubValue = false; data.val = newValue; QVariant v; - qVariantSetValue(v, data.val); + v.setValue(data.val); variantProperty(flagProperty)->setValue(v); } else if (QtProperty *alignProperty = m_alignHToProperty.value(property, 0)) { const uint v = m_alignValues.value(alignProperty); @@ -763,7 +763,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(stringProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(stringProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *stringProperty = m_translatableToString.value(property, 0)) { const PropertySheetStringValue v = m_stringValues.value(stringProperty); PropertySheetStringValue newValue = v; @@ -771,7 +771,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(stringProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(stringProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *stringProperty = m_disambiguationToString.value(property, 0)) { const PropertySheetStringValue v = m_stringValues.value(stringProperty); PropertySheetStringValue newValue = v; @@ -779,7 +779,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(stringProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(stringProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *keySequenceProperty = m_commentToKeySequence.value(property, 0)) { const PropertySheetKeySequenceValue v = m_keySequenceValues.value(keySequenceProperty); PropertySheetKeySequenceValue newValue = v; @@ -787,7 +787,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(keySequenceProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(keySequenceProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *keySequenceProperty = m_translatableToKeySequence.value(property, 0)) { const PropertySheetKeySequenceValue v = m_keySequenceValues.value(keySequenceProperty); PropertySheetKeySequenceValue newValue = v; @@ -795,7 +795,7 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(keySequenceProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(keySequenceProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *keySequenceProperty = m_disambiguationToKeySequence.value(property, 0)) { const PropertySheetKeySequenceValue v = m_keySequenceValues.value(keySequenceProperty); PropertySheetKeySequenceValue newValue = v; @@ -803,16 +803,16 @@ void DesignerPropertyManager::slotValueChanged(QtProperty *property, const QVari if (v == newValue) return; - variantProperty(keySequenceProperty)->setValue(qVariantFromValue(newValue)); + variantProperty(keySequenceProperty)->setValue(QVariant::fromValue(newValue)); } else if (QtProperty *iProperty = m_iconSubPropertyToProperty.value(property, 0)) { QtVariantProperty *iconProperty = variantProperty(iProperty); - PropertySheetIconValue icon = qVariantValue(iconProperty->value()); + PropertySheetIconValue icon = qvariant_cast(iconProperty->value()); QPair pair = m_iconSubPropertyToState.value(property); - icon.setPixmap(pair.first, pair.second, qVariantValue(value)); + icon.setPixmap(pair.first, pair.second, qvariant_cast(value)); QtProperty *origSourceOfChange = m_sourceOfChange; if (!origSourceOfChange) m_sourceOfChange = property; - iconProperty->setValue(qVariantFromValue(icon)); + iconProperty->setValue(QVariant::fromValue(icon)); if (!origSourceOfChange) m_sourceOfChange = origSourceOfChange; } else if (m_iconValues.contains(property)) { @@ -933,7 +933,7 @@ QVariant DesignerPropertyManager::attributeValue(const QtProperty *property, con PropertyFlagDataMap::const_iterator it = m_flagValues.constFind(prop); if (it != m_flagValues.constEnd()) { QVariant v; - qVariantSetValue(v, it.value().flags); + v.setValue(it.value().flags); return v; } } @@ -985,7 +985,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != designerFlagListTypeId()) return; - const DesignerFlagList flags = qVariantValue(value); + const DesignerFlagList flags = qvariant_cast(value); PropertyFlagDataMap::iterator fit = m_flagValues.find(property); FlagData data = fit.value(); if (data.flags == flags) @@ -1022,7 +1022,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, fit.value() = data; QVariant v; - qVariantSetValue(v, flags); + v.setValue(flags); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1061,7 +1061,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != QVariant::Palette) return; - QPalette superPalette = qVariantValue(value); + QPalette superPalette = qvariant_cast(value); const PropertyPaletteDataMap::iterator it = m_paletteValues.find(property); PaletteData data = it.value(); @@ -1077,7 +1077,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, it.value() = data; QVariant v; - qVariantSetValue(v, superPalette); + v.setValue(superPalette); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1086,7 +1086,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != QVariant::Pixmap) return; - QPixmap defaultPixmap = qVariantValue(value); + QPixmap defaultPixmap = qvariant_cast(value); const QMap::iterator it = m_defaultPixmaps.find(property); QPixmap oldDefaultPixmap = it.value(); @@ -1095,7 +1095,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, it.value() = defaultPixmap; - QVariant v = qVariantFromValue(defaultPixmap); + QVariant v = QVariant::fromValue(defaultPixmap); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1103,7 +1103,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, if (value.userType() != QVariant::Icon) return; - QIcon defaultIcon = qVariantValue(value); + QIcon defaultIcon = qvariant_cast(value); const QMap::iterator it = m_defaultIcons.find(property); QIcon oldDefaultIcon = it.value(); @@ -1124,7 +1124,7 @@ void DesignerPropertyManager::setAttribute(QtProperty *property, } } - QVariant v = qVariantFromValue(defaultIcon); + QVariant v = QVariant::fromValue(defaultIcon); emit attributeChanged(property, attribute, v); emit propertyChanged(property); @@ -1265,12 +1265,12 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const return m_stringListValues.value(const_cast(property)).join(QLatin1String("; ")); } if (QtVariantPropertyManager::valueType(property) == QVariant::String || QtVariantPropertyManager::valueType(property) == designerStringTypeId()) { - const QString str = (QtVariantPropertyManager::valueType(property) == QVariant::String) ? value(property).toString() : qVariantValue(value(property)).value(); + const QString str = (QtVariantPropertyManager::valueType(property) == QVariant::String) ? value(property).toString() : qvariant_cast(value(property)).value(); const int validationMode = attributeValue(property, QLatin1String(validationModesAttributeC)).toInt(); return TextPropertyEditor::stringToEditorString(str, static_cast(validationMode)); } if (QtVariantPropertyManager::valueType(property) == designerKeySequenceTypeId()) { - return qVariantValue(value(property)).value(); + return qvariant_cast(value(property)).value(); } if (QtVariantPropertyManager::valueType(property) == QVariant::Bool) { return QString(); @@ -1313,13 +1313,13 @@ void DesignerPropertyManager::reloadResourceProperties() } emit propertyChanged(property); - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(itIcon.value())); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(itIcon.value())); } QMapIterator itPix(m_pixmapValues); while (itPix.hasNext()) { QtProperty *property = itPix.next().key(); emit propertyChanged(property); - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(itPix.value())); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(itPix.value())); } } @@ -1357,13 +1357,13 @@ QVariant DesignerPropertyManager::value(const QtProperty *property) const if (m_paletteValues.contains(const_cast(property))) return m_paletteValues.value(const_cast(property)).val; if (m_iconValues.contains(const_cast(property))) - return qVariantFromValue(m_iconValues.value(const_cast(property))); + return QVariant::fromValue(m_iconValues.value(const_cast(property))); if (m_pixmapValues.contains(const_cast(property))) - return qVariantFromValue(m_pixmapValues.value(const_cast(property))); + return QVariant::fromValue(m_pixmapValues.value(const_cast(property))); if (m_stringValues.contains(const_cast(property))) - return qVariantFromValue(m_stringValues.value(const_cast(property))); + return QVariant::fromValue(m_stringValues.value(const_cast(property))); if (m_keySequenceValues.contains(const_cast(property))) - return qVariantFromValue(m_keySequenceValues.value(const_cast(property))); + return QVariant::fromValue(m_keySequenceValues.value(const_cast(property))); if (m_uintValues.contains(const_cast(property))) return m_uintValues.value(const_cast(property)); if (m_longLongValues.contains(const_cast(property))) @@ -1497,7 +1497,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerStringTypeId()) return; - const PropertySheetStringValue v = qVariantValue(value); + const PropertySheetStringValue v = qvariant_cast(value); const PropertySheetStringValue val = m_stringValues.value(property); @@ -1517,7 +1517,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val m_stringValues[property] = v; - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(v)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(v)); emit propertyChanged(property); return; @@ -1525,7 +1525,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerKeySequenceTypeId()) return; - const PropertySheetKeySequenceValue v = qVariantValue(value); + const PropertySheetKeySequenceValue v = qvariant_cast(value); const PropertySheetKeySequenceValue val = m_keySequenceValues.value(property); @@ -1545,7 +1545,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val m_keySequenceValues[property] = v; - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(v)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(v)); emit propertyChanged(property); return; @@ -1553,7 +1553,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.type() != QVariant::Palette && !value.canConvert(QVariant::Palette)) return; - QPalette p = qVariantValue(value); + QPalette p = qvariant_cast(value); PaletteData data = m_paletteValues.value(property); @@ -1575,7 +1575,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerIconTypeId()) return; - const PropertySheetIconValue icon = qVariantValue(value); + const PropertySheetIconValue icon = qvariant_cast(value); const PropertySheetIconValue oldIcon = m_iconValues.value(property); if (icon == oldIcon) @@ -1600,12 +1600,12 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val QtVariantProperty *subProperty = variantProperty(itSub.value()); bool hasPath = iconPaths.contains(pair); subProperty->setModified(hasPath); - subProperty->setValue(qVariantFromValue(iconPaths.value(pair))); + subProperty->setValue(QVariant::fromValue(iconPaths.value(pair))); subProperty->setAttribute(QLatin1String(defaultResourceAttributeC), defaultIcon.pixmap(16, 16, pair.first, pair.second)); } - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(icon)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(icon)); emit propertyChanged(property); QString toolTip; @@ -1620,7 +1620,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (value.userType() != designerPixmapTypeId()) return; - const PropertySheetPixmapValue pixmap = qVariantValue(value); + const PropertySheetPixmapValue pixmap = qvariant_cast(value); const PropertySheetPixmapValue oldPixmap = m_pixmapValues.value(property); if (pixmap == oldPixmap) @@ -1628,7 +1628,7 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val m_pixmapValues[property] = pixmap; - emit QtVariantPropertyManager::valueChanged(property, qVariantFromValue(pixmap)); + emit QtVariantPropertyManager::valueChanged(property, QVariant::fromValue(pixmap)); emit propertyChanged(property); property->setToolTip(pixmap.path()); @@ -1746,9 +1746,9 @@ void DesignerPropertyManager::setValue(QtProperty *property, const QVariant &val if (QtVariantPropertyManager::valueType(property) == QVariant::String) property->setToolTip(DesignerPropertyManager::value(property).toString()); else if (QtVariantPropertyManager::valueType(property) == designerStringTypeId()) - property->setToolTip(qVariantValue(DesignerPropertyManager::value(property)).value()); + property->setToolTip(qvariant_cast(DesignerPropertyManager::value(property)).value()); else if (QtVariantPropertyManager::valueType(property) == designerKeySequenceTypeId()) - property->setToolTip(qVariantValue(DesignerPropertyManager::value(property)).value()); + property->setToolTip(qvariant_cast(DesignerPropertyManager::value(property)).value()); else if (QtVariantPropertyManager::valueType(property) == QVariant::Bool) property->setToolTip(QtVariantPropertyManager::valueText(property)); } @@ -2017,7 +2017,7 @@ bool DesignerPropertyManager::resetIconSubProperty(QtProperty *property) return false; QtVariantProperty *pixmapProperty = variantProperty(property); - pixmapProperty->setValue(qVariantFromValue(PropertySheetPixmapValue())); + pixmapProperty->setValue(QVariant::fromValue(PropertySheetPixmapValue())); return true; } @@ -2131,7 +2131,7 @@ void DesignerEditorFactory::slotPropertyChanged(QtProperty *property) if (!property->isModified()) defaultPixmap = qvariant_cast(manager->attributeValue(property, QLatin1String(defaultResourceAttributeC))).pixmap(16, 16); else if (m_fwb) - defaultPixmap = m_fwb->iconCache()->icon(qVariantValue(manager->value(property))).pixmap(16, 16); + defaultPixmap = m_fwb->iconCache()->icon(qvariant_cast(manager->value(property))).pixmap(16, 16); QList editors = m_iconPropertyToEditors.value(property); QListIterator it(editors); while (it.hasNext()) { @@ -2175,13 +2175,13 @@ void DesignerEditorFactory::slotValueChanged(QtProperty *property, const QVarian break; default: if (type == DesignerPropertyManager::designerIconTypeId()) - applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setPath, qVariantValue(value).pixmap(QIcon::Normal, QIcon::Off).path()); + applyToEditors(m_iconPropertyToEditors.value(property), &PixmapEditor::setPath, qvariant_cast(value).pixmap(QIcon::Normal, QIcon::Off).path()); else if (type == DesignerPropertyManager::designerPixmapTypeId()) - applyToEditors(m_pixmapPropertyToEditors.value(property), &PixmapEditor::setPath, qVariantValue(value).path()); + applyToEditors(m_pixmapPropertyToEditors.value(property), &PixmapEditor::setPath, qvariant_cast(value).path()); else if (type == DesignerPropertyManager::designerStringTypeId()) - applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setText, qVariantValue(value).value()); + applyToEditors(m_stringPropertyToEditors.value(property), &TextEditor::setText, qvariant_cast(value).value()); else if (type == DesignerPropertyManager::designerKeySequenceTypeId()) - applyToEditors(m_keySequencePropertyToEditors.value(property), &QtKeySequenceEdit::setKeySequence, qVariantValue(value).value()); + applyToEditors(m_keySequencePropertyToEditors.value(property), &QtKeySequenceEdit::setKeySequence, qvariant_cast(value).value()); break; } } @@ -2324,7 +2324,7 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager, editor = ed; } else if (type == DesignerPropertyManager::designerStringTypeId()) { const TextPropertyValidationMode tvm = static_cast(manager->attributeValue(property, QLatin1String(validationModesAttributeC)).toInt()); - TextEditor *ed = createTextEditor(parent, tvm, qVariantValue(manager->value(property)).value()); + TextEditor *ed = createTextEditor(parent, tvm, qvariant_cast(manager->value(property)).value()); const QVariant richTextDefaultFont = manager->attributeValue(property, QLatin1String(fontAttributeC)); if (richTextDefaultFont.type() == QVariant::Font) ed->setRichTextDefaultFont(qvariant_cast(richTextDefaultFont)); @@ -2335,7 +2335,7 @@ QWidget *DesignerEditorFactory::createEditor(QtVariantPropertyManager *manager, editor = ed; } else if (type == DesignerPropertyManager::designerKeySequenceTypeId()) { QtKeySequenceEdit *ed = new QtKeySequenceEdit(parent); - ed->setKeySequence(qVariantValue(manager->value(property)).value()); + ed->setKeySequence(qvariant_cast(manager->value(property)).value()); m_keySequencePropertyToEditors[property].append(ed); m_editorToKeySequenceProperty[ed] = property; connect(ed, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); @@ -2456,12 +2456,12 @@ void DesignerEditorFactory::slotStringTextChanged(const QString &value) QtVariantProperty *varProp = manager->variantProperty(prop); QVariant val = varProp->value(); if (val.userType() == DesignerPropertyManager::designerStringTypeId()) { - PropertySheetStringValue strVal = qVariantValue(val); + PropertySheetStringValue strVal = qvariant_cast(val); strVal.setValue(value); // Disable translation if no translation subproperties exist. if (varProp->subProperties().empty()) strVal.setTranslatable(false); - val = qVariantFromValue(strVal); + val = QVariant::fromValue(strVal); } else { val = QVariant(value); } @@ -2482,11 +2482,11 @@ void DesignerEditorFactory::slotKeySequenceChanged(const QKeySequence &value) QtVariantProperty *varProp = manager->variantProperty(prop); QVariant val = varProp->value(); if (val.userType() == DesignerPropertyManager::designerKeySequenceTypeId()) { - PropertySheetKeySequenceValue keyVal = qVariantValue(val); + PropertySheetKeySequenceValue keyVal = qvariant_cast(val); keyVal.setValue(value); - val = qVariantFromValue(keyVal); + val = QVariant::fromValue(keyVal); } else { - val = qVariantFromValue(value); + val = QVariant::fromValue(value); } m_changingPropertyValue = true; manager->variantProperty(prop)->setValue(val); @@ -2497,24 +2497,24 @@ void DesignerEditorFactory::slotKeySequenceChanged(const QKeySequence &value) void DesignerEditorFactory::slotPaletteChanged(const QPalette &value) { - updateManager(this, &m_changingPropertyValue, m_editorToPaletteProperty, qobject_cast(sender()), qVariantFromValue(value)); + updateManager(this, &m_changingPropertyValue, m_editorToPaletteProperty, qobject_cast(sender()), QVariant::fromValue(value)); } void DesignerEditorFactory::slotPixmapChanged(const QString &value) { updateManager(this, &m_changingPropertyValue, m_editorToPixmapProperty, qobject_cast(sender()), - qVariantFromValue(PropertySheetPixmapValue(value))); + QVariant::fromValue(PropertySheetPixmapValue(value))); } void DesignerEditorFactory::slotIconChanged(const QString &value) { updateManager(this, &m_changingPropertyValue, m_editorToIconProperty, qobject_cast(sender()), - qVariantFromValue(PropertySheetIconValue(PropertySheetPixmapValue(value)))); + QVariant::fromValue(PropertySheetIconValue(PropertySheetPixmapValue(value)))); } void DesignerEditorFactory::slotStringListChanged(const QStringList &value) { - updateManager(this, &m_changingPropertyValue, m_editorToStringListProperty, qobject_cast(sender()), qVariantFromValue(value)); + updateManager(this, &m_changingPropertyValue, m_editorToStringListProperty, qobject_cast(sender()), QVariant::fromValue(value)); } ResetDecorator::~ResetDecorator() diff --git a/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp b/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp index 9442b01..419834e 100644 --- a/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp +++ b/tools/designer/src/components/propertyeditor/fontpropertymanager.cpp @@ -123,7 +123,7 @@ namespace qdesigner_internal { // This will cause a recursion QtVariantProperty *antialiasing = vm->addProperty(enumTypeId, QCoreApplication::translate("FontPropertyManager", "Antialiasing")); - const QFont font = qVariantValue(vm->variantProperty(property)->value()); + const QFont font = qvariant_cast(vm->variantProperty(property)->value()); antialiasing->setAttribute(QLatin1String("enumNames"), m_aliasingEnumNames); antialiasing->setValue(antialiasingToIndex(font.styleStrategy())); @@ -196,7 +196,7 @@ namespace qdesigner_internal { mask &= ~flag; font.resolve(mask); - qVariantSetValue(v, font); + v.setValue(font); fontProperty->setValue(v); return true; } @@ -250,13 +250,13 @@ namespace qdesigner_internal { QtVariantProperty *fontProperty = vm->variantProperty(antialiasingProperty); const QFont::StyleStrategy newValue = indexToAntialiasing(value.toInt()); - QFont font = qVariantValue(fontProperty->value()); + QFont font = qvariant_cast(fontProperty->value()); const QFont::StyleStrategy oldValue = font.styleStrategy(); if (newValue == oldValue) return Unchanged; font.setStyleStrategy(newValue); - fontProperty->setValue(qVariantFromValue(font)); + fontProperty->setValue(QVariant::fromValue(font)); return Changed; } @@ -268,7 +268,7 @@ namespace qdesigner_internal { const PropertyList &subProperties = it.value(); - QFont font = qVariantValue(value); + QFont font = qvariant_cast(value); const unsigned mask = font.resolve(); const int count = subProperties.size(); @@ -285,7 +285,7 @@ namespace qdesigner_internal { if (QtProperty *antialiasingProperty = m_propertyToAntialiasing.value(property, 0)) { QtVariantProperty *antialiasing = vm->variantProperty(antialiasingProperty); if (antialiasing) { - QFont font = qVariantValue(value); + QFont font = qvariant_cast(value); antialiasing->setValue(antialiasingToIndex(font.styleStrategy())); } } diff --git a/tools/designer/src/components/propertyeditor/paletteeditor.cpp b/tools/designer/src/components/propertyeditor/paletteeditor.cpp index 067946b..5c4cbcc 100644 --- a/tools/designer/src/components/propertyeditor/paletteeditor.cpp +++ b/tools/designer/src/components/propertyeditor/paletteeditor.cpp @@ -294,7 +294,7 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int return false; if (index.column() != 0 && role == BrushRole) { - const QBrush br = qVariantValue(value); + const QBrush br = qvariant_cast(value); const QPalette::ColorRole r = static_cast(index.row()); const QPalette::ColorGroup g = columnToGroup(index.column()); m_palette.setBrush(g, r, br); @@ -336,7 +336,7 @@ bool PaletteModel::setData(const QModelIndex &index, const QVariant &value, int } if (index.column() == 0 && role == Qt::EditRole) { uint mask = m_palette.resolve(); - const bool isMask = qVariantValue(value); + const bool isMask = qvariant_cast(value); const int r = index.row(); if (isMask) mask |= (1 << r); @@ -532,13 +532,13 @@ QWidget *ColorDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem void ColorDelegate::setEditorData(QWidget *ed, const QModelIndex &index) const { if (index.column() == 0) { - const bool mask = qVariantValue(index.model()->data(index, Qt::EditRole)); + const bool mask = qvariant_cast(index.model()->data(index, Qt::EditRole)); RoleEditor *editor = static_cast(ed); editor->setEdited(mask); - const QString colorName = qVariantValue(index.model()->data(index, Qt::DisplayRole)); + const QString colorName = qvariant_cast(index.model()->data(index, Qt::DisplayRole)); editor->setLabel(colorName); } else { - const QBrush br = qVariantValue(index.model()->data(index, BrushRole)); + const QBrush br = qvariant_cast(index.model()->data(index, BrushRole)); BrushEditor *editor = static_cast(ed); editor->setBrush(br); } @@ -571,11 +571,11 @@ void ColorDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opt, const QModelIndex &index) const { QStyleOptionViewItem option = opt; - const bool mask = qVariantValue(index.model()->data(index, Qt::EditRole)); + const bool mask = qvariant_cast(index.model()->data(index, Qt::EditRole)); if (index.column() == 0 && mask) { option.font.setBold(true); } - QBrush br = qVariantValue(index.model()->data(index, BrushRole)); + QBrush br = qvariant_cast(index.model()->data(index, BrushRole)); if (br.style() == Qt::LinearGradientPattern || br.style() == Qt::RadialGradientPattern || br.style() == Qt::ConicalGradientPattern) { diff --git a/tools/designer/src/components/propertyeditor/propertyeditor.cpp b/tools/designer/src/components/propertyeditor/propertyeditor.cpp index a8ca8ad..7296636 100644 --- a/tools/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/tools/designer/src/components/propertyeditor/propertyeditor.cpp @@ -872,12 +872,12 @@ void PropertyEditor::updateBrowserValue(QtVariantProperty *property, const QVari int PropertyEditor::toBrowserType(const QVariant &value, const QString &propertyName) const { - if (qVariantCanConvert(value)) { + if (value.canConvert()) { if (m_strings.m_alignmentProperties.contains(propertyName)) return DesignerPropertyManager::designerAlignmentTypeId(); return DesignerPropertyManager::designerFlagTypeId(); } - if (qVariantCanConvert(value)) + if (value.canConvert()) return DesignerPropertyManager::enumTypeId(); return value.userType(); @@ -1034,7 +1034,7 @@ void PropertyEditor::setObject(QObject *object) } m_updatingBrowser = true; QVariant v; - qVariantSetValue(v, flags); + v.setValue(flags); property->setAttribute(m_strings.m_flagsAttribute, v); m_updatingBrowser = false; } @@ -1223,7 +1223,7 @@ void PropertyEditor::slotValueChanged(QtProperty *property, const QVariant &valu e.value = e.metaEnum.parseEnum(valName, &ok); Q_ASSERT(ok); QVariant v; - qVariantSetValue(v, e); + v.setValue(e); emitPropertyValueChanged(property->propertyName(), v, true); return; } diff --git a/tools/designer/src/components/signalsloteditor/connectdialog.cpp b/tools/designer/src/components/signalsloteditor/connectdialog.cpp index ff6be16..abd2e83 100644 --- a/tools/designer/src/components/signalsloteditor/connectdialog.cpp +++ b/tools/designer/src/components/signalsloteditor/connectdialog.cpp @@ -231,7 +231,7 @@ void ConnectDialog::populateSlotList(const QString &signal) QFont font = QApplication::font(); font.setItalic(true); - QVariant variantFont = qVariantFromValue(font); + QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap::ConstIterator itMember = memberToClassName.constBegin(); @@ -271,7 +271,7 @@ void ConnectDialog::populateSignalList() QFont font = QApplication::font(); font.setItalic(true); - QVariant variantFont = qVariantFromValue(font); + QVariant variantFont = QVariant::fromValue(font); QListWidgetItem *curr = 0; QMap::ConstIterator itMember = memberToClassName.constBegin(); diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 530f176..6cfc286 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -473,7 +473,7 @@ void InlineEditorModel::addTextList(const QMap &text_list) insertRows(cnt, text_list.size()); QFont font = QApplication::font(); font.setItalic(true); - QVariant fontVariant = qVariantFromValue(font); + QVariant fontVariant = QVariant::fromValue(font); QMap::ConstIterator it = text_list.constBegin(); const QMap::ConstIterator itEnd = text_list.constEnd(); while (it != itEnd) { diff --git a/tools/designer/src/components/tabordereditor/tabordereditor.cpp b/tools/designer/src/components/tabordereditor/tabordereditor.cpp index 37acabc..f877654 100644 --- a/tools/designer/src/components/tabordereditor/tabordereditor.cpp +++ b/tools/designer/src/components/tabordereditor/tabordereditor.cpp @@ -239,7 +239,7 @@ void TabOrderEditor::initTabOrder() childQueue.append(formWindow()->mainContainer()); while (!childQueue.isEmpty()) { QWidget *child = childQueue.takeFirst(); - childQueue += qVariantValue(child->property("_q_widgetOrder")); + childQueue += qvariant_cast(child->property("_q_widgetOrder")); if (skipWidget(child)) continue; diff --git a/tools/designer/src/components/taskmenu/button_taskmenu.cpp b/tools/designer/src/components/taskmenu/button_taskmenu.cpp index 6b91c60..e178ebc 100644 --- a/tools/designer/src/components/taskmenu/button_taskmenu.cpp +++ b/tools/designer/src/components/taskmenu/button_taskmenu.cpp @@ -508,7 +508,7 @@ bool ButtonTaskMenu::refreshAssignMenu(const QDesignerFormWindowInterface *fw, i QButtonGroup *bg = *it; if (*it != currentGroup) { QAction *a = new QAction(bg->objectName(), m_assignGroupSubMenu); - a->setData(qVariantFromValue(bg)); + a->setData(QVariant::fromValue(bg)); m_assignActionGroup->addAction(a); m_assignGroupSubMenu->addAction(a); } diff --git a/tools/designer/src/components/taskmenu/inplace_editor.cpp b/tools/designer/src/components/taskmenu/inplace_editor.cpp index 5732500..810df23 100644 --- a/tools/designer/src/components/taskmenu/inplace_editor.cpp +++ b/tools/designer/src/components/taskmenu/inplace_editor.cpp @@ -106,7 +106,7 @@ void TaskMenuInlineEditor::editText() const int index = sheet->indexOf(m_property); if (index == -1) return; - m_value = qVariantValue(sheet->property(index)); + m_value = qvariant_cast(sheet->property(index)); const QString oldValue = m_value.value(); m_editor = new InPlaceEditor(m_widget, m_vm, m_formWindow, oldValue, editRectangle()); @@ -119,9 +119,9 @@ void TaskMenuInlineEditor::updateText(const QString &text) // do not use the cursor selection m_value.setValue(text); if (m_managed) { - m_formWindow->cursor()->setProperty(m_property, qVariantFromValue(m_value)); + m_formWindow->cursor()->setProperty(m_property, QVariant::fromValue(m_value)); } else { - m_formWindow->cursor()->setWidgetProperty(m_widget, m_property, qVariantFromValue(m_value)); + m_formWindow->cursor()->setWidgetProperty(m_widget, m_property, QVariant::fromValue(m_value)); } } diff --git a/tools/designer/src/components/taskmenu/itemlisteditor.cpp b/tools/designer/src/components/taskmenu/itemlisteditor.cpp index 94959fd..29fe0c9 100644 --- a/tools/designer/src/components/taskmenu/itemlisteditor.cpp +++ b/tools/designer/src/components/taskmenu/itemlisteditor.cpp @@ -191,8 +191,8 @@ void AbstractItemEditor::propertyChanged(QtProperty *property) return; if ((role == ItemFlagsShadowRole && prop->value().toInt() == (int)QListWidgetItem().flags()) - || (role == Qt::DecorationPropertyRole && !qVariantValue(prop->value()).mask()) - || (role == Qt::FontRole && !qVariantValue(prop->value()).resolve())) { + || (role == Qt::DecorationPropertyRole && !qvariant_cast(prop->value()).mask()) + || (role == Qt::FontRole && !qvariant_cast(prop->value()).resolve())) { prop->setModified(false); setItemData(role, QVariant()); } else { @@ -202,19 +202,19 @@ void AbstractItemEditor::propertyChanged(QtProperty *property) switch (role) { case Qt::DecorationPropertyRole: - setItemData(Qt::DecorationRole, qVariantFromValue(iconCache()->icon(qVariantValue(prop->value())))); + setItemData(Qt::DecorationRole, QVariant::fromValue(iconCache()->icon(qvariant_cast(prop->value())))); break; case Qt::DisplayPropertyRole: - setItemData(Qt::EditRole, qVariantFromValue(qVariantValue(prop->value()).value())); + setItemData(Qt::EditRole, QVariant::fromValue(qvariant_cast(prop->value()).value())); break; case Qt::ToolTipPropertyRole: - setItemData(Qt::ToolTipRole, qVariantFromValue(qVariantValue(prop->value()).value())); + setItemData(Qt::ToolTipRole, QVariant::fromValue(qvariant_cast(prop->value()).value())); break; case Qt::StatusTipPropertyRole: - setItemData(Qt::StatusTipRole, qVariantFromValue(qVariantValue(prop->value()).value())); + setItemData(Qt::StatusTipRole, QVariant::fromValue(qvariant_cast(prop->value()).value())); break; case Qt::WhatsThisPropertyRole: - setItemData(Qt::WhatsThisRole, qVariantFromValue(qVariantValue(prop->value()).value())); + setItemData(Qt::WhatsThisRole, QVariant::fromValue(qvariant_cast(prop->value()).value())); break; default: break; @@ -236,22 +236,22 @@ void AbstractItemEditor::resetProperty(QtProperty *property) QtVariantProperty *prop = m_propertyManager->variantProperty(property); int role = m_propertyToRole.value(prop); if (role == ItemFlagsShadowRole) - prop->setValue(qVariantFromValue((int)QListWidgetItem().flags())); + prop->setValue(QVariant::fromValue((int)QListWidgetItem().flags())); else prop->setValue(QVariant(prop->valueType(), (void *)0)); prop->setModified(false); setItemData(role, QVariant()); if (role == Qt::DecorationPropertyRole) - setItemData(Qt::DecorationRole, qVariantFromValue(QIcon())); + setItemData(Qt::DecorationRole, QVariant::fromValue(QIcon())); if (role == Qt::DisplayPropertyRole) - setItemData(Qt::EditRole, qVariantFromValue(QString())); + setItemData(Qt::EditRole, QVariant::fromValue(QString())); if (role == Qt::ToolTipPropertyRole) - setItemData(Qt::ToolTipRole, qVariantFromValue(QString())); + setItemData(Qt::ToolTipRole, QVariant::fromValue(QString())); if (role == Qt::StatusTipPropertyRole) - setItemData(Qt::StatusTipRole, qVariantFromValue(QString())); + setItemData(Qt::StatusTipRole, QVariant::fromValue(QString())); if (role == Qt::WhatsThisPropertyRole) - setItemData(Qt::WhatsThisRole, qVariantFromValue(QString())); + setItemData(Qt::WhatsThisRole, QVariant::fromValue(QString())); } void AbstractItemEditor::cacheReloaded() @@ -268,7 +268,7 @@ void AbstractItemEditor::updateBrowser() QVariant val = getItemData(role); if (!val.isValid()) { if (role == ItemFlagsShadowRole) - val = qVariantFromValue((int)QListWidgetItem().flags()); + val = QVariant::fromValue((int)QListWidgetItem().flags()); else val = QVariant((int)prop->value().userType(), (void *)0); prop->setModified(false); @@ -340,7 +340,7 @@ void ItemListEditor::on_newListItemButton_clicked() int row = ui.listWidget->currentRow() + 1; QListWidgetItem *item = new QListWidgetItem(m_newItemText); - item->setData(Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(m_newItemText))); + item->setData(Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(m_newItemText))); item->setFlags(item->flags() | Qt::ItemIsEditable); if (row < ui.listWidget->count()) ui.listWidget->insertItem(row, item); @@ -403,15 +403,15 @@ void ItemListEditor::on_listWidget_itemChanged(QListWidgetItem *item) if (m_updatingBrowser) return; - PropertySheetStringValue val = qVariantValue(item->data(Qt::DisplayPropertyRole)); + PropertySheetStringValue val = qvariant_cast(item->data(Qt::DisplayPropertyRole)); val.setValue(item->text()); BoolBlocker block(m_updatingBrowser); - item->setData(Qt::DisplayPropertyRole, qVariantFromValue(val)); + item->setData(Qt::DisplayPropertyRole, QVariant::fromValue(val)); // The checkState could change, too, but if this signal is connected, // checkState is not in the list anyway, as we are editing a header item. emit itemChanged(ui.listWidget->currentRow(), Qt::DisplayPropertyRole, - qVariantFromValue(val)); + QVariant::fromValue(val)); updateBrowser(); } @@ -438,8 +438,8 @@ void ItemListEditor::setItemData(int role, const QVariant &v) QVariant newValue = v; if (role == Qt::FontRole && newValue.type() == QVariant::Font) { QFont oldFont = ui.listWidget->font(); - QFont newFont = qVariantValue(newValue).resolve(oldFont); - newValue = qVariantFromValue(newFont); + QFont newFont = qvariant_cast(newValue).resolve(oldFont); + newValue = QVariant::fromValue(newFont); item->setData(role, QVariant()); // force the right font with the current resolve mask is set (item view bug) } item->setData(role, newValue); diff --git a/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp b/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp index 7dd5442..cd8b188 100644 --- a/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp +++ b/tools/designer/src/components/taskmenu/tablewidgeteditor.cpp @@ -152,8 +152,8 @@ void TableWidgetEditor::setItemData(int role, const QVariant &v) QVariant newValue = v; if (role == Qt::FontRole && newValue.type() == QVariant::Font) { QFont oldFont = ui.tableWidget->font(); - QFont newFont = qVariantValue(newValue).resolve(oldFont); - newValue = qVariantFromValue(newFont); + QFont newFont = qvariant_cast(newValue).resolve(oldFont); + newValue = QVariant::fromValue(newFont); item->setData(role, QVariant()); // force the right font with the current resolve mask is set (item view bug) } item->setData(role, newValue); @@ -179,10 +179,10 @@ void TableWidgetEditor::on_tableWidget_itemChanged(QTableWidgetItem *item) if (m_updatingBrowser) return; - PropertySheetStringValue val = qVariantValue(item->data(Qt::DisplayPropertyRole)); + PropertySheetStringValue val = qvariant_cast(item->data(Qt::DisplayPropertyRole)); val.setValue(item->text()); BoolBlocker block(m_updatingBrowser); - item->setData(Qt::DisplayPropertyRole, qVariantFromValue(val)); + item->setData(Qt::DisplayPropertyRole, QVariant::fromValue(val)); updateBrowser(); } @@ -317,7 +317,7 @@ void TableWidgetEditor::on_columnEditor_itemInserted(int idx) ui.tableWidget->setColumnCount(columnCount + 1); QTableWidgetItem *newItem = new QTableWidgetItem(m_columnEditor->newItemText()); - newItem->setData(Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(m_columnEditor->newItemText()))); + newItem->setData(Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(m_columnEditor->newItemText()))); ui.tableWidget->setHorizontalHeaderItem(columnCount, newItem); moveColumnsLeft(idx, columnCount); @@ -359,7 +359,7 @@ void TableWidgetEditor::on_rowEditor_itemInserted(int idx) ui.tableWidget->setRowCount(rowCount + 1); QTableWidgetItem *newItem = new QTableWidgetItem(m_rowEditor->newItemText()); - newItem->setData(Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(m_rowEditor->newItemText()))); + newItem->setData(Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(m_rowEditor->newItemText()))); ui.tableWidget->setVerticalHeaderItem(rowCount, newItem); moveRowsDown(idx, rowCount); diff --git a/tools/designer/src/components/taskmenu/treewidgeteditor.cpp b/tools/designer/src/components/taskmenu/treewidgeteditor.cpp index c4063d1..8fab2ad 100644 --- a/tools/designer/src/components/taskmenu/treewidgeteditor.cpp +++ b/tools/designer/src/components/taskmenu/treewidgeteditor.cpp @@ -171,8 +171,8 @@ void TreeWidgetEditor::setItemData(int role, const QVariant &v) BoolBlocker block(m_updatingBrowser); if (role == Qt::FontRole && newValue.type() == QVariant::Font) { QFont oldFont = ui.treeWidget->font(); - QFont newFont = qVariantValue(newValue).resolve(oldFont); - newValue = qVariantFromValue(newFont); + QFont newFont = qvariant_cast(newValue).resolve(oldFont); + newValue = QVariant::fromValue(newFont); ui.treeWidget->currentItem()->setData(col, role, QVariant()); // force the right font with the current resolve mask is set (item view bug) } ui.treeWidget->currentItem()->setData(col, role, newValue); @@ -198,7 +198,7 @@ void TreeWidgetEditor::on_newItemButton_clicked() newItem = new QTreeWidgetItem(ui.treeWidget); const QString newItemText = tr("New Item"); newItem->setText(0, newItemText); - newItem->setData(0, Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(newItemText))); + newItem->setData(0, Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(newItemText))); newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); ui.treeWidget->blockSignals(false); @@ -217,7 +217,7 @@ void TreeWidgetEditor::on_newSubItemButton_clicked() QTreeWidgetItem *newItem = new QTreeWidgetItem(curItem); const QString newItemText = tr("New Subitem"); newItem->setText(0, newItemText); - newItem->setData(0, Qt::DisplayPropertyRole, qVariantFromValue(PropertySheetStringValue(newItemText))); + newItem->setData(0, Qt::DisplayPropertyRole, QVariant::fromValue(PropertySheetStringValue(newItemText))); newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); ui.treeWidget->blockSignals(false); @@ -408,10 +408,10 @@ void TreeWidgetEditor::on_treeWidget_itemChanged(QTreeWidgetItem *item, int colu if (m_updatingBrowser) return; - PropertySheetStringValue val = qVariantValue(item->data(column, Qt::DisplayPropertyRole)); + PropertySheetStringValue val = qvariant_cast(item->data(column, Qt::DisplayPropertyRole)); val.setValue(item->text(column)); BoolBlocker block(m_updatingBrowser); - item->setData(column, Qt::DisplayPropertyRole, qVariantFromValue(val)); + item->setData(column, Qt::DisplayPropertyRole, QVariant::fromValue(val)); updateBrowser(); } @@ -425,7 +425,7 @@ void TreeWidgetEditor::on_columnEditor_indexChanged(int idx) void TreeWidgetEditor::on_columnEditor_itemChanged(int idx, int role, const QVariant &v) { if (role == Qt::DisplayPropertyRole) - ui.treeWidget->headerItem()->setData(idx, Qt::EditRole, qVariantValue(v).value()); + ui.treeWidget->headerItem()->setData(idx, Qt::EditRole, qvariant_cast(v).value()); ui.treeWidget->headerItem()->setData(idx, role, v); } diff --git a/tools/designer/src/designer/qdesigner_settings.cpp b/tools/designer/src/designer/qdesigner_settings.cpp index cc6cec5..9404e50 100644 --- a/tools/designer/src/designer/qdesigner_settings.cpp +++ b/tools/designer/src/designer/qdesigner_settings.cpp @@ -241,7 +241,7 @@ ToolWindowFontSettings QDesignerSettings::toolWindowFont() const fontSettings.m_writingSystem = static_cast(value(QLatin1String("UI/writingSystem"), QFontDatabase::Any).toInt()); - fontSettings.m_font = qVariantValue(value(QLatin1String("UI/font"))); + fontSettings.m_font = qvariant_cast(value(QLatin1String("UI/font"))); fontSettings.m_useFont = settings()->value(QLatin1String("UI/useFont"), QVariant(false)).toBool(); return fontSettings; diff --git a/tools/designer/src/lib/shared/actioneditor.cpp b/tools/designer/src/lib/shared/actioneditor.cpp index 664921e..d3716ca 100644 --- a/tools/designer/src/lib/shared/actioneditor.cpp +++ b/tools/designer/src/lib/shared/actioneditor.cpp @@ -459,9 +459,9 @@ void ActionEditor::slotNewAction() setInitialProperty(sheet, QLatin1String(checkablePropertyC), QVariant(true)); if (!actionData.keysequence.value().isEmpty()) - setInitialProperty(sheet, QLatin1String(shortcutPropertyC), qVariantFromValue(actionData.keysequence)); + setInitialProperty(sheet, QLatin1String(shortcutPropertyC), QVariant::fromValue(actionData.keysequence)); - sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), qVariantFromValue(actionData.icon)); + sheet->setProperty(sheet->indexOf(QLatin1String(iconPropertyC)), QVariant::fromValue(actionData.icon)); AddActionCommand *cmd = new AddActionCommand(formWindow()); cmd->init(action); @@ -486,7 +486,7 @@ static QDesignerFormWindowCommand *setIconPropertyCommand(const PropertySheetIco return cmd; } SetPropertyCommand *cmd = new SetPropertyCommand(fw); - cmd->init(action, iconProperty, qVariantFromValue(newIcon)); + cmd->init(action, iconProperty, QVariant::fromValue(newIcon)); return cmd; } @@ -502,7 +502,7 @@ static QDesignerFormWindowCommand *setKeySequencePropertyCommand(const PropertyS return cmd; } SetPropertyCommand *cmd = new SetPropertyCommand(fw); - cmd->init(action, shortcutProperty, qVariantFromValue(ks)); + cmd->init(action, shortcutProperty, QVariant::fromValue(ks)); return cmd; } @@ -528,7 +528,7 @@ static inline QString textPropertyValue(const QDesignerPropertySheetExtension *s { const int index = sheet->indexOf(name); Q_ASSERT(index != -1); - const PropertySheetStringValue ps = qVariantValue(sheet->property(index)); + const PropertySheetStringValue ps = qvariant_cast(sheet->property(index)); return ps.value(); } @@ -545,7 +545,7 @@ void ActionEditor::editAction(QAction *action) oldActionData.name = action->objectName(); oldActionData.text = action->text(); oldActionData.toolTip = textPropertyValue(sheet, QLatin1String(toolTipPropertyC)); - oldActionData.icon = qVariantValue(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); + oldActionData.icon = qvariant_cast(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); oldActionData.keysequence = ActionModel::actionShortCut(sheet); oldActionData.checkable = action->isCheckable(); dlg.setActionData(oldActionData); @@ -677,7 +677,7 @@ void ActionEditor::resourceImageDropped(const QString &path, QAction *action) QDesignerPropertySheetExtension *sheet = qt_extension(core()->extensionManager(), action); const PropertySheetIconValue oldIcon = - qVariantValue(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); + qvariant_cast(sheet->property(sheet->indexOf(QLatin1String(iconPropertyC)))); PropertySheetIconValue newIcon; newIcon.setPixmap(QIcon::Normal, QIcon::Off, PropertySheetPixmapValue(path)); if (newIcon.paths().isEmpty() || newIcon.paths() == oldIcon.paths()) diff --git a/tools/designer/src/lib/shared/actionrepository.cpp b/tools/designer/src/lib/shared/actionrepository.cpp index 1076ff4..8df6f83 100644 --- a/tools/designer/src/lib/shared/actionrepository.cpp +++ b/tools/designer/src/lib/shared/actionrepository.cpp @@ -136,7 +136,7 @@ QModelIndex ActionModel::addAction(QAction *action) const Qt::ItemFlags flags = Qt::ItemIsSelectable|Qt::ItemIsDropEnabled|Qt::ItemIsDragEnabled|Qt::ItemIsEnabled; QVariant itemData; - qVariantSetValue(itemData, action); + itemData.setValue(action); for (int i = 0; i < NumColumns; i++) { QStandardItem *item = new QStandardItem; diff --git a/tools/designer/src/lib/shared/formlayoutmenu.cpp b/tools/designer/src/lib/shared/formlayoutmenu.cpp index 8d9f9a6..ff909a7 100644 --- a/tools/designer/src/lib/shared/formlayoutmenu.cpp +++ b/tools/designer/src/lib/shared/formlayoutmenu.cpp @@ -432,16 +432,16 @@ static QPair const QString objectNameProperty = QLatin1String("objectName"); QDesignerPropertySheetExtension *labelSheet = qt_extension(core->extensionManager(), rc.first); int nameIndex = labelSheet->indexOf(objectNameProperty); - labelSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.labelName))); + labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName))); labelSheet->setChanged(nameIndex, true); formWindow->ensureUniqueObjectName(rc.first); const int textIndex = labelSheet->indexOf(QLatin1String("text")); - labelSheet->setProperty(textIndex, qVariantFromValue(PropertySheetStringValue(row.labelText))); + labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText))); labelSheet->setChanged(textIndex, true); // Set up properties of the control QDesignerPropertySheetExtension *controlSheet = qt_extension(core->extensionManager(), rc.second); nameIndex = controlSheet->indexOf(objectNameProperty); - controlSheet->setProperty(nameIndex, qVariantFromValue(PropertySheetStringValue(row.fieldName))); + controlSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.fieldName))); controlSheet->setChanged(nameIndex, true); formWindow->ensureUniqueObjectName(rc.second); return rc; diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp index 5292f5f..7e65d6b 100644 --- a/tools/designer/src/lib/shared/formwindowbase.cpp +++ b/tools/designer/src/lib/shared/formwindowbase.cpp @@ -184,11 +184,11 @@ void FormWindowBase::reloadProperties() const int index = itIndex.next().key(); const QVariant newValue = sheet->property(index); if (qobject_cast(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) { - const PropertySheetStringValue newString = qVariantValue(newValue); + const PropertySheetStringValue newString = qvariant_cast(newValue); // optimize a bit, reset only if the text value might contain a reference to qt resources // (however reloading of icons other than taken from resources might not work here) if (newString.value().contains(QLatin1String(":/"))) { - const QVariant resetValue = qVariantFromValue(PropertySheetStringValue()); + const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue()); sheet->setProperty(index, resetValue); } } diff --git a/tools/designer/src/lib/shared/grid.cpp b/tools/designer/src/lib/shared/grid.cpp index 42296e1..67b8d5c 100644 --- a/tools/designer/src/lib/shared/grid.cpp +++ b/tools/designer/src/lib/shared/grid.cpp @@ -71,7 +71,7 @@ template const QVariantMap::const_iterator it = v.constFind(key); const bool found = it != v.constEnd(); if (found) - value = qVariantValue(it.value()); + value = qvariant_cast(it.value()); return found; } diff --git a/tools/designer/src/lib/shared/morphmenu.cpp b/tools/designer/src/lib/shared/morphmenu.cpp index 6dfac47..80eac0c 100644 --- a/tools/designer/src/lib/shared/morphmenu.cpp +++ b/tools/designer/src/lib/shared/morphmenu.cpp @@ -256,11 +256,11 @@ static void replaceWidgetListDynamicProperty(QWidget *parentWidget, QWidget *oldWidget, QWidget *newWidget, const char *name) { - QWidgetList list = qVariantValue(parentWidget->property(name)); + QWidgetList list = qvariant_cast(parentWidget->property(name)); const int index = list.indexOf(oldWidget); if (index != -1) { list.replace(index, newWidget); - parentWidget->setProperty(name, qVariantFromValue(list)); + parentWidget->setProperty(name, QVariant::fromValue(list)); } } diff --git a/tools/designer/src/lib/shared/qdesigner_command.cpp b/tools/designer/src/lib/shared/qdesigner_command.cpp index 9fe0e89..8c01000 100644 --- a/tools/designer/src/lib/shared/qdesigner_command.cpp +++ b/tools/designer/src/lib/shared/qdesigner_command.cpp @@ -107,23 +107,23 @@ static const char *zOrderPropertyC = "_q_zOrder"; static void addToWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name, int index = -1) { - QWidgetList list = qVariantValue(parentWidget->property(name)); + QWidgetList list = qvariant_cast(parentWidget->property(name)); list.removeAll(widget); if (index >= 0 && index < list.size()) { list.insert(index, widget); } else { list.append(widget); } - parentWidget->setProperty(name, qVariantFromValue(list)); + parentWidget->setProperty(name, QVariant::fromValue(list)); } static int removeFromWidgetListDynamicProperty(QWidget *parentWidget, QWidget *widget, const char *name) { - QWidgetList list = qVariantValue(parentWidget->property(name)); + QWidgetList list = qvariant_cast(parentWidget->property(name)); const int firstIndex = list.indexOf(widget); if (firstIndex != -1) { list.removeAll(widget); - parentWidget->setProperty(name, qVariantFromValue(list)); + parentWidget->setProperty(name, QVariant::fromValue(list)); } return firstIndex; } @@ -281,7 +281,7 @@ void ChangeZOrderCommand::init(QWidget *widget) setText(QApplication::translate("Command", "Change Z-order of '%1'").arg(widget->objectName())); - m_oldParentZOrder = qVariantValue(widget->parentWidget()->property("_q_zOrder")); + m_oldParentZOrder = qvariant_cast(widget->parentWidget()->property("_q_zOrder")); const int index = m_oldParentZOrder.indexOf(m_widget); if (index != -1 && index + 1 < m_oldParentZOrder.count()) m_oldPreceding = m_oldParentZOrder.at(index + 1); @@ -289,14 +289,14 @@ void ChangeZOrderCommand::init(QWidget *widget) void ChangeZOrderCommand::redo() { - m_widget->parentWidget()->setProperty("_q_zOrder", qVariantFromValue(reorderWidget(m_oldParentZOrder, m_widget))); + m_widget->parentWidget()->setProperty("_q_zOrder", QVariant::fromValue(reorderWidget(m_oldParentZOrder, m_widget))); reorder(m_widget); } void ChangeZOrderCommand::undo() { - m_widget->parentWidget()->setProperty("_q_zOrder", qVariantFromValue(m_oldParentZOrder)); + m_widget->parentWidget()->setProperty("_q_zOrder", QVariant::fromValue(m_oldParentZOrder)); if (m_oldPreceding) m_widget->stackUnder(m_oldPreceding); @@ -580,8 +580,8 @@ void ReparentWidgetCommand::init(QWidget *widget, QWidget *parentWidget) setText(QApplication::translate("Command", "Reparent '%1'").arg(widget->objectName())); - m_oldParentList = qVariantValue(m_oldParentWidget->property("_q_widgetOrder")); - m_oldParentZOrder = qVariantValue(m_oldParentWidget->property("_q_zOrder")); + m_oldParentList = qvariant_cast(m_oldParentWidget->property("_q_widgetOrder")); + m_oldParentZOrder = qvariant_cast(m_oldParentWidget->property("_q_zOrder")); } void ReparentWidgetCommand::redo() @@ -591,19 +591,19 @@ void ReparentWidgetCommand::redo() QWidgetList oldList = m_oldParentList; oldList.removeAll(m_widget); - m_oldParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(oldList)); + m_oldParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(oldList)); - QWidgetList newList = qVariantValue(m_newParentWidget->property("_q_widgetOrder")); + QWidgetList newList = qvariant_cast(m_newParentWidget->property("_q_widgetOrder")); newList.append(m_widget); - m_newParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(newList)); + m_newParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(newList)); QWidgetList oldZOrder = m_oldParentZOrder; oldZOrder.removeAll(m_widget); - m_oldParentWidget->setProperty("_q_zOrder", qVariantFromValue(oldZOrder)); + m_oldParentWidget->setProperty("_q_zOrder", QVariant::fromValue(oldZOrder)); - QWidgetList newZOrder = qVariantValue(m_newParentWidget->property("_q_zOrder")); + QWidgetList newZOrder = qvariant_cast(m_newParentWidget->property("_q_zOrder")); newZOrder.append(m_widget); - m_newParentWidget->setProperty("_q_zOrder", qVariantFromValue(newZOrder)); + m_newParentWidget->setProperty("_q_zOrder", QVariant::fromValue(newZOrder)); m_widget->show(); core()->objectInspector()->setFormWindow(formWindow()); @@ -614,16 +614,16 @@ void ReparentWidgetCommand::undo() m_widget->setParent(m_oldParentWidget); m_widget->move(m_oldPos); - m_oldParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(m_oldParentList)); + m_oldParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(m_oldParentList)); - QWidgetList newList = qVariantValue(m_newParentWidget->property("_q_widgetOrder")); + QWidgetList newList = qvariant_cast(m_newParentWidget->property("_q_widgetOrder")); newList.removeAll(m_widget); - m_newParentWidget->setProperty("_q_widgetOrder", qVariantFromValue(newList)); + m_newParentWidget->setProperty("_q_widgetOrder", QVariant::fromValue(newList)); - m_oldParentWidget->setProperty("_q_zOrder", qVariantFromValue(m_oldParentZOrder)); + m_oldParentWidget->setProperty("_q_zOrder", QVariant::fromValue(m_oldParentZOrder)); - QWidgetList newZOrder = qVariantValue(m_newParentWidget->property("_q_zOrder")); - m_newParentWidget->setProperty("_q_zOrder", qVariantFromValue(newZOrder)); + QWidgetList newZOrder = qvariant_cast(m_newParentWidget->property("_q_zOrder")); + m_newParentWidget->setProperty("_q_zOrder", QVariant::fromValue(newZOrder)); m_widget->show(); core()->objectInspector()->setFormWindow(formWindow()); @@ -1016,7 +1016,7 @@ void ToolBoxCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension(formWindow()->core()->extensionManager(), m_toolBox); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QLatin1String("currentItemText")), qVariantFromValue(itemText)); + sheet->setProperty(sheet->indexOf(QLatin1String("currentItemText")), QVariant::fromValue(itemText)); } m_widget->show(); @@ -1176,7 +1176,7 @@ void TabWidgetCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension(formWindow()->core()->extensionManager(), m_tabWidget); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QLatin1String("currentTabText")), qVariantFromValue(itemText)); + sheet->setProperty(sheet->indexOf(QLatin1String("currentTabText")), QVariant::fromValue(itemText)); } formWindow()->clearSelection(); @@ -2193,7 +2193,7 @@ static void copyRolesFromItem(ItemData *id, const T *item, bool editor) if (editor) copyRoleFromItem(id, ItemFlagsShadowRole, item); else if (item->flags() != defaultFlags) - id->m_properties.insert(ItemFlagsShadowRole, qVariantFromValue((int)item->flags())); + id->m_properties.insert(ItemFlagsShadowRole, QVariant::fromValue((int)item->flags())); } template @@ -2210,19 +2210,19 @@ static void copyRolesToItem(const ItemData *id, T *item, DesignerIconCache *icon switch (it.key()) { case Qt::DecorationPropertyRole: if (iconCache) - item->setIcon(iconCache->icon(qVariantValue(it.value()))); + item->setIcon(iconCache->icon(qvariant_cast(it.value()))); break; case Qt::DisplayPropertyRole: - item->setText(qVariantValue(it.value()).value()); + item->setText(qvariant_cast(it.value()).value()); break; case Qt::ToolTipPropertyRole: - item->setToolTip(qVariantValue(it.value()).value()); + item->setToolTip(qvariant_cast(it.value()).value()); break; case Qt::StatusTipPropertyRole: - item->setStatusTip(qVariantValue(it.value()).value()); + item->setStatusTip(qvariant_cast(it.value()).value()); break; case Qt::WhatsThisPropertyRole: - item->setWhatsThis(qVariantValue(it.value()).value()); + item->setWhatsThis(qvariant_cast(it.value()).value()); break; } } @@ -2267,7 +2267,7 @@ ItemData::ItemData(const QTreeWidgetItem *item, int column) { copyRoleFromItem(this, Qt::EditRole, item, column); PropertySheetStringValue str(item->text(column)); - m_properties.insert(Qt::DisplayPropertyRole, qVariantFromValue(str)); + m_properties.insert(Qt::DisplayPropertyRole, QVariant::fromValue(str)); for (int i = 0; itemRoles[i] != -1; i++) copyRoleFromItem(this, itemRoles[i], item, column); @@ -2282,19 +2282,19 @@ void ItemData::fillTreeItemColumn(QTreeWidgetItem *item, int column, DesignerIco switch (it.key()) { case Qt::DecorationPropertyRole: if (iconCache) - item->setIcon(column, iconCache->icon(qVariantValue(it.value()))); + item->setIcon(column, iconCache->icon(qvariant_cast(it.value()))); break; case Qt::DisplayPropertyRole: - item->setText(column, qVariantValue(it.value()).value()); + item->setText(column, qvariant_cast(it.value()).value()); break; case Qt::ToolTipPropertyRole: - item->setToolTip(column, qVariantValue(it.value()).value()); + item->setToolTip(column, qvariant_cast(it.value()).value()); break; case Qt::StatusTipPropertyRole: - item->setStatusTip(column, qVariantValue(it.value()).value()); + item->setStatusTip(column, qvariant_cast(it.value()).value()); break; case Qt::WhatsThisPropertyRole: - item->setWhatsThis(column, qVariantValue(it.value()).value()); + item->setWhatsThis(column, qvariant_cast(it.value()).value()); break; } } @@ -2364,10 +2364,10 @@ void ListContents::applyToComboBox(QComboBox *comboBox, DesignerIconCache *iconC foreach (const ItemData &hash, m_items) { QIcon icon; if (iconCache) - icon = iconCache->icon(qVariantValue( + icon = iconCache->icon(qvariant_cast( hash.m_properties[Qt::DecorationPropertyRole])); QVariant var = hash.m_properties[Qt::DisplayPropertyRole]; - PropertySheetStringValue str = qVariantValue(var); + PropertySheetStringValue str = qvariant_cast(var); comboBox->addItem(icon, str.value()); comboBox->setItemData(comboBox->count() - 1, var, @@ -2407,7 +2407,7 @@ bool TableWidgetContents::nonEmpty(const QTableWidgetItem *item, int headerColum if (item->flags() != defaultFlags) return true; - QString text = qVariantValue(item->data(Qt::DisplayPropertyRole)).value(); + QString text = qvariant_cast(item->data(Qt::DisplayPropertyRole)).value(); if (!text.isEmpty()) { if (headerColumn < 0 || text != defaultHeaderText(headerColumn)) return true; @@ -2545,7 +2545,7 @@ QTreeWidgetItem *TreeWidgetContents::ItemContents::createTreeItem(DesignerIconCa if (m_itemFlags != -1) { if (editor) - item->setData(0, ItemFlagsShadowRole, qVariantFromValue(m_itemFlags)); + item->setData(0, ItemFlagsShadowRole, QVariant::fromValue(m_itemFlags)); else item->setFlags((Qt::ItemFlags)m_itemFlags); } diff --git a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp index 14e0d81..b881589 100644 --- a/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/tools/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -243,7 +243,7 @@ static bool readDomEnumerationValue(const DomProperty *p, if (index == -1) return false; const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert(sheetValue)) { + if (sheetValue.canConvert()) { const PropertySheetFlagValue f = qvariant_cast(sheetValue); bool ok = false; v = f.metaFlags.parseFlags(p->elementSet(), &ok); @@ -258,7 +258,7 @@ static bool readDomEnumerationValue(const DomProperty *p, if (index == -1) return false; const QVariant sheetValue = sheet->property(index); - if (qVariantCanConvert(sheetValue)) { + if (sheetValue.canConvert()) { const PropertySheetEnumValue e = qvariant_cast(sheetValue); bool ok = false; v = e.metaEnum.parseEnum(p->elementEnum(), &ok); diff --git a/tools/designer/src/lib/shared/qdesigner_menu.cpp b/tools/designer/src/lib/shared/qdesigner_menu.cpp index bbab032..3d9fdf1 100644 --- a/tools/designer/src/lib/shared/qdesigner_menu.cpp +++ b/tools/designer/src/lib/shared/qdesigner_menu.cpp @@ -477,7 +477,7 @@ bool QDesignerMenu::handleContextMenuEvent(QWidget *, QContextMenuEvent *event) QMenu menu; QVariant itemData; - qVariantSetValue(itemData, action); + itemData.setValue(action); QAction *addSeparatorAction = menu.addAction(tr("Insert separator")); addSeparatorAction->setData(itemData); diff --git a/tools/designer/src/lib/shared/qdesigner_menubar.cpp b/tools/designer/src/lib/shared/qdesigner_menubar.cpp index 8d53037..b017264 100644 --- a/tools/designer/src/lib/shared/qdesigner_menubar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_menubar.cpp @@ -403,7 +403,7 @@ ActionList QDesignerMenuBar::contextMenuActions() if (QAction *action = safeActionAt(m_currentIndex)) { if (!qobject_cast(action)) { QVariant itemData; - qVariantSetValue(itemData, action); + itemData.setValue(action); QAction *remove_action = new QAction(tr("Remove Menu '%1'").arg(action->menu()->objectName()), 0); remove_action->setData(itemData); diff --git a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp index 6cc054c..08385b5 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -505,7 +505,7 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant case QVariant::Size: return PropertyHelper::Value(applySizeSubProperty(oldValue.toSize(), newValue.toSize(), mask), changed); case QVariant::SizePolicy: - return PropertyHelper::Value(qVariantFromValue(applySizePolicySubProperty(qvariant_cast(oldValue), qvariant_cast(newValue), mask)), changed); + return PropertyHelper::Value(QVariant::fromValue(applySizePolicySubProperty(qvariant_cast(oldValue), qvariant_cast(newValue), mask)), changed); case QVariant::Font: { // Changed flag in case of font and palette depends on resolve mask only, not on the passed "changed" value. @@ -524,27 +524,27 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant // He press reset button for the whole font property. In result whole font properties for both // widgets should be marked as unchanged. QFont font = applyFontSubProperty(qvariant_cast(oldValue), qvariant_cast(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(font), font.resolve()); + return PropertyHelper::Value(QVariant::fromValue(font), font.resolve()); } case QVariant::Palette: { QPalette palette = applyPaletteSubProperty(qvariant_cast(oldValue), qvariant_cast(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(palette), palette.resolve()); + return PropertyHelper::Value(QVariant::fromValue(palette), palette.resolve()); } default: if (oldValue.userType() == qMetaTypeId()) { PropertySheetIconValue icon = qvariant_cast(oldValue); icon.assign(qvariant_cast(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(icon), icon.mask()); + return PropertyHelper::Value(QVariant::fromValue(icon), icon.mask()); } else if (oldValue.userType() == qMetaTypeId()) { qdesigner_internal::PropertySheetStringValue str = applyStringSubProperty( qvariant_cast(oldValue), qvariant_cast(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(str), changed); + return PropertyHelper::Value(QVariant::fromValue(str), changed); } else if (oldValue.userType() == qMetaTypeId()) { qdesigner_internal::PropertySheetKeySequenceValue key = applyKeySequenceSubProperty( qvariant_cast(oldValue), qvariant_cast(newValue), mask); - return PropertyHelper::Value(qVariantFromValue(key), changed); + return PropertyHelper::Value(QVariant::fromValue(key), changed); } // Enumerations, flags switch (specialProperty) { @@ -552,7 +552,7 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant qdesigner_internal::PropertySheetFlagValue f = qvariant_cast(oldValue); f.value = applyAlignmentSubProperty(variantToAlignment(oldValue), variantToAlignment(newValue), mask); QVariant v; - qVariantSetValue(v, f); + v.setValue(f); return PropertyHelper::Value(v, changed); } default: @@ -651,7 +651,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi switch (specialProperty) { case SP_MinimumSize: { const QSize size = checkSize(value.toSize()); - qVariantSetValue(value, size); + value.setValue(size); } break; @@ -660,7 +660,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi checkSizes(fw, value.toSize(), &fs, &cs); container->setMaximumSize(cs); fw->mainContainer()->setMaximumSize(fs); - qVariantSetValue(value, fs); + value.setValue(fs); } break; @@ -670,7 +670,7 @@ void PropertyHelper::checkApplyWidgetValue(QDesignerFormWindowInterface *fw, QWi checkSizes(fw, r.size(), &fs, &cs); container->resize(cs); r.setSize(fs); - qVariantSetValue(value, r); + value.setValue(r); } break; default: @@ -727,8 +727,8 @@ void PropertyHelper::updateObject(QDesignerFormWindowInterface *fw, const QVaria case OT_Widget: { switch (m_specialProperty) { case SP_ObjectName: { - const QString oldName = qVariantValue(oldValue).value(); - const QString newName = qVariantValue(newValue).value(); + const QString oldName = qvariant_cast(oldValue).value(); + const QString newName = qvariant_cast(newValue).value(); QDesignerFormWindowCommand::updateBuddies(fw, oldName, newName); } break; @@ -751,8 +751,8 @@ void PropertyHelper::updateObject(QDesignerFormWindowInterface *fw, const QVaria case SP_LayoutName: case SP_SpacerName: if (QDesignerIntegration *integr = integration(fw)) { - const QString oldName = qVariantValue(oldValue).value(); - const QString newName = qVariantValue(newValue).value(); + const QString oldName = qvariant_cast(oldValue).value(); + const QString newName = qvariant_cast(newValue).value(); integr->emitObjectNameChanged(fw, m_object, newName, oldName); } break; diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp index 086f46d..72ecb8f 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -290,18 +290,18 @@ bool QDesignerPropertySheetPrivate::isResourceProperty(int index) const void QDesignerPropertySheetPrivate::addResourceProperty(int index, QVariant::Type type) { if (type == QVariant::Pixmap) - m_resourceProperties.insert(index, qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue())); + m_resourceProperties.insert(index, QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue())); else if (type == QVariant::Icon) - m_resourceProperties.insert(index, qVariantFromValue(qdesigner_internal::PropertySheetIconValue())); + m_resourceProperties.insert(index, QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); } QVariant QDesignerPropertySheetPrivate::emptyResourceProperty(int index) const { QVariant v = m_resourceProperties.value(index); - if (qVariantCanConvert(v)) - return qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); - if (qVariantCanConvert(v)) - return qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + if (v.canConvert()) + return QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue()); + if (v.canConvert()) + return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); return v; } @@ -320,8 +320,8 @@ void QDesignerPropertySheetPrivate::setResourceProperty(int index, const QVarian Q_ASSERT(isResourceProperty(index)); QVariant &v = m_resourceProperties[index]; - if ((qVariantCanConvert(value) && qVariantCanConvert(v)) - || (qVariantCanConvert(value) && qVariantCanConvert(v))) + if ((value.canConvert() && v.canConvert()) + || (value.canConvert() && v.canConvert())) v = value; } @@ -722,14 +722,14 @@ int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QV QVariant v = value; if (value.type() == QVariant::Icon) - v = qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); else if (value.type() == QVariant::Pixmap) - v = qVariantFromValue(qdesigner_internal::PropertySheetPixmapValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetPixmapValue()); else if (value.type() == QVariant::String) - v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(value.toString())); + v = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue(value.toString())); else if (value.type() == QVariant::KeySequence) { - const QKeySequence keySequence = qVariantValue(value); - v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); + const QKeySequence keySequence = qvariant_cast(value); + v = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); } if (d->m_addIndex.contains(propName)) { @@ -873,9 +873,9 @@ int QDesignerPropertySheet::createFakeProperty(const QString &propertyName, cons info.kind = QDesignerPropertySheetPrivate::FakeProperty; QVariant v = value.isValid() ? value : metaProperty(index); if (v.type() == QVariant::String) - v = qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (v.type() == QVariant::KeySequence) - v = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue()); + v = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue()); d->m_fakeProperties.insert(index, v); return index; } @@ -1002,17 +1002,17 @@ QVariant QDesignerPropertySheet::property(int index) const value.setValue(strValue); d->setStringProperty(index, value); // cache it } - return qVariantFromValue(value); + return QVariant::fromValue(value); } if (d->isKeySequenceProperty(index)) { - QKeySequence keyValue = qVariantValue(metaProperty(index)); + QKeySequence keyValue = qvariant_cast(metaProperty(index)); qdesigner_internal::PropertySheetKeySequenceValue value = d->keySequenceProperty(index); if (keyValue != value.value()) { value.setValue(keyValue); d->setKeySequenceProperty(index, value); // cache it } - return qVariantFromValue(value); + return QVariant::fromValue(value); } return metaProperty(index); @@ -1027,12 +1027,12 @@ QVariant QDesignerPropertySheet::metaProperty(int index) const switch (p->kind()) { case QDesignerMetaPropertyInterface::FlagKind: { qdesigner_internal::PropertySheetFlagValue psflags = qdesigner_internal::PropertySheetFlagValue(v.toInt(), designerMetaFlagsFor(p->enumerator())); - qVariantSetValue(v, psflags); + v.setValue(psflags); } break; case QDesignerMetaPropertyInterface::EnumKind: { qdesigner_internal::PropertySheetEnumValue pse = qdesigner_internal::PropertySheetEnumValue(v.toInt(), designerMetaEnumFor(p->enumerator())); - qVariantSetValue(v, pse); + v.setValue(pse); } break; case QDesignerMetaPropertyInterface::OtherKind: @@ -1043,20 +1043,20 @@ QVariant QDesignerPropertySheet::metaProperty(int index) const QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant &value) const { - if (qVariantCanConvert(value)) + if (value.canConvert()) return qvariant_cast(value).value; - if (qVariantCanConvert(value)) + if (value.canConvert()) return qvariant_cast(value).value; - if (qVariantCanConvert(value)) - return qVariantValue(value).value(); + if (value.canConvert()) + return qvariant_cast(value).value(); - if (qVariantCanConvert(value)) - return qVariantValue(value).value(); + if (value.canConvert()) + return qvariant_cast(value).value(); - if (qVariantCanConvert(value)) { - const QString path = qVariantValue(value).path(); + if (value.canConvert()) { + const QString path = qvariant_cast(value).path(); if (path.isEmpty()) return defaultResourceProperty(index); if (d->m_pixmapCache) { @@ -1064,8 +1064,8 @@ QVariant QDesignerPropertySheet::resolvePropertyValue(int index, const QVariant } } - if (qVariantCanConvert(value)) { - const int pathCount = qVariantValue(value).paths().count(); + if (value.canConvert()) { + const int pathCount = qvariant_cast(value).paths().count(); if (pathCount == 0) return defaultResourceProperty(index); if (d->m_iconCache) @@ -1082,17 +1082,17 @@ void QDesignerPropertySheet::setFakeProperty(int index, const QVariant &value) QVariant &v = d->m_fakeProperties[index]; // set resource properties also (if we are going to have fake resource properties) - if (qVariantCanConvert(value) || qVariantCanConvert(value)) { + if (value.canConvert() || value.canConvert()) { v = value; - } else if (qVariantCanConvert(v)) { + } else if (v.canConvert()) { qdesigner_internal::PropertySheetFlagValue f = qvariant_cast(v); f.value = value.toInt(); - qVariantSetValue(v, f); + v.setValue(f); Q_ASSERT(value.type() == QVariant::Int); - } else if (qVariantCanConvert(v)) { + } else if (v.canConvert()) { qdesigner_internal::PropertySheetEnumValue e = qvariant_cast(v); e.value = value.toInt(); - qVariantSetValue(v, e); + v.setValue(e); Q_ASSERT(value.type() == QVariant::Int); } else { v = value; @@ -1139,9 +1139,9 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) if (d->isResourceProperty(index)) d->setResourceProperty(index, value); if (d->isStringProperty(index)) - d->setStringProperty(index, qVariantValue(value)); + d->setStringProperty(index, qvariant_cast(value)); if (d->isKeySequenceProperty(index)) - d->setKeySequenceProperty(index, qVariantValue(value)); + d->setKeySequenceProperty(index, qvariant_cast(value)); d->m_object->setProperty(propertyName(index).toUtf8(), resolvePropertyValue(index, value)); if (d->m_object->isWidgetType()) { QWidget *w = qobject_cast(d->m_object); @@ -1155,26 +1155,26 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) if (d->isResourceProperty(index)) d->setResourceProperty(index, value); if (d->isStringProperty(index)) - d->setStringProperty(index, qVariantValue(value)); + d->setStringProperty(index, qvariant_cast(value)); if (d->isKeySequenceProperty(index)) - d->setKeySequenceProperty(index, qVariantValue(value)); + d->setKeySequenceProperty(index, qvariant_cast(value)); const QDesignerMetaPropertyInterface *p = d->m_meta->property(index); p->write(d->m_object, resolvePropertyValue(index, value)); if (qobject_cast(d->m_object) && propertyType(index) == PropertyCheckable) { const int idx = indexOf(QLatin1String("focusPolicy")); if (!isChanged(idx)) { - qdesigner_internal::PropertySheetEnumValue e = qVariantValue(property(idx)); + qdesigner_internal::PropertySheetEnumValue e = qvariant_cast(property(idx)); if (value.toBool()) { const QDesignerMetaPropertyInterface *p = d->m_meta->property(idx); p->write(d->m_object, Qt::NoFocus); e.value = Qt::StrongFocus; QVariant v; - qVariantSetValue(v, e); + v.setValue(e); setFakeProperty(idx, v); } else { e.value = Qt::NoFocus; QVariant v; - qVariantSetValue(v, e); + v.setValue(e); setFakeProperty(idx, v); } } @@ -1196,9 +1196,9 @@ bool QDesignerPropertySheet::reset(int index) if (d->invalidIndex(Q_FUNC_INFO, index)) return false; if (d->isStringProperty(index)) - setProperty(index, qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + setProperty(index, QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); if (d->isKeySequenceProperty(index)) - setProperty(index, qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue())); + setProperty(index, QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue())); if (d->isResourceProperty(index)) { setProperty(index, d->emptyResourceProperty(index)); return true; @@ -1208,10 +1208,10 @@ bool QDesignerPropertySheet::reset(int index) const QVariant defaultValue = d->m_info.value(index).defaultValue; QVariant newValue = defaultValue; if (d->isStringProperty(index)) { - newValue = qVariantFromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString())); + newValue = QVariant::fromValue(qdesigner_internal::PropertySheetStringValue(newValue.toString())); } else if (d->isKeySequenceProperty(index)) { - const QKeySequence keySequence = qVariantValue(newValue); - newValue = qVariantFromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); + const QKeySequence keySequence = qvariant_cast(newValue); + newValue = QVariant::fromValue(qdesigner_internal::PropertySheetKeySequenceValue(keySequence)); } if (oldValue == newValue) return true; diff --git a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp index 78c6bd9..461212c 100644 --- a/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/tools/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -405,13 +405,13 @@ QTabWidgetPropertySheet::QTabWidgetPropertySheet(QTabWidget *object, QObject *pa QDesignerPropertySheet(object, parent), m_tabWidget(object) { - createFakeProperty(QLatin1String(currentTabTextKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentTabTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(currentTabNameKey), QString()); - createFakeProperty(QLatin1String(currentTabIconKey), qVariantFromValue(qdesigner_internal::PropertySheetIconValue())); + createFakeProperty(QLatin1String(currentTabIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); if (formWindowBase()) formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentTabIconKey))); - createFakeProperty(QLatin1String(currentTabToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); - createFakeProperty(QLatin1String(currentTabWhatsThisKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentTabToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentTabWhatsThisKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); // Prevent the tab widget's drag and drop handling from interfering with Designer's createFakeProperty(QLatin1String(tabMovableKey), QVariant(false)); } @@ -447,22 +447,22 @@ void QTabWidgetPropertySheet::setProperty(int index, const QVariant &value) switch (tabWidgetProperty) { case PropertyCurrentTabText: m_tabWidget->setTabText(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].text = qVariantValue(value); + m_pageToData[currentWidget].text = qvariant_cast(value); break; case PropertyCurrentTabName: currentWidget->setObjectName(value.toString()); break; case PropertyCurrentTabIcon: m_tabWidget->setTabIcon(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].icon = qVariantValue(value); + m_pageToData[currentWidget].icon = qvariant_cast(value); break; case PropertyCurrentTabToolTip: m_tabWidget->setTabToolTip(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].tooltip = qVariantValue(value); + m_pageToData[currentWidget].tooltip = qvariant_cast(value); break; case PropertyCurrentTabWhatsThis: m_tabWidget->setTabWhatsThis(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].whatsthis = qVariantValue(value); + m_pageToData[currentWidget].whatsthis = qvariant_cast(value); break; case PropertyTabWidgetNone: break; @@ -486,28 +486,28 @@ QVariant QTabWidgetPropertySheet::property(int index) const QWidget *currentWidget = m_tabWidget->currentWidget(); if (!currentWidget) { if (tabWidgetProperty == PropertyCurrentTabIcon) - return qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); if (tabWidgetProperty == PropertyCurrentTabText) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (tabWidgetProperty == PropertyCurrentTabToolTip) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (tabWidgetProperty == PropertyCurrentTabWhatsThis) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); return QVariant(QString()); } // index-dependent switch (tabWidgetProperty) { case PropertyCurrentTabText: - return qVariantFromValue(m_pageToData.value(currentWidget).text); + return QVariant::fromValue(m_pageToData.value(currentWidget).text); case PropertyCurrentTabName: return currentWidget->objectName(); case PropertyCurrentTabIcon: - return qVariantFromValue(m_pageToData.value(currentWidget).icon); + return QVariant::fromValue(m_pageToData.value(currentWidget).icon); case PropertyCurrentTabToolTip: - return qVariantFromValue(m_pageToData.value(currentWidget).tooltip); + return QVariant::fromValue(m_pageToData.value(currentWidget).tooltip); case PropertyCurrentTabWhatsThis: - return qVariantFromValue(m_pageToData.value(currentWidget).whatsthis); + return QVariant::fromValue(m_pageToData.value(currentWidget).whatsthis); case PropertyTabWidgetNone: break; } diff --git a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp index cd95f5b..a607f35 100644 --- a/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/tools/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -132,7 +132,7 @@ static QString objName(const QDesignerFormEditorInterface *core, QObject *object const QString objectNameProperty = QLatin1String("objectName"); const int index = sheet->indexOf(objectNameProperty); const qdesigner_internal::PropertySheetStringValue objectNameValue - = qVariantValue(sheet->property(index)); + = qvariant_cast(sheet->property(index)); return objectNameValue.value(); } @@ -447,7 +447,7 @@ void QDesignerTaskMenu::changeObjectName() const QString objectNameProperty = QLatin1String("objectName"); PropertySheetStringValue objectNameValue; objectNameValue.setValue(newObjectName); - setProperty(fw, CurrentWidgetMode, objectNameProperty, qVariantFromValue(objectNameValue)); + setProperty(fw, CurrentWidgetMode, objectNameProperty, QVariant::fromValue(objectNameValue)); } } } @@ -465,7 +465,7 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS qDebug() << "** WARNING Invalid property" << propertyName << " passed to changeTextProperty!"; return; } - PropertySheetStringValue textValue = qVariantValue(sheet->property(index)); + PropertySheetStringValue textValue = qvariant_cast(sheet->property(index)); const QString oldText = textValue.value(); // Pop up respective dialog bool accepted = false; @@ -498,7 +498,7 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS textValue.setValue(newText); - setProperty(fw, pm, propertyName, qVariantFromValue(textValue)); + setProperty(fw, pm, propertyName, QVariant::fromValue(textValue)); } void QDesignerTaskMenu::changeToolTip() @@ -673,7 +673,7 @@ void QDesignerTaskMenu::navigateToSlot(QDesignerFormEditorInterface *core, if (selectSignalDialog.exec() == QDialog::Accepted) { QTreeWidgetItem *selectedItem = dialogUi.signalList->selectedItems().first(); const QString signalSignature = selectedItem->text(0); - const QStringList parameterNames = qVariantValue(selectedItem->data(0, Qt::UserRole)); + const QStringList parameterNames = qvariant_cast(selectedItem->data(0, Qt::UserRole)); // TODO: Check whether signal is connected to slot integr->emitNavigateToSlot(objectName, signalSignature, parameterNames); diff --git a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp index e3bc64c..629c810 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -146,7 +146,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) // Insert before if (action && index != 0 && !action->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Insert Separator before '%1'").arg(action->objectName()), 0); - qVariantSetValue(itemData, action); + itemData.setValue(action); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); rc.push_back(newSeperatorAct); @@ -155,7 +155,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) // Append separator if (actions.empty() || !actions.back()->isSeparator()) { QAction *newSeperatorAct = new QAction(tr("Append Separator"), 0); - qVariantSetValue(itemData, static_cast(0)); + itemData.setValue(static_cast(0)); newSeperatorAct->setData(itemData); connect(newSeperatorAct, SIGNAL(triggered()), this, SLOT(slotInsertSeparator())); rc.push_back(newSeperatorAct); @@ -167,7 +167,7 @@ ActionList ToolBarEventFilter::contextMenuActions(const QPoint &globalPos) // Remove if (action) { QAction *a = new QAction(tr("Remove action '%1'").arg(action->objectName()), 0); - qVariantSetValue(itemData, action); + itemData.setValue(action); a->setData(itemData); connect(a, SIGNAL(triggered()), this, SLOT(slotRemoveSelectedAction())); rc.push_back(a); diff --git a/tools/designer/src/lib/shared/qdesigner_toolbox.cpp b/tools/designer/src/lib/shared/qdesigner_toolbox.cpp index 986bfbe..c0f7c20 100644 --- a/tools/designer/src/lib/shared/qdesigner_toolbox.cpp +++ b/tools/designer/src/lib/shared/qdesigner_toolbox.cpp @@ -260,12 +260,12 @@ QToolBoxWidgetPropertySheet::QToolBoxWidgetPropertySheet(QToolBox *object, QObje QDesignerPropertySheet(object, parent), m_toolBox(object) { - createFakeProperty(QLatin1String(currentItemTextKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentItemTextKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(currentItemNameKey), QString()); - createFakeProperty(QLatin1String(currentItemIconKey), qVariantFromValue(qdesigner_internal::PropertySheetIconValue())); + createFakeProperty(QLatin1String(currentItemIconKey), QVariant::fromValue(qdesigner_internal::PropertySheetIconValue())); if (formWindowBase()) formWindowBase()->addReloadableProperty(this, indexOf(QLatin1String(currentItemIconKey))); - createFakeProperty(QLatin1String(currentItemToolTipKey), qVariantFromValue(qdesigner_internal::PropertySheetStringValue())); + createFakeProperty(QLatin1String(currentItemToolTipKey), QVariant::fromValue(qdesigner_internal::PropertySheetStringValue())); createFakeProperty(QLatin1String(tabSpacingKey), QVariant(tabSpacingDefault)); } @@ -306,18 +306,18 @@ void QToolBoxWidgetPropertySheet::setProperty(int index, const QVariant &value) switch (toolBoxProperty) { case PropertyCurrentItemText: m_toolBox->setItemText(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].text = qVariantValue(value); + m_pageToData[currentWidget].text = qvariant_cast(value); break; case PropertyCurrentItemName: currentWidget->setObjectName(value.toString()); break; case PropertyCurrentItemIcon: m_toolBox->setItemIcon(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].icon = qVariantValue(value); + m_pageToData[currentWidget].icon = qvariant_cast(value); break; case PropertyCurrentItemToolTip: m_toolBox->setItemToolTip(currentIndex, qvariant_cast(resolvePropertyValue(index, value))); - m_pageToData[currentWidget].tooltip = qVariantValue(value); + m_pageToData[currentWidget].tooltip = qvariant_cast(value); break; case PropertyTabSpacing: case PropertyToolBoxNone: @@ -353,24 +353,24 @@ QVariant QToolBoxWidgetPropertySheet::property(int index) const QWidget *currentWidget = m_toolBox->currentWidget(); if (!currentWidget) { if (toolBoxProperty == PropertyCurrentItemIcon) - return qVariantFromValue(qdesigner_internal::PropertySheetIconValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetIconValue()); if (toolBoxProperty == PropertyCurrentItemText) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); if (toolBoxProperty == PropertyCurrentItemToolTip) - return qVariantFromValue(qdesigner_internal::PropertySheetStringValue()); + return QVariant::fromValue(qdesigner_internal::PropertySheetStringValue()); return QVariant(QString()); } // index-dependent switch (toolBoxProperty) { case PropertyCurrentItemText: - return qVariantFromValue(m_pageToData.value(currentWidget).text); + return QVariant::fromValue(m_pageToData.value(currentWidget).text); case PropertyCurrentItemName: return currentWidget->objectName(); case PropertyCurrentItemIcon: - return qVariantFromValue(m_pageToData.value(currentWidget).icon); + return QVariant::fromValue(m_pageToData.value(currentWidget).icon); case PropertyCurrentItemToolTip: - return qVariantFromValue(m_pageToData.value(currentWidget).tooltip); + return QVariant::fromValue(m_pageToData.value(currentWidget).tooltip); case PropertyTabSpacing: case PropertyToolBoxNone: break; diff --git a/tools/designer/src/lib/shared/qdesigner_utils.cpp b/tools/designer/src/lib/shared/qdesigner_utils.cpp index 3bd0704..de3e387 100644 --- a/tools/designer/src/lib/shared/qdesigner_utils.cpp +++ b/tools/designer/src/lib/shared/qdesigner_utils.cpp @@ -82,8 +82,8 @@ namespace qdesigner_internal for (int c = 0; c < item->columnCount(); c++) { const QVariant v = item->data(c, Qt::DecorationPropertyRole); - if (qVariantCanConvert(v)) - item->setIcon(c, iconCache->icon(qVariantValue(v))); + if (v.canConvert()) + item->setIcon(c, iconCache->icon(qvariant_cast(v))); } } @@ -93,8 +93,8 @@ namespace qdesigner_internal return; const QVariant v = item->data(Qt::DecorationPropertyRole); - if (qVariantCanConvert(v)) - item->setIcon(iconCache->icon(qVariantValue(v))); + if (v.canConvert()) + item->setIcon(iconCache->icon(qvariant_cast(v))); } void reloadTableItem(DesignerIconCache *iconCache, QTableWidgetItem *item) @@ -103,8 +103,8 @@ namespace qdesigner_internal return; const QVariant v = item->data(Qt::DecorationPropertyRole); - if (qVariantCanConvert(v)) - item->setIcon(iconCache->icon(qVariantValue(v))); + if (v.canConvert()) + item->setIcon(iconCache->icon(qvariant_cast(v))); } void reloadIconResources(DesignerIconCache *iconCache, QObject *object) @@ -115,8 +115,8 @@ namespace qdesigner_internal } else if (QComboBox *comboBox = qobject_cast(object)) { for (int i = 0; i < comboBox->count(); i++) { const QVariant v = comboBox->itemData(i, Qt::DecorationPropertyRole); - if (qVariantCanConvert(v)) { - QIcon icon = iconCache->icon(qVariantValue(v)); + if (v.canConvert()) { + QIcon icon = iconCache->icon(qvariant_cast(v)); comboBox->setItemIcon(i, icon); comboBox->setItemData(i, icon); } diff --git a/tools/designer/src/lib/shared/qdesigner_utils_p.h b/tools/designer/src/lib/shared/qdesigner_utils_p.h index fac0697..bed1d05 100644 --- a/tools/designer/src/lib/shared/qdesigner_utils_p.h +++ b/tools/designer/src/lib/shared/qdesigner_utils_p.h @@ -432,15 +432,15 @@ namespace Utils { inline int valueOf(const QVariant &value, bool *ok = 0) { - if (qVariantCanConvert(value)) { + if (value.canConvert()) { if (ok) *ok = true; - return qVariantValue(value).value; + return qvariant_cast(value).value; } - else if (qVariantCanConvert(value)) { + else if (value.canConvert()) { if (ok) *ok = true; - return qVariantValue(value).value; + return qvariant_cast(value).value; } return value.toInt(ok); } diff --git a/tools/designer/src/lib/shared/stylesheeteditor.cpp b/tools/designer/src/lib/shared/stylesheeteditor.cpp index b76d700..955f8e4 100644 --- a/tools/designer/src/lib/shared/stylesheeteditor.cpp +++ b/tools/designer/src/lib/shared/stylesheeteditor.cpp @@ -393,14 +393,14 @@ StyleSheetPropertyEditorDialog::StyleSheetPropertyEditorDialog(QWidget *parent, qt_extension(m_fw->core()->extensionManager(), m_widget); Q_ASSERT(sheet != 0); const int index = sheet->indexOf(QLatin1String(styleSheetProperty)); - const PropertySheetStringValue value = qVariantValue(sheet->property(index)); + const PropertySheetStringValue value = qvariant_cast(sheet->property(index)); setText(value.value()); } void StyleSheetPropertyEditorDialog::applyStyleSheet() { const PropertySheetStringValue value(text(), false); - m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), qVariantFromValue(value)); + m_fw->cursor()->setWidgetProperty(m_widget, QLatin1String(styleSheetProperty), QVariant::fromValue(value)); } } // namespace qdesigner_internal diff --git a/tools/designer/src/lib/uilib/abstractformbuilder.cpp b/tools/designer/src/lib/uilib/abstractformbuilder.cpp index a280876..ad2aa05 100644 --- a/tools/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/tools/designer/src/lib/uilib/abstractformbuilder.cpp @@ -363,7 +363,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge const QStringList zOrderNames = ui_widget->elementZOrder(); if (!zOrderNames.isEmpty()) { - QList zOrder = qVariantValue(w->property("_q_zOrder")); + QList zOrder = qvariant_cast(w->property("_q_zOrder")); foreach (const QString &widgetName, zOrderNames) { if (QWidget *child = w->findChild(widgetName)) { if (child->parentWidget() == w) { @@ -373,7 +373,7 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge } } } - w->setProperty("_q_zOrder", qVariantFromValue(zOrder)); + w->setProperty("_q_zOrder", QVariant::fromValue(zOrder)); } return w; @@ -1287,7 +1287,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent { QList childObjects = widget->children(); - const QList list = qVariantValue(widget->property("_q_widgetOrder")); + const QList list = qvariant_cast(widget->property("_q_widgetOrder")); foreach (QWidget *w, list) { if (childObjects.contains(w)) { children.append(w); @@ -1296,7 +1296,7 @@ DomWidget *QAbstractFormBuilder::createDom(QWidget *widget, DomWidget *ui_parent } children += childObjects; - const QList zOrder = qVariantValue(widget->property("_q_zOrder")); + const QList zOrder = qvariant_cast(widget->property("_q_zOrder")); if (list != zOrder) { QStringList zOrderList; QListIterator itZOrder(zOrder); @@ -1747,7 +1747,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, T *item, if ((p = properties.value(it.second))) { v = formBuilder->textBuilder()->loadText(p); QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); - item->setData(it.first.first, qVariantValue(nativeValue)); + item->setData(it.first.first, qvariant_cast(nativeValue)); item->setData(it.first.second, v); } @@ -1759,7 +1759,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, T *item, if ((p = properties.value(strings.iconAttribute))) { v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); - item->setIcon(qVariantValue(nativeValue)); + item->setIcon(qvariant_cast(nativeValue)); item->setData(Qt::DecorationPropertyRole, v); } } @@ -1855,7 +1855,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidge if ((p = properties.value(it.second))) { v = formBuilder->textBuilder()->loadText(p); QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); - item->setData(it.first.first, qVariantValue(nativeValue)); + item->setData(it.first.first, qvariant_cast(nativeValue)); item->setData(it.first.second, v); } @@ -1867,7 +1867,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QTableWidge if ((p = properties.value(strings.iconAttribute))) { v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); - item->setIcon(qVariantValue(nativeValue)); + item->setIcon(qvariant_cast(nativeValue)); item->setData(Qt::DecorationPropertyRole, v); } } @@ -1885,7 +1885,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidget if ((p = properties.value(it.second))) { v = formBuilder->textBuilder()->loadText(p); QVariant nativeValue = formBuilder->textBuilder()->toNativeValue(v); - item->setData(it.first.first, qVariantValue(nativeValue)); + item->setData(it.first.first, qvariant_cast(nativeValue)); item->setData(it.first.second, v); } @@ -1897,7 +1897,7 @@ static void loadItemProps(QAbstractFormBuilder *abstractFormBuilder, QListWidget if ((p = properties.value(strings.iconAttribute))) { v = formBuilder->resourceBuilder()->loadResource(formBuilder->workingDirectory(), p); QVariant nativeValue = formBuilder->resourceBuilder()->toNativeValue(v); - item->setIcon(qVariantValue(nativeValue)); + item->setIcon(qvariant_cast(nativeValue)); item->setData(Qt::DecorationPropertyRole, v); } } @@ -2337,14 +2337,14 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi if ((p = properties.value(it.second))) { v = textBuilder()->loadText(p); QVariant nativeValue = textBuilder()->toNativeValue(v); - treeWidget->headerItem()->setData(i, it.first.first, qVariantValue(nativeValue)); + treeWidget->headerItem()->setData(i, it.first.first, qvariant_cast(nativeValue)); treeWidget->headerItem()->setData(i, it.first.second, v); } if ((p = properties.value(strings.iconAttribute))) { v = resourceBuilder()->loadResource(workingDirectory(), p); QVariant nativeValue = resourceBuilder()->toNativeValue(v); - treeWidget->headerItem()->setIcon(i, qVariantValue(nativeValue)); + treeWidget->headerItem()->setIcon(i, qvariant_cast(nativeValue)); treeWidget->headerItem()->setData(i, Qt::DecorationPropertyRole, v); } } @@ -2374,14 +2374,14 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi col++; QVariant textV = textBuilder()->loadText(property); QVariant nativeValue = textBuilder()->toNativeValue(textV); - currentItem->setText(col, qVariantValue(nativeValue)); + currentItem->setText(col, qvariant_cast(nativeValue)); currentItem->setData(col, Qt::DisplayPropertyRole, textV); } else if (col >= 0) { if (property->attributeName() == strings.iconAttribute) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), property); if (v.isValid()) { QVariant nativeValue = resourceBuilder()->toNativeValue(v); - currentItem->setIcon(col, qVariantValue(nativeValue)); + currentItem->setIcon(col, qvariant_cast(nativeValue)); currentItem->setData(col, Qt::DecorationPropertyRole, v); } } else { @@ -2397,7 +2397,7 @@ void QAbstractFormBuilder::loadTreeWidgetExtraInfo(DomWidget *ui_widget, QTreeWi if (rolePair.first >= 0) { QVariant textV = textBuilder()->loadText(property); QVariant nativeValue = textBuilder()->toNativeValue(textV); - currentItem->setData(col, rolePair.first, qVariantValue(nativeValue)); + currentItem->setData(col, rolePair.first, qvariant_cast(nativeValue)); currentItem->setData(col, rolePair.second, textV); } } @@ -2475,13 +2475,13 @@ void QAbstractFormBuilder::loadComboBoxExtraInfo(DomWidget *ui_widget, QComboBox p = properties.value(strings.textAttribute); if (p && p->elementString()) { textData = textBuilder()->loadText(p); - text = qVariantValue(textBuilder()->toNativeValue(textData)); + text = qvariant_cast(textBuilder()->toNativeValue(textData)); } p = properties.value(strings.iconAttribute); if (p) { iconData = resourceBuilder()->loadResource(workingDirectory(), p); - icon = qVariantValue(resourceBuilder()->toNativeValue(iconData)); + icon = qvariant_cast(resourceBuilder()->toNativeValue(iconData)); } comboBox->addItem(icon, text); diff --git a/tools/designer/src/lib/uilib/properties.cpp b/tools/designer/src/lib/uilib/properties.cpp index 615aa8a..b660dc4 100644 --- a/tools/designer/src/lib/uilib/properties.cpp +++ b/tools/designer/src/lib/uilib/properties.cpp @@ -78,7 +78,7 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, case DomProperty::String: { const int index = meta->indexOfProperty(p->attributeName().toUtf8()); if (index != -1 && meta->property(index).type() == QVariant::KeySequence) - return qVariantFromValue(QKeySequence(p->elementString()->text())); + return QVariant::fromValue(QKeySequence(p->elementString()->text())); } break; @@ -96,7 +96,7 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, afb->setupColorGroup(palette, QPalette::Disabled, dom->elementDisabled()); palette.setCurrentColorGroup(QPalette::Active); - return qVariantFromValue(palette); + return QVariant::fromValue(palette); } case DomProperty::Set: { @@ -135,7 +135,7 @@ QVariant domPropertyToVariant(QAbstractFormBuilder *afb,const QMetaObject *meta, return QVariant(e.keyToValue(enumValue.toUtf8())); } case DomProperty::Brush: - return qVariantFromValue(afb->setupBrush(p->elementBrush())); + return QVariant::fromValue(afb->setupBrush(p->elementBrush())); default: if (afb->resourceBuilder()->isResourceProperty(p)) { return afb->resourceBuilder()->loadResource(afb->workingDirectory(), p); @@ -212,7 +212,7 @@ QVariant domPropertyToVariant(const DomProperty *p) case DomProperty::Char: { const DomChar *character = p->elementChar(); const QChar c(character->elementUnicode()); - return qVariantFromValue(c); + return QVariant::fromValue(c); } case DomProperty::Color: { @@ -220,7 +220,7 @@ QVariant domPropertyToVariant(const DomProperty *p) QColor c(color->elementRed(), color->elementGreen(), color->elementBlue()); if (color->hasAttributeAlpha()) c.setAlpha(color->attributeAlpha()); - return qVariantFromValue(c); + return QVariant::fromValue(c); } case DomProperty::Font: { @@ -248,7 +248,7 @@ QVariant domPropertyToVariant(const DomProperty *p) if (font->hasElementStyleStrategy()) { f.setStyleStrategy(enumKeyOfObjectToValue("styleStrategy", font->elementStyleStrategy().toLatin1())); } - return qVariantFromValue(f); + return QVariant::fromValue(f); } case DomProperty::Date: { @@ -275,15 +275,15 @@ QVariant domPropertyToVariant(const DomProperty *p) #ifndef QT_NO_CURSOR case DomProperty::Cursor: - return qVariantFromValue(QCursor(static_cast(p->elementCursor()))); + return QVariant::fromValue(QCursor(static_cast(p->elementCursor()))); case DomProperty::CursorShape: - return qVariantFromValue(QCursor(enumKeyOfObjectToValue("cursorShape", p->elementCursorShape().toLatin1()))); + return QVariant::fromValue(QCursor(enumKeyOfObjectToValue("cursorShape", p->elementCursorShape().toLatin1()))); #endif case DomProperty::Locale: { const DomLocale *locale = p->elementLocale(); - return qVariantFromValue(QLocale(enumKeyOfObjectToValue("language", locale->attributeLanguage().toLatin1()), + return QVariant::fromValue(QLocale(enumKeyOfObjectToValue("language", locale->attributeLanguage().toLatin1()), enumKeyOfObjectToValue("country", locale->attributeCountry().toLatin1()))); } case DomProperty::SizePolicy: { @@ -309,7 +309,7 @@ QVariant domPropertyToVariant(const DomProperty *p) sizePolicy.setVerticalPolicy(sp); } - return qVariantFromValue(sizePolicy); + return QVariant::fromValue(sizePolicy); } case DomProperty::StringList: diff --git a/tools/designer/src/lib/uilib/resourcebuilder.cpp b/tools/designer/src/lib/uilib/resourcebuilder.cpp index 810bea0..d19a09a 100644 --- a/tools/designer/src/lib/uilib/resourcebuilder.cpp +++ b/tools/designer/src/lib/uilib/resourcebuilder.cpp @@ -91,7 +91,7 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP case DomProperty::Pixmap: { const DomResourcePixmap *dpx = property->elementPixmap(); QPixmap pixmap(QFileInfo(workingDirectory, dpx->text()).absoluteFilePath()); - return qVariantFromValue(pixmap); + return QVariant::fromValue(pixmap); } case DomProperty::IconSet: { const DomResourceIcon *dpi = property->elementIconSet(); @@ -113,10 +113,10 @@ QVariant QResourceBuilder::loadResource(const QDir &workingDirectory, const DomP icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOff()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::Off); if (flags & SelectedOn) icon.addFile(QFileInfo(workingDirectory, dpi->elementSelectedOn()->text()).absoluteFilePath(), QSize(), QIcon::Selected, QIcon::On); - return qVariantFromValue(icon); + return QVariant::fromValue(icon); } else { // 4.3 legacy const QIcon icon(QFileInfo(workingDirectory, dpi->text()).absoluteFilePath()); - return qVariantFromValue(icon); + return QVariant::fromValue(icon); } } break; diff --git a/tools/designer/src/uitools/quiloader.cpp b/tools/designer/src/uitools/quiloader.cpp index c7e7829..411059e 100644 --- a/tools/designer/src/uitools/quiloader.cpp +++ b/tools/designer/src/uitools/quiloader.cpp @@ -102,27 +102,27 @@ QVariant TranslatingTextBuilder::loadText(const DomProperty *text) const if (str->hasAttributeNotr()) { const QString notr = str->attributeNotr(); if (notr == QLatin1String("true") || notr == QLatin1String("yes")) - return qVariantFromValue(str->text()); + return QVariant::fromValue(str->text()); } QUiTranslatableStringValue strVal; strVal.setValue(str->text().toUtf8()); if (str->hasAttributeComment()) strVal.setComment(str->attributeComment().toUtf8()); - return qVariantFromValue(strVal); + return QVariant::fromValue(strVal); } QVariant TranslatingTextBuilder::toNativeValue(const QVariant &value) const { - if (qVariantCanConvert(value)) { - QUiTranslatableStringValue tsv = qVariantValue(value); + if (value.canConvert()) { + QUiTranslatableStringValue tsv = qvariant_cast(value); if (!m_trEnabled) return QString::fromUtf8(tsv.value().data()); - return qVariantFromValue( + return QVariant::fromValue( QApplication::translate(m_className, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8)); } - if (qVariantCanConvert(value)) - return qVariantFromValue(qVariantValue(value)); + if (value.canConvert()) + return QVariant::fromValue(qvariant_cast(value)); return value; } @@ -150,7 +150,7 @@ static void recursiveReTranslate(QTreeWidgetItem *item, const QByteArray &class_ for (unsigned j = 0; irs[j].shadowRole >= 0; j++) { QVariant v = item->data(i, irs[j].shadowRole); if (v.isValid()) { - QUiTranslatableStringValue tsv = qVariantValue(v); + QUiTranslatableStringValue tsv = qvariant_cast(v); const QString text = QApplication::translate(class_name, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -172,7 +172,7 @@ static void reTranslateWidgetItem(T *item, const QByteArray &class_name) for (unsigned j = 0; irs[j].shadowRole >= 0; j++) { QVariant v = item->data(irs[j].shadowRole); if (v.isValid()) { - QUiTranslatableStringValue tsv = qVariantValue(v); + QUiTranslatableStringValue tsv = qvariant_cast(v); const QString text = QApplication::translate(class_name, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -191,7 +191,7 @@ static void reTranslateTableItem(QTableWidgetItem *item, const QByteArray &class do { \ QVariant v = mainWidget->widget(i)->property(propName); \ if (v.isValid()) { \ - QUiTranslatableStringValue tsv = qVariantValue(v); \ + QUiTranslatableStringValue tsv = qvariant_cast(v); \ const QString text = QApplication::translate(m_className, \ tsv.value(), tsv.comment(), \ QCoreApplication::UnicodeUTF8); \ @@ -217,7 +217,7 @@ public: if (prop.startsWith(PROP_GENERIC_PREFIX)) { const QByteArray propName = prop.mid(sizeof(PROP_GENERIC_PREFIX) - 1); const QUiTranslatableStringValue tsv = - qVariantValue(o->property(prop)); + qvariant_cast(o->property(prop)); const QString text = QApplication::translate(m_className, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -273,7 +273,7 @@ public: for (int i = 0; i < cnt; ++i) { const QVariant v = combow->itemData(i, Qt::DisplayPropertyRole); if (v.isValid()) { - QUiTranslatableStringValue tsv = qVariantValue(v); + QUiTranslatableStringValue tsv = qvariant_cast(v); const QString text = QApplication::translate(m_className, tsv.value(), tsv.comment(), QCoreApplication::UnicodeUTF8); @@ -430,7 +430,7 @@ void FormBuilderPrivate::applyProperties(QObject *o, const QList & continue; const QByteArray name = p->attributeName().toUtf8(); if (dynamicTr) { - o->setProperty(PROP_GENERIC_PREFIX + name, qVariantFromValue(strVal)); + o->setProperty(PROP_GENERIC_PREFIX + name, QVariant::fromValue(strVal)); anyTrs = trEnabled; } o->setProperty(name, text); @@ -489,7 +489,7 @@ QWidget *FormBuilderPrivate::create(DomWidget *ui_widget, QWidget *parentWidget) const QString text = convertTranslatable(p##attribute, m_class, &strVal); \ if (!text.isEmpty()) { \ if (dynamicTr) \ - mainWidget->widget(i)->setProperty(propName, qVariantFromValue(strVal)); \ + mainWidget->widget(i)->setProperty(propName, QVariant::fromValue(strVal)); \ mainWidget->setter(i, text); \ } \ } \ diff --git a/tools/linguist/linguist/formpreviewview.cpp b/tools/linguist/linguist/formpreviewview.cpp index f360a16..3f3f82a 100644 --- a/tools/linguist/linguist/formpreviewview.cpp +++ b/tools/linguist/linguist/formpreviewview.cpp @@ -83,7 +83,7 @@ static bool operator==(const QUiTranslatableStringValue &tsv1, const QUiTranslat target.type = _type; \ target.target._target; \ target.prop._prop; \ - (*targets)[qVariantValue(_tsv)].append(target); \ + (*targets)[qvariant_cast(_tsv)].append(target); \ } while (0) static void registerTreeItem(QTreeWidgetItem *item, TargetsHash *targets) @@ -350,14 +350,14 @@ static void highlightAction(QAction *a, bool on) if (on) { if (!bak.isValid()) { QFont fnt = qApp->font(); - a->setProperty(FONT_BACKUP_PROP, qVariantFromValue(a->font().resolve(fnt))); + a->setProperty(FONT_BACKUP_PROP, QVariant::fromValue(a->font().resolve(fnt))); fnt.setBold(true); fnt.setItalic(true); a->setFont(fnt); } } else { if (bak.isValid()) { - a->setFont(qVariantValue(bak)); + a->setFont(qvariant_cast(bak)); a->setProperty(FONT_BACKUP_PROP, QVariant()); } } @@ -374,8 +374,8 @@ static void highlightWidget(QWidget *w, bool on) foreach (QObject *co, w->children()) if (QWidget *cw = qobject_cast(co)) cw->setPalette(cw->palette().resolve(pal)); - w->setProperty(PALETTE_BACKUP_PROP, qVariantFromValue(w->palette().resolve(pal))); - w->setProperty(AUTOFILL_BACKUP_PROP, qVariantFromValue(w->autoFillBackground())); + w->setProperty(PALETTE_BACKUP_PROP, QVariant::fromValue(w->palette().resolve(pal))); + w->setProperty(AUTOFILL_BACKUP_PROP, QVariant::fromValue(w->autoFillBackground())); QColor col1 = pal.color(QPalette::Dark); QColor col2 = pal.color(QPalette::Light); pal.setColor(QPalette::Base, col1); @@ -390,8 +390,8 @@ static void highlightWidget(QWidget *w, bool on) } } else { if (bak.isValid()) { - w->setPalette(qVariantValue(bak)); - w->setAutoFillBackground(qVariantValue(w->property(AUTOFILL_BACKUP_PROP))); + w->setPalette(qvariant_cast(bak)); + w->setAutoFillBackground(qvariant_cast(w->property(AUTOFILL_BACKUP_PROP))); w->setProperty(PALETTE_BACKUP_PROP, QVariant()); w->setProperty(AUTOFILL_BACKUP_PROP, QVariant()); } diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp index 1611699..9072bab 100644 --- a/tools/linguist/linguist/mainwindow.cpp +++ b/tools/linguist/linguist/mainwindow.cpp @@ -184,7 +184,7 @@ private: static const QVariant &pxObsolete() { static const QVariant v = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); return v; } diff --git a/tools/linguist/linguist/messagemodel.cpp b/tools/linguist/linguist/messagemodel.cpp index 39ba9fd..36202ab 100644 --- a/tools/linguist/linguist/messagemodel.cpp +++ b/tools/linguist/linguist/messagemodel.cpp @@ -1231,17 +1231,17 @@ int MessageModel::columnCount(const QModelIndex &) const QVariant MessageModel::data(const QModelIndex &index, int role) const { static QVariant pxOn = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_on.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_on.png"))); static QVariant pxOff = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_off.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_off.png"))); static QVariant pxObsolete = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_obsolete.png"))); static QVariant pxDanger = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_danger.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_danger.png"))); static QVariant pxWarning = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_warning.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_warning.png"))); static QVariant pxEmpty = - qVariantFromValue(QPixmap(QLatin1String(":/images/s_check_empty.png"))); + QVariant::fromValue(QPixmap(QLatin1String(":/images/s_check_empty.png"))); int row = index.row(); int column = index.column() - 1; diff --git a/tools/makeqpf/mainwindow.cpp b/tools/makeqpf/mainwindow.cpp index 166a193..ae723f5 100644 --- a/tools/makeqpf/mainwindow.cpp +++ b/tools/makeqpf/mainwindow.cpp @@ -199,7 +199,7 @@ void MainWindow::on_generate_clicked() if (item->checkState() != Qt::Checked) continue; - QPF::CharacterRange range = qVariantValue(item->data(Qt::UserRole)); + QPF::CharacterRange range = qvariant_cast(item->data(Qt::UserRole)); ranges.append(range); } } @@ -297,7 +297,7 @@ void MainWindow::populateCharacterRanges() item->setText(text); item->setCheckState(Qt::Checked); - item->setData(Qt::UserRole, qVariantFromValue(range)); + item->setData(Qt::UserRole, QVariant::fromValue(range)); } } diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp index ce18cb9..c93288c 100644 --- a/tools/qdbus/qdbus/qdbus.cpp +++ b/tools/qdbus/qdbus/qdbus.cpp @@ -324,7 +324,7 @@ static int placeCall(const QString &service, const QString &path, const QString if (id == int(QMetaType::UChar)) { // special case: QVariant::convert doesn't convert to/from // UChar because it can't decide if it's a character or a number - p = qVariantFromValue(p.toUInt()); + p = QVariant::fromValue(p.toUInt()); } else if (id < int(QMetaType::User) && id != int(QVariant::Map)) { p.convert(QVariant::Type(id)); if (p.type() == QVariant::Invalid) { @@ -334,7 +334,7 @@ static int placeCall(const QString &service, const QString &path, const QString } } else if (id == qMetaTypeId()) { QDBusVariant tmp(p); - p = qVariantFromValue(tmp); + p = QVariant::fromValue(tmp); } else if (id == qMetaTypeId()) { QDBusObjectPath path(argument); if (path.path().isNull()) { @@ -342,7 +342,7 @@ static int placeCall(const QString &service, const QString &path, const QString qPrintable(argument)); return 1; } - p = qVariantFromValue(path); + p = QVariant::fromValue(path); } else if (id == qMetaTypeId()) { QDBusSignature sig(argument); if (sig.signature().isNull()) { @@ -350,7 +350,7 @@ static int placeCall(const QString &service, const QString &path, const QString qPrintable(argument)); return 1; } - p = qVariantFromValue(sig); + p = QVariant::fromValue(sig); } else { fprintf(stderr, "Sorry, can't pass arg of type '%s'.\n", types.at(i).constData()); diff --git a/tools/qdbus/qdbusviewer/qdbusviewer.cpp b/tools/qdbus/qdbusviewer/qdbusviewer.cpp index 9878aff..9bc5a15 100644 --- a/tools/qdbus/qdbusviewer/qdbusviewer.cpp +++ b/tools/qdbus/qdbusviewer/qdbusviewer.cpp @@ -217,7 +217,7 @@ void QDBusViewer::setProperty(const BusSignature &sig) QDBusMessage message = QDBusMessage::createMethodCall(sig.mService, sig.mPath, QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("Set")); QList arguments; - arguments << sig.mInterface << sig.mName << qVariantFromValue(QDBusVariant(value)); + arguments << sig.mInterface << sig.mName << QVariant::fromValue(QDBusVariant(value)); message.setArguments(arguments); c.callWithCallback(message, this, SLOT(dumpMessage(QDBusMessage))); @@ -283,7 +283,7 @@ void QDBusViewer::callMethod(const BusSignature &sig) // interface wants a variant for (int i = 0; i < args.count(); ++i) { if (types.at(i) == qMetaTypeId()) - args[i] = qVariantFromValue(QDBusVariant(args.at(i))); + args[i] = QVariant::fromValue(QDBusVariant(args.at(i))); } QDBusMessage message = QDBusMessage::createMethodCall(sig.mService, sig.mPath, sig.mInterface, diff --git a/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp b/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp index d9343e3..31667dc 100644 --- a/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp +++ b/tools/qdbus/qdbusxml2cpp/qdbusxml2cpp.cpp @@ -617,7 +617,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (property.access != QDBusIntrospection::Property::Read) { hs << " inline void " << setter << "(" << constRefArg(type) << "value)" << endl << " { setProperty(\"" << property.name - << "\", qVariantFromValue(value)); }" << endl; + << "\", QVariant::fromValue(value)); }" << endl; } hs << endl; @@ -660,7 +660,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (!method.inputArgs.isEmpty()) { hs << " argumentList"; for (int argPos = 0; argPos < method.inputArgs.count(); ++argPos) - hs << " << qVariantFromValue(" << argNames.at(argPos) << ')'; + hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; hs << ";" << endl; } @@ -693,7 +693,7 @@ static void writeProxy(const QString &filename, const QDBusIntrospection::Interf if (!method.inputArgs.isEmpty()) { hs << " argumentList"; for (argPos = 0; argPos < method.inputArgs.count(); ++argPos) - hs << " << qVariantFromValue(" << argNames.at(argPos) << ')'; + hs << " << QVariant::fromValue(" << argNames.at(argPos) << ')'; hs << ";" << endl; } @@ -940,7 +940,7 @@ static void writeAdaptor(const QString &filename, const QDBusIntrospection::Inte cs << "void " << className << "::" << setter << "(" << constRefType << "value)" << endl << "{" << endl << " // set the value of property " << property.name << endl - << " parent()->setProperty(\"" << property.name << "\", qVariantFromValue(value"; + << " parent()->setProperty(\"" << property.name << "\", QVariant::fromValue(value"; if (constRefType.contains(QLatin1String("QDBusVariant"))) cs << ".variant()"; cs << "));" << endl diff --git a/tools/shared/qtpropertybrowser/qtvariantproperty.cpp b/tools/shared/qtpropertybrowser/qtvariantproperty.cpp index 15b0ced..948fa1e 100644 --- a/tools/shared/qtpropertybrowser/qtvariantproperty.cpp +++ b/tools/shared/qtpropertybrowser/qtvariantproperty.cpp @@ -549,7 +549,7 @@ void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, con void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QKeySequence &val) { QVariant v; - qVariantSetValue(v, val); + v.setValue(val); valueChanged(property, v); } @@ -636,7 +636,7 @@ void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, { if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) { QVariant v; - qVariantSetValue(v, enumIcons); + v.setValue(enumIcons); emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v); } } @@ -1488,7 +1488,7 @@ QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, co return enumManager->enumNames(internProp); if (attribute == d_ptr->m_enumIconsAttribute) { QVariant v; - qVariantSetValue(v, enumManager->enumIcons(internProp)); + v.setValue(enumManager->enumIcons(internProp)); return v; } return QVariant(); @@ -1568,73 +1568,73 @@ void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &va QtAbstractPropertyManager *manager = internProp->propertyManager(); if (QtIntPropertyManager *intManager = qobject_cast(manager)) { - intManager->setValue(internProp, qVariantValue(val)); + intManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtDoublePropertyManager *doubleManager = qobject_cast(manager)) { - doubleManager->setValue(internProp, qVariantValue(val)); + doubleManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtBoolPropertyManager *boolManager = qobject_cast(manager)) { - boolManager->setValue(internProp, qVariantValue(val)); + boolManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtStringPropertyManager *stringManager = qobject_cast(manager)) { - stringManager->setValue(internProp, qVariantValue(val)); + stringManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtDatePropertyManager *dateManager = qobject_cast(manager)) { - dateManager->setValue(internProp, qVariantValue(val)); + dateManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtTimePropertyManager *timeManager = qobject_cast(manager)) { - timeManager->setValue(internProp, qVariantValue(val)); + timeManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast(manager)) { - dateTimeManager->setValue(internProp, qVariantValue(val)); + dateTimeManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast(manager)) { - keySequenceManager->setValue(internProp, qVariantValue(val)); + keySequenceManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtCharPropertyManager *charManager = qobject_cast(manager)) { - charManager->setValue(internProp, qVariantValue(val)); + charManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtLocalePropertyManager *localeManager = qobject_cast(manager)) { - localeManager->setValue(internProp, qVariantValue(val)); + localeManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtPointPropertyManager *pointManager = qobject_cast(manager)) { - pointManager->setValue(internProp, qVariantValue(val)); + pointManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtPointFPropertyManager *pointFManager = qobject_cast(manager)) { - pointFManager->setValue(internProp, qVariantValue(val)); + pointFManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtSizePropertyManager *sizeManager = qobject_cast(manager)) { - sizeManager->setValue(internProp, qVariantValue(val)); + sizeManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast(manager)) { - sizeFManager->setValue(internProp, qVariantValue(val)); + sizeFManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtRectPropertyManager *rectManager = qobject_cast(manager)) { - rectManager->setValue(internProp, qVariantValue(val)); + rectManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtRectFPropertyManager *rectFManager = qobject_cast(manager)) { - rectFManager->setValue(internProp, qVariantValue(val)); + rectFManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtColorPropertyManager *colorManager = qobject_cast(manager)) { - colorManager->setValue(internProp, qVariantValue(val)); + colorManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtEnumPropertyManager *enumManager = qobject_cast(manager)) { - enumManager->setValue(internProp, qVariantValue(val)); + enumManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtSizePolicyPropertyManager *sizePolicyManager = qobject_cast(manager)) { - sizePolicyManager->setValue(internProp, qVariantValue(val)); + sizePolicyManager->setValue(internProp, qvariant_cast(val)); return; } else if (QtFontPropertyManager *fontManager = qobject_cast(manager)) { - fontManager->setValue(internProp, qVariantValue(val)); + fontManager->setValue(internProp, qvariant_cast(val)); return; #ifndef QT_NO_CURSOR } else if (QtCursorPropertyManager *cursorManager = qobject_cast(manager)) { - cursorManager->setValue(internProp, qVariantValue(val)); + cursorManager->setValue(internProp, qvariant_cast(val)); return; #endif } else if (QtFlagPropertyManager *flagManager = qobject_cast(manager)) { - flagManager->setValue(internProp, qVariantValue(val)); + flagManager->setValue(internProp, qvariant_cast(val)); return; } } @@ -1672,69 +1672,69 @@ void QtVariantPropertyManager::setAttribute(QtProperty *property, QtAbstractPropertyManager *manager = internProp->propertyManager(); if (QtIntPropertyManager *intManager = qobject_cast(manager)) { if (attribute == d_ptr->m_maximumAttribute) - intManager->setMaximum(internProp, qVariantValue(value)); + intManager->setMaximum(internProp, qvariant_cast(value)); else if (attribute == d_ptr->m_minimumAttribute) - intManager->setMinimum(internProp, qVariantValue(value)); + intManager->setMinimum(internProp, qvariant_cast(value)); else if (attribute == d_ptr->m_singleStepAttribute) - intManager->setSingleStep(internProp, qVariantValue(value)); + intManager->setSingleStep(internProp, qvariant_cast(value)); return; } else if (QtDoublePropertyManager *doubleManager = qobject_cast(manager)) { if (attribute == d_ptr->m_maximumAttribute) - doubleManager->setMaximum(internProp, qVariantValue(value)); + doubleManager->setMaximum(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_minimumAttribute) - doubleManager->setMinimum(internProp, qVariantValue(value)); + doubleManager->setMinimum(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_singleStepAttribute) - doubleManager->setSingleStep(internProp, qVariantValue(value)); + doubleManager->setSingleStep(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_decimalsAttribute) - doubleManager->setDecimals(internProp, qVariantValue(value)); + doubleManager->setDecimals(internProp, qvariant_cast(value)); return; } else if (QtStringPropertyManager *stringManager = qobject_cast(manager)) { if (attribute == d_ptr->m_regExpAttribute) - stringManager->setRegExp(internProp, qVariantValue(value)); + stringManager->setRegExp(internProp, qvariant_cast(value)); return; } else if (QtDatePropertyManager *dateManager = qobject_cast(manager)) { if (attribute == d_ptr->m_maximumAttribute) - dateManager->setMaximum(internProp, qVariantValue(value)); + dateManager->setMaximum(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_minimumAttribute) - dateManager->setMinimum(internProp, qVariantValue(value)); + dateManager->setMinimum(internProp, qvariant_cast(value)); return; } else if (QtPointFPropertyManager *pointFManager = qobject_cast(manager)) { if (attribute == d_ptr->m_decimalsAttribute) - pointFManager->setDecimals(internProp, qVariantValue(value)); + pointFManager->setDecimals(internProp, qvariant_cast(value)); return; } else if (QtSizePropertyManager *sizeManager = qobject_cast(manager)) { if (attribute == d_ptr->m_maximumAttribute) - sizeManager->setMaximum(internProp, qVariantValue(value)); + sizeManager->setMaximum(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_minimumAttribute) - sizeManager->setMinimum(internProp, qVariantValue(value)); + sizeManager->setMinimum(internProp, qvariant_cast(value)); return; } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast(manager)) { if (attribute == d_ptr->m_maximumAttribute) - sizeFManager->setMaximum(internProp, qVariantValue(value)); + sizeFManager->setMaximum(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_minimumAttribute) - sizeFManager->setMinimum(internProp, qVariantValue(value)); + sizeFManager->setMinimum(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_decimalsAttribute) - sizeFManager->setDecimals(internProp, qVariantValue(value)); + sizeFManager->setDecimals(internProp, qvariant_cast(value)); return; } else if (QtRectPropertyManager *rectManager = qobject_cast(manager)) { if (attribute == d_ptr->m_constraintAttribute) - rectManager->setConstraint(internProp, qVariantValue(value)); + rectManager->setConstraint(internProp, qvariant_cast(value)); return; } else if (QtRectFPropertyManager *rectFManager = qobject_cast(manager)) { if (attribute == d_ptr->m_constraintAttribute) - rectFManager->setConstraint(internProp, qVariantValue(value)); + rectFManager->setConstraint(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_decimalsAttribute) - rectFManager->setDecimals(internProp, qVariantValue(value)); + rectFManager->setDecimals(internProp, qvariant_cast(value)); return; } else if (QtEnumPropertyManager *enumManager = qobject_cast(manager)) { if (attribute == d_ptr->m_enumNamesAttribute) - enumManager->setEnumNames(internProp, qVariantValue(value)); + enumManager->setEnumNames(internProp, qvariant_cast(value)); if (attribute == d_ptr->m_enumIconsAttribute) - enumManager->setEnumIcons(internProp, qVariantValue(value)); + enumManager->setEnumIcons(internProp, qvariant_cast(value)); return; } else if (QtFlagPropertyManager *flagManager = qobject_cast(manager)) { if (attribute == d_ptr->m_flagNamesAttribute) - flagManager->setFlagNames(internProp, qVariantValue(value)); + flagManager->setFlagNames(internProp, qvariant_cast(value)); return; } } diff --git a/tools/xmlpatterns/main.cpp b/tools/xmlpatterns/main.cpp index b0e9e67..8479de7 100644 --- a/tools/xmlpatterns/main.cpp +++ b/tools/xmlpatterns/main.cpp @@ -145,14 +145,14 @@ protected: } /* The value.isNull() check ensures we can bind variables whose value is an empty string. */ - return qVariantFromValue(Parameter(name, value.isNull() ? QString(QLatin1String("")) : value )); + return QVariant::fromValue(Parameter(name, value.isNull() ? QString(QLatin1String("")) : value )); } else if(arg.name() == QLatin1String("output")) { QFile *const f = new QFile(input); if(f->open(QIODevice::WriteOnly)) - return qVariantFromValue(static_cast(f)); + return QVariant::fromValue(static_cast(f)); else { message(QXmlPatternistCLI::tr("Failed to open file %1 for writing: %2").arg(f->fileName(), f->errorString())); @@ -168,7 +168,7 @@ protected: return QVariant(); } else - return qVariantFromValue(name); + return QVariant::fromValue(name); } else return QApplicationArgumentParser::convertToValue(arg, input); @@ -200,7 +200,7 @@ protected: out->open(stdout, QIODevice::WriteOnly); #endif - return qVariantFromValue(static_cast(out)); + return QVariant::fromValue(static_cast(out)); } else return QApplicationArgumentParser::defaultValue(argument); @@ -317,7 +317,7 @@ int main(int argc, char **argv) QXmlQuery query(lang, namePool); - query.setInitialTemplateName(qVariantValue(parser.value(initialTemplateName))); + query.setInitialTemplateName(qvariant_cast(parser.value(initialTemplateName))); /* Bind external variables. */ { @@ -329,7 +329,7 @@ int main(int argc, char **argv) for(int i = 0; i < len; ++i) { - const Parameter p(qVariantValue(parameters.at(i))); + const Parameter p(qvariant_cast(parameters.at(i))); if(usedParameters.contains(p.first)) { @@ -359,7 +359,7 @@ int main(int argc, char **argv) query.setQuery(effectiveURI); - const QPatternist::AutoPtr outDevice(qVariantValue(parser.value(output))); + const QPatternist::AutoPtr outDevice(qvariant_cast(parser.value(output))); Q_ASSERT(outDevice); Q_ASSERT(outDevice->isWritable()); -- cgit v0.12 From 6f09167b4fde25e04611557549a0d0d0cfd6a6ae Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Aug 2010 11:15:11 +0200 Subject: Deprecate qScriptValueFromQMetaObject, qScriptValueToValue, qScriptValueFromValue Rev-by: dev mailing list --- src/script/api/qscriptengine.cpp | 9 +++++--- src/script/api/qscriptengine.h | 45 ++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index a7a20c1..ee02b9d 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2442,6 +2442,7 @@ QScriptValue QScriptEngine::newQMetaObject( \fn QScriptValue qScriptValueFromQMetaObject(QScriptEngine *engine) \since 4.3 \relates QScriptEngine + \obsolete Uses \a engine to create a QScriptValue that represents the Qt class \c{T}. @@ -3762,6 +3763,7 @@ QStringList QScriptEngine::importedExtensions() const \fn QScriptValue qScriptValueFromValue(QScriptEngine *engine, const T &value) \since 4.3 \relates QScriptEngine + \obsolete Creates a QScriptValue using the given \a engine with the given \a value of template type \c{T}. @@ -3772,13 +3774,14 @@ QStringList QScriptEngine::importedExtensions() const which did not support member template functions. It is advised to use the other form in new code. - \sa qScriptValueToValue() + \sa QScriptEngine::toScriptValue(), qscriptvalue_cast */ /*! \fn T qScriptValueToValue(const QScriptValue &value) \since 4.3 \relates QScriptEngine + \obsolete Returns the given \a value converted to the template type \c{T}. @@ -3788,7 +3791,7 @@ QStringList QScriptEngine::importedExtensions() const which did not support member template functions. It is advised to use the other form in new code. - \sa qScriptValueFromValue() + \sa QScriptEngine::fromScriptValue() */ /*! @@ -3807,7 +3810,7 @@ QStringList QScriptEngine::importedExtensions() const \l{Conversion Between QtScript and C++ Types} for more information about the restrictions on types that can be used with QScriptValue. - \sa qScriptValueFromValue() + \sa QScriptEngine::fromScriptValue() */ /*! diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index 6add6ed..eafd40c 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -69,7 +69,7 @@ template inline QScriptValue qScriptValueFromValue(QScriptEngine *, const T &); template -inline T qScriptValueToValue(const QScriptValue &); +inline T qscriptvalue_cast(const QScriptValue &); class QScriptSyntaxCheckResultPrivate; class Q_SCRIPT_EXPORT QScriptSyntaxCheckResult @@ -217,7 +217,7 @@ public: template inline T fromScriptValue(const QScriptValue &value) { - return qScriptValueToValue(value); + return qscriptvalue_cast(value); } void installTranslatorFunctions(const QScriptValue &object = QScriptValue()); @@ -279,19 +279,6 @@ private: }; #ifndef QT_NO_QOBJECT -template -inline QScriptValue qScriptValueFromQMetaObject( - QScriptEngine *engine -#ifndef qdoc - , T * /* dummy */ = 0 -#endif - ) -{ - typedef QScriptValue(*ConstructPtr)(QScriptContext *, QScriptEngine *, T *); - ConstructPtr cptr = qscriptQMetaObjectConstructor; - return engine->newQMetaObject(&T::staticMetaObject, - engine->newFunction(reinterpret_cast(cptr), 0)); -} #define Q_SCRIPT_DECLARE_QMETAOBJECT(T, _Arg1) \ template<> inline QScriptValue qscriptQMetaObjectConstructor(QScriptContext *ctx, QScriptEngine *eng, T *) \ @@ -305,10 +292,26 @@ template<> inline QScriptValue qscriptQMetaObjectConstructor(QScriptContext * return o; \ } - template QScriptValue QScriptEngine::scriptValueFromQMetaObject() - { - return qScriptValueFromQMetaObject(this); - } +template QScriptValue QScriptEngine::scriptValueFromQMetaObject() +{ + typedef QScriptValue(*ConstructPtr)(QScriptContext *, QScriptEngine *, T *); + ConstructPtr cptr = qscriptQMetaObjectConstructor; + return newQMetaObject(&T::staticMetaObject, + newFunction(reinterpret_cast(cptr), 0)); +} + +#ifdef QT_DEPRECATED +template +inline QT_DEPRECATED QScriptValue qScriptValueFromQMetaObject( + QScriptEngine *engine +#ifndef qdoc + , T * /* dummy */ = 0 +#endif + ) +{ + return engine->scriptValueFromQMetaObject(); +} +#endif #endif // QT_NO_QOBJECT @@ -360,11 +363,13 @@ inline QVariant qscriptvalue_cast(const QScriptValue &value) return value.toVariant(); } +#ifdef QT_DEPRECATED template -inline T qScriptValueToValue(const QScriptValue &value) +inline QT_DEPRECATED T qScriptValueToValue(const QScriptValue &value) { return qscriptvalue_cast(value); } +#endif inline void qScriptRegisterMetaType_helper(QScriptEngine *eng, int type, QScriptEngine::MarshalFunction mf, -- cgit v0.12 From 4232955aa9498a5e1e4e4b3fb4662222acffe70f Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Aug 2010 11:38:41 +0200 Subject: Remove usage of deprecated QScriptValue* function Tests were untouched. Regexp used: git grep -O"sed -i 's/qScriptValueFromQMetaObject *<\([^>]*\)> *(\([^&*\(),]*\))/\\2->scriptValueFromQMetaObject<\\1>()/g'" qScriptValueFromQMetaObject git grep -O"sed -i 's/qScriptValueFromValue(this, */toScriptValue(/'" qScriptValueFromValue git grep -O"sed -i 's/qScriptValueFromValue(\([^&*\(),]*\), */\\1->toScriptValue(/'" qScriptValueFromValue git grep -O"sed -i 's/qScriptValueFromValue(&\([^&*\(),]*\), */\\1.toScriptValue(/'" qScriptValueFromValue git grep -O"sed -i 's/qScriptValueToValuenewFunction(construct, proto); - ctor.setData(qScriptValueFromValue(engine, this)); + ctor.setData(engine->toScriptValue(this)); } //! [0] diff --git a/examples/script/marshal/main.cpp b/examples/script/marshal/main.cpp index adfeaf1..270cb56 100644 --- a/examples/script/marshal/main.cpp +++ b/examples/script/marshal/main.cpp @@ -49,7 +49,7 @@ QScriptValue toScriptValue(QScriptEngine *eng, const Container &cont) typename Container::const_iterator end = cont.end(); typename Container::const_iterator it; for (it = begin; it != end; ++it) - a.setProperty(quint32(it - begin), qScriptValueFromValue(eng, *it)); + a.setProperty(quint32(it - begin), eng->toScriptValue(*it)); return a; } diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index a96e4f4..a5b5fcc 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1469,7 +1469,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine if (a < 0.0) a=0.0; if (a > 1.0) a=1.0; - return qScriptValueFromValue(engine, QVariant::fromValue(QColor::fromRgbF(r, g, b, a))); + return engine->toScriptValue(QVariant::fromValue(QColor::fromRgbF(r, g, b, a))); } /*! @@ -1497,7 +1497,7 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine if (a < 0.0) a=0.0; if (a > 1.0) a=1.0; - return qScriptValueFromValue(engine, QVariant::fromValue(QColor::fromHslF(h, s, l, a))); + return engine->toScriptValue(QVariant::fromValue(QColor::fromHslF(h, s, l, a))); } /*! @@ -1582,7 +1582,7 @@ QScriptValue QDeclarativeEnginePrivate::lighter(QScriptContext *ctxt, QScriptEng if (ctxt->argumentCount() == 2) factor = ctxt->argument(1).toNumber(); color = color.lighter(int(qRound(factor*100.))); - return qScriptValueFromValue(engine, QVariant::fromValue(color)); + return engine->toScriptValue(QVariant::fromValue(color)); } /*! @@ -1619,7 +1619,7 @@ QScriptValue QDeclarativeEnginePrivate::darker(QScriptContext *ctxt, QScriptEngi if (ctxt->argumentCount() == 2) factor = ctxt->argument(1).toNumber(); color = color.darker(int(qRound(factor*100.))); - return qScriptValueFromValue(engine, QVariant::fromValue(color)); + return engine->toScriptValue(QVariant::fromValue(color)); } /*! @@ -1854,7 +1854,7 @@ QScriptValue QDeclarativeEnginePrivate::tint(QScriptContext *ctxt, QScriptEngine a + inv_a * color.alphaF()); } - return qScriptValueFromValue(engine, QVariant::fromValue(finalColor)); + return engine->toScriptValue(QVariant::fromValue(finalColor)); } QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &val) @@ -1884,7 +1884,7 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v if (objOk) { return objectClass->newQObject(obj); } else { - return qScriptValueFromValue(&scriptEngine, val); + return scriptEngine.toScriptValue(val); } } diff --git a/src/declarative/util/qdeclarativelistmodel.cpp b/src/declarative/util/qdeclarativelistmodel.cpp index 596c53b..6b969e3 100644 --- a/src/declarative/util/qdeclarativelistmodel.cpp +++ b/src/declarative/util/qdeclarativelistmodel.cpp @@ -864,7 +864,7 @@ QScriptValue FlatListModel::get(int index) const QHash row = m_values.at(index); for (QHash::ConstIterator iter = row.begin(); iter != row.end(); ++iter) - rv.setProperty(m_roles.value(iter.key()), qScriptValueFromValue(scriptEngine, iter.value())); + rv.setProperty(m_roles.value(iter.key()), scriptEngine->toScriptValue(iter.value())); return rv; } diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 7c1e1fd..05f751d 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -809,7 +809,7 @@ QScriptValue QDeclarativeXmlListModel::get(int index) const QScriptValue sv = sengine->newObject(); for (int i=0; iroleObjects.count(); i++) - sv.setProperty(d->roleObjects[i]->name(), qScriptValueFromValue(sengine, d->data.value(i).value(index))); + sv.setProperty(d->roleObjects[i]->name(), sengine->toScriptValue(d->data.value(i).value(index))); return sv; } diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index eafd40c..cdf6099 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -212,7 +212,7 @@ public: template inline QScriptValue toScriptValue(const T &value) { - return qScriptValueFromValue(this, value); + return toScriptValue(value); } template inline T fromScriptValue(const QScriptValue &value) @@ -409,7 +409,7 @@ QScriptValue qScriptValueFromSequence(QScriptEngine *eng, const Container &cont) typename Container::const_iterator it; quint32 i; for (it = begin, i = 0; it != end; ++it, ++i) - a.setProperty(i, qScriptValueFromValue(eng, *it)); + a.setProperty(i, eng->toScriptValue(*it)); return a; } diff --git a/src/scripttools/debugging/qscriptdebuggerconsole.cpp b/src/scripttools/debugging/qscriptdebuggerconsole.cpp index 2f7a998..268b30e 100644 --- a/src/scripttools/debugging/qscriptdebuggerconsole.cpp +++ b/src/scripttools/debugging/qscriptdebuggerconsole.cpp @@ -76,7 +76,7 @@ QT_BEGIN_NAMESPACE static QScriptValue debuggerResponseToScriptValue(QScriptEngine *eng, const QScriptDebuggerResponse &in) { QScriptValue out = eng->newObject(); - out.setProperty(QString::fromLatin1("result"), qScriptValueFromValue(eng, in.result())); + out.setProperty(QString::fromLatin1("result"), eng->toScriptValue(in.result())); out.setProperty(QString::fromLatin1("error"), QScriptValue(eng, in.error())); out.setProperty(QString::fromLatin1("async"), QScriptValue(eng, in.async())); return out; @@ -122,7 +122,7 @@ static QScriptValue breakpointMapToScriptValue(QScriptEngine *eng, const QScript QScriptValue out = eng->newObject(); QScriptBreakpointMap::const_iterator it; for (it = in.constBegin(); it != in.constEnd(); ++it) { - out.setProperty(QString::number(it.key()), qScriptValueFromValue(eng, it.value())); + out.setProperty(QString::number(it.key()), eng->toScriptValue(it.value())); } return out; } @@ -155,7 +155,7 @@ static QScriptValue scriptMapToScriptValue(QScriptEngine *eng, const QScriptScri QScriptValue out = eng->newObject(); QScriptScriptMap::const_iterator it; for (it = in.constBegin(); it != in.constEnd(); ++it) { - out.setProperty(QString::number(it.key()), qScriptValueFromValue(eng, it.value())); + out.setProperty(QString::number(it.key()), eng->toScriptValue(it.value())); } return out; } @@ -175,8 +175,8 @@ static QScriptValue consoleCommandToScriptValue( out.setProperty(QString::fromLatin1("group"), QScriptValue(eng, in->group())); out.setProperty(QString::fromLatin1("shortDescription"), QScriptValue(eng, in->shortDescription())); out.setProperty(QString::fromLatin1("longDescription"), QScriptValue(eng, in->longDescription())); - out.setProperty(QString::fromLatin1("aliases"), qScriptValueFromValue(eng, in->aliases())); - out.setProperty(QString::fromLatin1("seeAlso"), qScriptValueFromValue(eng, in->seeAlso())); + out.setProperty(QString::fromLatin1("aliases"), eng->toScriptValue(in->aliases())); + out.setProperty(QString::fromLatin1("seeAlso"), eng->toScriptValue(in->seeAlso())); return out; } @@ -207,7 +207,7 @@ static QScriptValue consoleCommandGroupMapToScriptValue( QScriptValue out = eng->newObject(); QScriptDebuggerConsoleCommandGroupMap::const_iterator it; for (it = in.constBegin(); it != in.constEnd(); ++it) { - out.setProperty(it.key(), qScriptValueFromValue(eng, it.value())); + out.setProperty(it.key(), eng->toScriptValue(it.value())); } return out; } @@ -238,7 +238,7 @@ static QScriptValue debuggerScriptValuePropertyToScriptValue(QScriptEngine *eng, { QScriptValue out = eng->newObject(); out.setProperty(QString::fromLatin1("name"), QScriptValue(eng, in.name())); - out.setProperty(QString::fromLatin1("value"), qScriptValueFromValue(eng, in.value())); + out.setProperty(QString::fromLatin1("value"), eng->toScriptValue(in.value())); out.setProperty(QString::fromLatin1("valueAsString"), QScriptValue(eng, in.valueAsString())); out.setProperty(QString::fromLatin1("flags"), QScriptValue(eng, static_cast(in.flags()))); return out; diff --git a/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp b/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp index 117c2d6..83cabfd 100644 --- a/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp +++ b/src/scripttools/debugging/qscriptdebuggerscriptedconsolecommand.cpp @@ -227,7 +227,7 @@ void QScriptDebuggerScriptedConsoleCommandJob::handleResponse( QScriptEngine *engine = d->command->globalObject.engine(); engine->setGlobalObject(d->command->globalObject); QScriptValueList args; - args.append(qScriptValueFromValue(engine, response)); + args.append(engine->toScriptValue(response)); args.append(QScriptValue(engine, commandId)); QScriptDebuggerConsoleGlobalObject *global; global = qobject_cast(d->command->globalObject.toQObject()); -- cgit v0.12 From 2dddba7f6641e2a49912e87d07dfecd3bb68d916 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Aug 2010 11:47:13 +0200 Subject: Deprecate qGenericMatrixFromMatrix4x4 and qGenericMatrixToMatrix4x4 Rev-by: dev mailing list --- src/gui/math3d/qmatrix4x4.cpp | 10 +++++----- src/gui/math3d/qmatrix4x4.h | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp index 04a9099..2f03bd0 100644 --- a/src/gui/math3d/qmatrix4x4.cpp +++ b/src/gui/math3d/qmatrix4x4.cpp @@ -110,7 +110,7 @@ QMatrix4x4::QMatrix4x4(const qreal *values) the remaining elements are filled with elements from the identity matrix. - \sa toGenericMatrix(), qGenericMatrixToMatrix4x4() + \sa toGenericMatrix() */ /*! @@ -120,32 +120,32 @@ QMatrix4x4::QMatrix4x4(const qreal *values) top-most M rows of this 4x4 matrix. If N or M is greater than 4, then the remaining elements are filled with elements from the identity matrix. - - \sa qGenericMatrixFromMatrix4x4() */ /*! \fn QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix& matrix) \relates QMatrix4x4 + \obsolete Returns a 4x4 matrix constructed from the left-most 4 columns and top-most 4 rows of \a matrix. If \a matrix has less than 4 columns or rows, the remaining elements are filled with elements from the identity matrix. - \sa qGenericMatrixFromMatrix4x4() + \sa QMatrix4x4(const QGenericMatrix &) */ /*! \fn QGenericMatrix qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix) \relates QMatrix4x4 + \obsolete Returns a NxM generic matrix constructed from the left-most N columns and top-most M rows of \a matrix. If N or M is greater than 4, then the remaining elements are filled with elements from the identity matrix. - \sa qGenericMatrixToMatrix4x4(), QMatrix4x4::toGenericMatrix() + \sa QMatrix4x4::toGenericMatrix() */ /*! diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h index 1f77d36..598058c 100644 --- a/src/gui/math3d/qmatrix4x4.h +++ b/src/gui/math3d/qmatrix4x4.h @@ -986,14 +986,15 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QMatrix4x4 &); Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QMatrix4x4 &); #endif +#ifdef QT_DEPRECATED template -QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix& matrix) +QT_DEPRECATED QMatrix4x4 qGenericMatrixToMatrix4x4(const QGenericMatrix& matrix) { return QMatrix4x4(matrix.constData(), N, M); } template -QGenericMatrix qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix) +QT_DEPRECATED QGenericMatrix qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix) { QGenericMatrix result; const qreal *m = matrix.constData(); @@ -1010,6 +1011,7 @@ QGenericMatrix qGenericMatrixFromMatrix4x4(const QMatrix4x4& matrix } return result; } +#endif #endif -- 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 73791fe53805f3bfad651c36fce9249441f864cd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Aug 2010 12:40:01 +0200 Subject: Fix recursion in QScriptEngine::toScriptValue Introduced by mistake in 4232955aa9498a5e1e4e4b3fb4662222acffe70f Reviewed-by: Yoann Lopes --- src/script/api/qscriptengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index cdf6099..27e5a13 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -212,7 +212,7 @@ public: template inline QScriptValue toScriptValue(const T &value) { - return toScriptValue(value); + return qScriptValueFromValue(value); } template inline T fromScriptValue(const QScriptValue &value) -- cgit v0.12 From 04fe6ee36cbabf7e2a8e70f3baed026a23394b4f Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Fri, 6 Aug 2010 13:09:34 +0200 Subject: Compile. Related to 73791fe53805f3bfad651c36fce9249441f864cd. --- src/script/api/qscriptengine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/api/qscriptengine.h b/src/script/api/qscriptengine.h index 27e5a13..830d477 100644 --- a/src/script/api/qscriptengine.h +++ b/src/script/api/qscriptengine.h @@ -212,7 +212,7 @@ public: template inline QScriptValue toScriptValue(const T &value) { - return qScriptValueFromValue(value); + return qScriptValueFromValue(this, value); } template inline T fromScriptValue(const QScriptValue &value) -- 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 d8ecf6b6f6b6c0f532a4c9f25bcd36e808dc0d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Wed, 14 Jul 2010 08:07:40 +0200 Subject: Fix some broken exports in dbus. QT_SHARED is only defined when the Qt modules is built... --- src/dbus/qdbusmacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qdbusmacros.h index 693a350..f110ff6 100644 --- a/src/dbus/qdbusmacros.h +++ b/src/dbus/qdbusmacros.h @@ -48,7 +48,7 @@ #if defined(QDBUS_MAKEDLL) # define QDBUS_EXPORT Q_DECL_EXPORT -#elif defined(QT_SHARED) +#elif defined(QT_SHARED) || defined(QT_DLL) # define QDBUS_EXPORT Q_DECL_IMPORT #else # define QDBUS_EXPORT -- 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 cfc1658c68ee3b7227277a4549b60de545ec5f6f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 9 Aug 2010 14:03:45 +0200 Subject: Added QPainter::clipBoundingRect() which is significantly faster than QPainter::clipRegion().boundingRect(). Task: http://bugreports.qt.nokia.com/browse/QTBUG-12618 Reviewed-by: Kim --- src/gui/painting/qpainter.cpp | 55 ++++++++++++++++++++++++++++++++++++ src/gui/painting/qpainter.h | 2 ++ tests/auto/qpainter/tst_qpainter.cpp | 37 ++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index f24eafd..c4de7f0 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -2702,6 +2702,61 @@ QPainterPath QPainter::clipPath() const } /*! + Returns the bounding rectangle of the current clip if there is a clip; + otherwise returns an empty rectangle. Note that the clip region is + given in logical coordinates. + + The bounding rectangle is not guaranteed to be tight. + + \sa setClipRect(), setClipPath(), setClipRegion() + + \since 4.8 + */ + +QRectF QPainter::clipBoundingRect() const +{ + Q_D(const QPainter); + + if (!d->engine) { + qWarning("QPainter::clipBoundingRect: Painter not active"); + return QRectF(); + } + + // Accumulate the bounding box in device space. This is not 100% + // precise, but it fits within the guarantee and it is resonably + // fast. + QRectF bounds; + for (int i=0; istate->clipInfo.size(); ++i) { + QRectF r; + const QPainterClipInfo &info = d->state->clipInfo.at(i); + + if (info.clipType == QPainterClipInfo::RectClip) + r = info.rect; + else if (info.clipType == QPainterClipInfo::RegionClip) + r = info.region.boundingRect(); + else + r = info.path.boundingRect(); + + r = info.matrix.mapRect(r); + + if (i == 0) + bounds = r; + else if (info.operation == Qt::IntersectClip) + bounds &= r; + else if (info.operation == Qt::UniteClip) + bounds |= r; + } + + + // Map the rectangle back into logical space using the inverse + // matrix. + if (!d->txinv) + const_cast(this)->d_ptr->updateInvMatrix(); + + return d->invMatrix.mapRect(bounds); +} + +/*! \fn void QPainter::setClipRect(const QRectF &rectangle, Qt::ClipOperation operation) Enables clipping, and sets the clip region to the given \a diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 85751a9..96305e3 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -222,6 +222,8 @@ public: void setClipping(bool enable); bool hasClipping() const; + QRectF clipBoundingRect() const; + void save(); void restore(); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index f358681..9ed212f 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -168,6 +168,8 @@ private slots: void clippedText(); + void clipBoundingRect(); + void setOpacity_data(); void setOpacity(); @@ -4522,6 +4524,41 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate() QCOMPARE(widget->deviceTransform, proxy->deviceTransform); } +void tst_QPainter::clipBoundingRect() +{ + QPixmap pix(500, 500); + + QPainter p(&pix); + + // Test a basic rectangle + p.setClipRect(100, 100, 200, 100); + QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200))); + p.setClipRect(120, 120, 20, 20, Qt::IntersectClip); + QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + + // Test a basic path + region + QPainterPath path; + path.addRect(100, 100, 200, 100); + p.setClipPath(path); + QVERIFY(p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(50, 50, 300, 200))); + p.setClipRegion(QRegion(120, 120, 20, 20), Qt::IntersectClip); + QVERIFY(p.clipBoundingRect().contains(QRect(120, 120, 20, 20))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(100, 100, 200, 100))); + + p.setClipRect(0, 0, 500, 500); + p.translate(250, 250); + for (int i=0; i<360; ++i) { + p.rotate(1); + p.setClipRect(-100, -100, 200, 200, Qt::IntersectClip); + } + QVERIFY(p.clipBoundingRect().contains(QRectF(-100, -100, 200, 200))); + QVERIFY(!p.clipBoundingRect().contains(QRectF(-250, -250, 500, 500))); + +} + QTEST_MAIN(tst_QPainter) #include "tst_qpainter.moc" -- cgit v0.12 From 2e7d5def1fdabb5949fbffc629da500aa2bb78d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 6 Aug 2010 16:04:27 +0200 Subject: There goes QResourceFileEngineHandler There's no reason why resources can't be handled in the default handler. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qabstractfileengine.cpp | 7 ++++++- src/corelib/io/qresource.cpp | 23 +---------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index d6b6f11..75eaeb4 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -41,6 +41,9 @@ #include "qabstractfileengine.h" #include "private/qabstractfileengine_p.h" +#ifdef QT_BUILD_CORE_LIB +#include "private/qresource_p.h" +#endif #include "qdatetime.h" #include "qreadwritelock.h" #include "qvariant.h" @@ -179,7 +182,9 @@ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) #ifdef QT_BUILD_CORE_LIB if (!fileName.startsWith(QLatin1Char('/'))) { int prefixSeparator = fileName.indexOf(QLatin1Char(':')); - if (prefixSeparator > 1) { + if (prefixSeparator == 0) { + return new QResourceFileEngine(fileName); + } else if (prefixSeparator > 1) { QString prefix = fileName.left(prefixSeparator); QString fileNameWithoutPrefix = fileName.mid(prefixSeparator + 1).prepend(QLatin1Char('/')); const QStringList &paths = QDir::searchPaths(prefix); diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp index ce9c57e..929885c 100644 --- a/src/corelib/io/qresource.cpp +++ b/src/corelib/io/qresource.cpp @@ -1185,21 +1185,6 @@ QResource::unregisterResource(const uchar *rccData, const QString &resourceRoot) return false; } -//file type handler -class QResourceFileEngineHandler : public QAbstractFileEngineHandler -{ -public: - QResourceFileEngineHandler() { } - ~QResourceFileEngineHandler() { } - QAbstractFileEngine *create(const QString &path) const; -}; -QAbstractFileEngine *QResourceFileEngineHandler::create(const QString &path) const -{ - if (path.size() > 0 && path.startsWith(QLatin1Char(':'))) - return new QResourceFileEngine(path); - return 0; -} - //resource engine class QResourceFileEnginePrivate : public QAbstractFileEnginePrivate { @@ -1506,12 +1491,6 @@ bool QResourceFileEnginePrivate::unmap(uchar *ptr) return true; } -//Initialization and cleanup -Q_GLOBAL_STATIC(QResourceFileEngineHandler, resource_file_handler) - -static int qt_force_resource_init() { resource_file_handler(); return 1; } -Q_CORE_EXPORT void qInitResourceIO() { resource_file_handler(); } -static int qt_forced_resource_init = qt_force_resource_init(); -Q_CONSTRUCTOR_FUNCTION(qt_force_resource_init) +Q_CORE_EXPORT void qInitResourceIO() { } // ### Qt 5: remove QT_END_NAMESPACE -- cgit v0.12 From 9a3e7c9c32167b777a090ee13082323d10895694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 9 Aug 2010 13:02:33 +0200 Subject: Fix minor premature pessimizations in file engine creation QAbstractFileEngineHandler ctor adds itself once to handler list, dtor should not try to be any smarter. Repeatedly calling the global static "constructor" fileEngineHandlers() could lead to additional overhead while checking for repeated construction -- that said, compilers can probably figure this one out, but being explicit shouldn't hurt. Reduce string manipulation and copying. Also, prefer QStringBuilder to building strings by hand. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qabstractfileengine.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index 75eaeb4..80bc244 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -50,6 +50,7 @@ // built-in handlers #include "qfsfileengine.h" #include "qdiriterator.h" +#include "qstringbuilder.h" QT_BEGIN_NAMESPACE @@ -138,7 +139,7 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler() QWriteLocker locker(fileEngineHandlerMutex()); // Remove this handler from the handler list only if the list is valid. if (!qt_abstractfileenginehandlerlist_shutDown) - fileEngineHandlers()->removeAll(this); + fileEngineHandlers()->removeOne(this); } /*! @@ -173,8 +174,9 @@ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) QReadLocker locker(fileEngineHandlerMutex()); // check for registered handlers that can load the file - for (int i = 0; i < fileEngineHandlers()->size(); i++) { - if (QAbstractFileEngine *ret = fileEngineHandlers()->at(i)->create(fileName)) + QAbstractFileEngineHandlerList *handlers = fileEngineHandlers(); + for (int i = 0; i < handlers->size(); i++) { + if (QAbstractFileEngine *ret = handlers->at(i)->create(fileName)) return ret; } } @@ -185,13 +187,9 @@ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) if (prefixSeparator == 0) { return new QResourceFileEngine(fileName); } else if (prefixSeparator > 1) { - QString prefix = fileName.left(prefixSeparator); - QString fileNameWithoutPrefix = fileName.mid(prefixSeparator + 1).prepend(QLatin1Char('/')); - const QStringList &paths = QDir::searchPaths(prefix); + const QStringList &paths = QDir::searchPaths(fileName.left(prefixSeparator)); for (int i = 0; i < paths.count(); i++) { - QString path = paths.at(i); - path.append(fileNameWithoutPrefix); - QAbstractFileEngine *engine = create(path); + QAbstractFileEngine *engine = create(paths.at(i) % QLatin1Char('/') % fileName.mid(prefixSeparator + 1)); if (engine && (engine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::ExistsFlag)) { return engine; } -- cgit v0.12 From 127cab437b53096b18beb0cfe299137dc384060d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 9 Aug 2010 17:50:58 +0200 Subject: Make prefix handling in file engine creation more robust ... and make it exit earlier, when feasible. While we could fully validate the prefix at this level, consulting Unicode tables on each character of a file name could quickly become expensive. Furthermore, we can already reap some benefits just by checking for '/' before ':'. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qabstractfileengine.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index 80bc244..6646e4e 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -182,11 +182,18 @@ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) } #ifdef QT_BUILD_CORE_LIB - if (!fileName.startsWith(QLatin1Char('/'))) { - int prefixSeparator = fileName.indexOf(QLatin1Char(':')); - if (prefixSeparator == 0) { - return new QResourceFileEngine(fileName); - } else if (prefixSeparator > 1) { + for (int prefixSeparator = 0; prefixSeparator < fileName.size(); ++prefixSeparator) { + QChar const ch = fileName[prefixSeparator]; + if (ch == QLatin1Char('/')) + break; + + if (ch == QLatin1Char(':')) { + if (prefixSeparator == 0) + return new QResourceFileEngine(fileName); + + if (prefixSeparator == 1) + break; + const QStringList &paths = QDir::searchPaths(fileName.left(prefixSeparator)); for (int i = 0; i < paths.count(); i++) { QAbstractFileEngine *engine = create(paths.at(i) % QLatin1Char('/') % fileName.mid(prefixSeparator + 1)); @@ -195,7 +202,16 @@ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) } delete engine; } + + break; } + + // There's no need to fully validate the prefix here. Consulting the + // unicode tables could be expensive and validation is already + // performed in QDir::setSearchPaths. + // + // if (!ch.isLetterOrNumber()) + // break; } #endif -- cgit v0.12 From 1aca3a1c6d104e52a15039cdbbe88a5e55c9235e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Mon, 9 Aug 2010 17:56:14 +0200 Subject: Are custom file engines in use? If no custom file engine handlers have been registered, we can avoid using the Read/Write lock and, most of the time, we also avoid the creating the handler list at all. Since the custom handler for QResource's engine has been folded into the default handler, there should be no other internal use of this API, thus triggering this optimization by default for all users. The new flag may also in the future be exported to other modules to trigger bypassing of file engines completely. Reviewed-by: Marius Storm-Olsen --- src/corelib/io/qabstractfileengine.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qabstractfileengine.cpp b/src/corelib/io/qabstractfileengine.cpp index 6646e4e..37a093c 100644 --- a/src/corelib/io/qabstractfileengine.cpp +++ b/src/corelib/io/qabstractfileengine.cpp @@ -98,6 +98,8 @@ QT_BEGIN_NAMESPACE \sa QAbstractFileEngine, QAbstractFileEngine::create() */ +static bool qt_file_engine_handlers_in_use = false; + /* All application-wide handlers are stored in this list. The mutex must be acquired to ensure thread safety. @@ -127,6 +129,7 @@ Q_GLOBAL_STATIC(QAbstractFileEngineHandlerList, fileEngineHandlers) QAbstractFileEngineHandler::QAbstractFileEngineHandler() { QWriteLocker locker(fileEngineHandlerMutex()); + qt_file_engine_handlers_in_use = true; fileEngineHandlers()->prepend(this); } @@ -138,8 +141,12 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler() { QWriteLocker locker(fileEngineHandlerMutex()); // Remove this handler from the handler list only if the list is valid. - if (!qt_abstractfileenginehandlerlist_shutDown) - fileEngineHandlers()->removeOne(this); + if (!qt_abstractfileenginehandlerlist_shutDown) { + QAbstractFileEngineHandlerList *handlers = fileEngineHandlers(); + handlers->removeOne(this); + if (handlers->isEmpty()) + qt_file_engine_handlers_in_use = false; + } } /*! @@ -170,7 +177,7 @@ QAbstractFileEngineHandler::~QAbstractFileEngineHandler() */ QAbstractFileEngine *QAbstractFileEngine::create(const QString &fileName) { - { + if (qt_file_engine_handlers_in_use) { QReadLocker locker(fileEngineHandlerMutex()); // check for registered handlers that can load the file -- cgit v0.12 From e0ca32a845fef14d569203056e617ead1adec62c Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 13:06:03 +0200 Subject: qmake msvc generator: remove unneeded handling of variables win32/thread.prf takes care of handling the following variables: MAKE_CXXFLAGS_MT_DLLDBG MAKE_CXXFLAGS_MT_DBG MAKE_CXXFLAGS_MT_DLL MAKE_CXXFLAGS_MT No need to do that in the MSVC generators. It was incorrectly implemented anyway. Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 13 +------------ qmake/generators/win32/msvc_vcxproj.cpp | 13 +------------ 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 8686ae8..bd3f183 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -916,20 +916,9 @@ void VcprojGenerator::initCompilerTool() } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - if(project->isActiveConfig("debug")){ - // Debug version - if((projectTarget == Application) || (projectTarget == StaticLib)) - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DBG")); - else - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DLLDBG")); - } else { - // Release version + if(project->isActiveConfig("release")) { conf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; conf.compiler.PreprocessorDefinitions += "NDEBUG"; - if((projectTarget == Application) || (projectTarget == StaticLib)) - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT")); - else - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DLL")); } // Common for both release and debug diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index f68a435..609f00f 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -292,20 +292,9 @@ void VcxprojGenerator::initCompilerTool() } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - if(project->isActiveConfig("debug")){ - // Debug version - if((projectTarget == Application) || (projectTarget == StaticLib)) - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DBG")); - else - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DLLDBG")); - } else { - // Release version + if(project->isActiveConfig("release")) { conf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; conf.compiler.PreprocessorDefinitions += "NDEBUG"; - if((projectTarget == Application) || (projectTarget == StaticLib)) - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT")); - else - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS_MT_DLL")); } // Common for both release and debug -- cgit v0.12 From 430cbd2f089302ceb7992f71a5d05d7a18863c6e Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 14:04:35 +0200 Subject: qmake: don't add QT_NO_DEBUG in msvc generators This is already done in qt.prf. Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 4 +--- qmake/generators/win32/msvc_vcxproj.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index bd3f183..5abe26e 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -916,10 +916,8 @@ void VcprojGenerator::initCompilerTool() } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - if(project->isActiveConfig("release")) { - conf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; + if(project->isActiveConfig("release")) conf.compiler.PreprocessorDefinitions += "NDEBUG"; - } // Common for both release and debug if(project->isActiveConfig("windows")) diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index 609f00f..d12e809 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -292,10 +292,8 @@ void VcxprojGenerator::initCompilerTool() } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - if(project->isActiveConfig("release")) { - conf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; + if(project->isActiveConfig("release")) conf.compiler.PreprocessorDefinitions += "NDEBUG"; - } // Common for both release and debug if(project->isActiveConfig("windows")) -- cgit v0.12 From a746c8dd6a1932f97ee2a4b1ef1821aac876b96b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 14:16:25 +0200 Subject: qmake: useless addition of the NDEBUG define removed This already happens in initConfiguration. Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 2 -- qmake/generators/win32/msvc_vcxproj.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 5abe26e..4cb8f5a 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -916,8 +916,6 @@ void VcprojGenerator::initCompilerTool() } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - if(project->isActiveConfig("release")) - conf.compiler.PreprocessorDefinitions += "NDEBUG"; // Common for both release and debug if(project->isActiveConfig("windows")) diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index d12e809..4073961 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -292,8 +292,6 @@ void VcxprojGenerator::initCompilerTool() } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - if(project->isActiveConfig("release")) - conf.compiler.PreprocessorDefinitions += "NDEBUG"; // Common for both release and debug if(project->isActiveConfig("windows")) -- cgit v0.12 From 550bef106d54cd649764c320758da912fae4db3e Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 14:36:01 +0200 Subject: qmake: no need to add the _WINDOWS define twice This is already done by MSVCPROJ_WINCONDEF. Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 6 ------ qmake/generators/win32/msvc_vcxproj.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 4cb8f5a..01331b3 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -887,7 +887,6 @@ void VcprojGenerator::initConfiguration() } else { conf.compiler.PreprocessorDefinitions += "NDEBUG"; } - } void VcprojGenerator::initCompilerTool() @@ -921,11 +920,6 @@ void VcprojGenerator::initCompilerTool() if(project->isActiveConfig("windows")) conf.compiler.PreprocessorDefinitions += project->values("MSVCPROJ_WINCONDEF"); - // Can this be set for ALL configs? - // If so, use qmake.conf! - if(projectTarget == SharedLib) - conf.compiler.PreprocessorDefinitions += "_WINDOWS"; - conf.compiler.PreprocessorDefinitions += project->values("DEFINES"); conf.compiler.PreprocessorDefinitions += project->values("PRL_EXPORT_DEFINES"); conf.compiler.parseOptions(project->values("MSVCPROJ_INCPATH")); diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index 4073961..34e75f8 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -263,7 +263,6 @@ void VcxprojGenerator::initConfiguration() } } - void VcxprojGenerator::initCompilerTool() { QString placement = project->first("OBJECTS_DIR"); @@ -297,11 +296,6 @@ void VcxprojGenerator::initCompilerTool() if(project->isActiveConfig("windows")) conf.compiler.PreprocessorDefinitions += project->values("MSVCPROJ_WINCONDEF"); - // Can this be set for ALL configs? - // If so, use qmake.conf! - if(projectTarget == SharedLib) - conf.compiler.PreprocessorDefinitions += "_WINDOWS"; - conf.compiler.PreprocessorDefinitions += project->values("DEFINES"); conf.compiler.PreprocessorDefinitions += project->values("PRL_EXPORT_DEFINES"); conf.compiler.parseOptions(project->values("MSVCPROJ_INCPATH")); -- cgit v0.12 From de6e55237263ea1b0426ffda9386cabba5739208 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 15:37:24 +0200 Subject: qmake: remove VS2003 work-around from vcxproj generator This generator is VS2010 only. Reviewed-by: ossi --- qmake/generators/win32/msvc_nmake.cpp | 2 ++ qmake/generators/win32/msvc_vcproj.cpp | 1 + qmake/generators/win32/msvc_vcxproj.cpp | 6 ------ 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 92e8aeb..0adb152 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -129,10 +129,12 @@ QString NmakeMakefileGenerator::var(const QString &value) p.replace("-c", precompRule); // Cannot use -Gm with -FI & -Yu, as this gives an // internal compiler error, on the newer compilers + // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. p.remove("-Gm"); return p; } else if (value == "QMAKE_CXXFLAGS") { // Remove internal compiler error option + // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. return MakefileGenerator::var(value).remove("-Gm"); } } diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 01331b3..2f949ed 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -908,6 +908,7 @@ void VcprojGenerator::initCompilerTool() conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER"); // Minimal build option triggers an Internal Compiler Error // when used in conjunction with /FI and /Yu, so remove it + // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. project->values("QMAKE_CFLAGS_DEBUG").removeAll("-Gm"); project->values("QMAKE_CFLAGS_DEBUG").removeAll("/Gm"); project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("-Gm"); diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index 34e75f8..3851270 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -282,12 +282,6 @@ void VcxprojGenerator::initCompilerTool() conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER"); conf.compiler.PreprocessToFile = _False; conf.compiler.PreprocessSuppressLineNumbers = _False; - // Minimal build option triggers an Internal Compiler Error - // when used in conjunction with /FI and /Yu, so remove it - project->values("QMAKE_CFLAGS_DEBUG").removeAll("-Gm"); - project->values("QMAKE_CFLAGS_DEBUG").removeAll("/Gm"); - project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("-Gm"); - project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("/Gm"); } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); -- cgit v0.12 From 56e31f8ad585d8524c0d0d21d5d1f6f821fba3c2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 16:21:15 +0200 Subject: qmake: remove Windows CE stuff from .vcxproj generator VS2010 does not support Windows CE. Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 2 - qmake/generators/win32/msvc_vcxproj.cpp | 150 +------------------------------- qmake/generators/win32/msvc_vcxproj.h | 1 - 3 files changed, 4 insertions(+), 149 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 2f949ed..e801371 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1260,7 +1260,6 @@ void VcprojGenerator::initTranslationFiles() vcProject.TranslationFiles.CustomBuild = none; } - void VcprojGenerator::initFormFiles() { vcProject.FormFiles.Name = "Form Files"; @@ -1276,7 +1275,6 @@ void VcprojGenerator::initFormFiles() vcProject.FormFiles.CustomBuild = none; } - void VcprojGenerator::initResourceFiles() { vcProject.ResourceFiles.Name = "Resource Files"; diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index 3851270..d87c0e8 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -112,13 +112,9 @@ void VcxprojGenerator::initProject() vcxProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); vcxProject.Keyword = project->first("VCPROJ_KEYWORD"); - if (project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) { - vcxProject.PlatformName = vcxProject.Configuration.idl.TargetEnvironment; - if ( vcxProject.Configuration.idl.TargetEnvironment.isEmpty() ) - vcxProject.PlatformName = "Win32"; - } else { - vcxProject.PlatformName = project->values("CE_SDK").join(" ") + " (" + project->first("CE_ARCH") + ")"; - } + vcxProject.PlatformName = vcxProject.Configuration.idl.TargetEnvironment; + if (vcxProject.Configuration.idl.TargetEnvironment.isEmpty()) + vcxProject.PlatformName = "Win32"; // These are not used by Qt, but may be used by customers vcxProject.SccProjectName = project->first("SCCPROJECTNAME"); vcxProject.SccLocalPath = project->first("SCCLOCALPATH"); @@ -179,11 +175,7 @@ void VcxprojGenerator::initConfiguration() if (conf.Name.isEmpty()) conf.Name = isDebug ? "Debug" : "Release"; conf.ConfigurationName = conf.Name; - if (project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) { - conf.Name += (conf.idl.TargetEnvironment == "Win64" ? "|Win64" : "|Win32"); - } else { - conf.Name += "|" + project->values("CE_SDK").join(" ") + " (" + project->first("CE_ARCH") + ")"; - } + conf.Name += (conf.idl.TargetEnvironment == "Win64" ? "|Win64" : "|Win32"); conf.ATLMinimizesCRunTimeLibraryUsage = (project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True); conf.BuildBrowserInformation = triState(temp.isEmpty() ? (short)unset : temp.toShort()); temp = project->first("CharacterSet"); @@ -250,9 +242,6 @@ void VcxprojGenerator::initConfiguration() initCustomBuildTool(); initPreBuildEventTools(); initPostBuildEventTools(); - // Only deploy for CE projects - if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) - initDeploymentTool(); initPreLinkEventTools(); // Set definite values in both configurations @@ -360,15 +349,6 @@ void VcxprojGenerator::initPostBuildEventTools() conf.postBuild.UseInBuild = _True; } - QString signature = !project->isEmpty("SIGNATURE_FILE") ? var("SIGNATURE_FILE") : var("DEFAULT_SIGNATURE"); - bool useSignature = !signature.isEmpty() && !project->isActiveConfig("staticlib") && - !project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH"); - if(useSignature) { - conf.postBuild.CommandLine.prepend(QLatin1String("signtool sign /F ") + signature + " \"$(TargetPath)\"\n" + - (!conf.postBuild.CommandLine.isEmpty() ? " && " : "")); - conf.postBuild.UseInBuild = _True; - } - if(!project->values("MSVCPROJ_COPY_DLL").isEmpty()) { if(!conf.postBuild.CommandLine.isEmpty()) conf.postBuild.CommandLine += " && "; @@ -378,128 +358,6 @@ void VcxprojGenerator::initPostBuildEventTools() } } - -void VcxprojGenerator::initDeploymentTool() -{ - VCXConfiguration &conf = vcxProject.Configuration; - QString targetPath = project->values("deploy.path").join(" "); - if (targetPath.isEmpty()) - targetPath = QString("%CSIDL_PROGRAM_FILES%\\") + project->first("TARGET"); - if (targetPath.endsWith("/") || targetPath.endsWith("\\")) - targetPath.chop(1); - - // Only deploy Qt libs for shared build - if (!project->values("QMAKE_QT_DLL").isEmpty()) { - QStringList& arg = project->values("MSVCPROJ_LIBS"); - for (QStringList::ConstIterator it = arg.constBegin(); it != arg.constEnd(); ++it) { - if (it->contains(project->first("QMAKE_LIBDIR"))) { - QString dllName = *it; - - if (dllName.contains(QLatin1String("QAxContainer")) - || dllName.contains(QLatin1String("qtmain")) - || dllName.contains(QLatin1String("QtUiTools"))) - continue; - dllName.replace(QLatin1String(".lib") , QLatin1String(".dll")); - QFileInfo info(dllName); - conf.deployment.AdditionalFiles += info.fileName() - + "|" + QDir::toNativeSeparators(info.absolutePath()) - + "|" + targetPath - + "|0;"; - } - } - } - - // C-runtime deployment - QString runtime = project->values("QT_CE_C_RUNTIME").join(QLatin1String(" ")); - if (!runtime.isEmpty() && (runtime != QLatin1String("no"))) { - QString runtimeVersion = QLatin1String("msvcr"); - QString mkspec = project->first("QMAKESPEC"); - // If no .qmake.cache has been found, we fallback to the original mkspec - if (mkspec.isEmpty()) - mkspec = project->first("QMAKESPEC_ORIGINAL"); - - if (!mkspec.isEmpty()) { - if (mkspec.endsWith("2010")) - runtimeVersion.append("100"); - else if (mkspec.endsWith("2008")) - runtimeVersion.append("90"); - else - runtimeVersion.append("80"); - if (project->isActiveConfig("debug")) - runtimeVersion.append("d"); - runtimeVersion.append(".dll"); - - if (runtime == "yes") { - // Auto-find C-runtime - QString vcInstallDir = qgetenv("VCINSTALLDIR"); - if (!vcInstallDir.isEmpty()) { - vcInstallDir += "\\ce\\dll\\"; - vcInstallDir += project->values("CE_ARCH").join(QLatin1String(" ")); - if (!QFileInfo(vcInstallDir + QDir::separator() + runtimeVersion).exists()) - runtime.clear(); - else - runtime = vcInstallDir; - } - } - } - - if (!runtime.isEmpty() && runtime != QLatin1String("yes")) { - conf.deployment.AdditionalFiles += runtimeVersion - + "|" + QDir::toNativeSeparators(runtime) - + "|" + targetPath - + "|0;"; - } - } - - // foreach item in DEPLOYMENT - foreach(QString item, project->values("DEPLOYMENT")) { - // get item.path - QString devicePath = project->first(item + ".path"); - if (devicePath.isEmpty()) - devicePath = targetPath; - // check if item.path is relative (! either /,\ or %) - if (!(devicePath.at(0) == QLatin1Char('/') - || devicePath.at(0) == QLatin1Char('\\') - || devicePath.at(0) == QLatin1Char('%'))) { - // create output path - devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('\\') + devicePath)); - } - // foreach d in item.sources - foreach(QString source, project->values(item + ".sources")) { - QString itemDevicePath = devicePath; - source = Option::fixPathToLocalOS(source); - QString nameFilter; - QFileInfo info(source); - QString searchPath; - if (info.isDir()) { - nameFilter = QLatin1String("*"); - itemDevicePath += "\\" + info.fileName(); - searchPath = info.absoluteFilePath(); - } else { - nameFilter = source.split('\\').last(); - searchPath = info.absolutePath(); - } - - int pathSize = searchPath.size(); - QDirIterator iterator(searchPath, QStringList() << nameFilter - , QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks - , QDirIterator::Subdirectories); - // foreach dirIterator-entry in d - while(iterator.hasNext()) { - iterator.next(); - QString absoluteItemPath = Option::fixPathToLocalOS(QFileInfo(iterator.filePath()).absolutePath()); - // Identify if it is just another subdir - int diffSize = absoluteItemPath.size() - pathSize; - // write out rules - conf.deployment.AdditionalFiles += iterator.fileName() - + "|" + absoluteItemPath - + "|" + itemDevicePath + (diffSize ? (absoluteItemPath.right(diffSize)) : QLatin1String("")) - + "|0;"; - } - } - } -} - void VcxprojGenerator::initPreLinkEventTools() { VCXConfiguration &conf = vcxProject.Configuration; diff --git a/qmake/generators/win32/msvc_vcxproj.h b/qmake/generators/win32/msvc_vcxproj.h index 8a183e9..efbfcb8 100644 --- a/qmake/generators/win32/msvc_vcxproj.h +++ b/qmake/generators/win32/msvc_vcxproj.h @@ -66,7 +66,6 @@ protected: void initConfiguration(); void initCompilerTool(); - void initDeploymentTool(); void initLinkerTool(); void initPreLinkEventTools(); void initPostBuildEventTools(); -- cgit v0.12 From 938c18a341cd653bb93d28fb0aed2f85a97ae943 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 3 Aug 2010 16:32:48 +0200 Subject: qmake: remove some old .dsp related code from .vcproj generator Removal of the following variables: MSVCPROJ_VERSION, MSVCPROJ_PROJECT, MSVCPROJ_TEMPLATE, MSVCPROJ_CONSOLE, MSVCPROJ_WINCONDEF, MSVCPROJ_VCPROJTYPE and MSVCPROJ_SUBSYSTEM. Apart from MSVCPROJ_WINCONDEF none of these variables were in use. MSVCPROJ_WINCONDEF was used to add the _WINDOWS define if CONFIG contained "windows". The _CONSOLE define was never added. Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 102 ++++++++------------------------ qmake/generators/win32/msvc_vcxproj.cpp | 7 ++- 2 files changed, 28 insertions(+), 81 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index e801371..08d34bf 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -51,7 +51,6 @@ #include //#define DEBUG_SOLUTION_GEN -//#define DEBUG_PROJECT_GEN QT_BEGIN_NAMESPACE // Filter GUIDs (Do NOT change these!) ------------------------------ @@ -209,6 +208,7 @@ const char _slnExtSections[] = "\n\tGlobalSection(ExtensibilityGlobals) = pos VcprojGenerator::VcprojGenerator() : Win32MakefileGenerator(), init_flag(false) { } + bool VcprojGenerator::writeMakefile(QTextStream &t) { initProject(); // Fills the whole project with proper data @@ -649,12 +649,12 @@ bool VcprojGenerator::hasBuiltinCompiler(const QString &file) void VcprojGenerator::init() { - if(init_flag) + if (init_flag) return; - if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs - init_flag = true; + init_flag = true; + + if(project->first("TEMPLATE") == "vcsubdirs") //too much work for subdirs return; - } debug_msg(1, "Generator: MSVC.NET: Initializing variables"); @@ -667,6 +667,20 @@ void VcprojGenerator::init() project->values("QMAKESPEC").append(qgetenv("QMAKESPEC")); processVars(); + + project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); + project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); + + if(!project->values("VERSION").isEmpty()) { + QString version = project->values("VERSION")[0]; + int firstDot = version.indexOf("."); + QString major = version.left(firstDot); + QString minor = version.right(version.length() - firstDot - 1); + minor.replace(QRegExp("\\."), ""); + project->values("QMAKE_LFLAGS").append("/VERSION:" + major + "." + minor); + } + + MakefileGenerator::init(); initOld(); // Currently calling old DSP code to set variables. CLEAN UP! // Figure out what we're trying to build @@ -917,9 +931,10 @@ void VcprojGenerator::initCompilerTool() conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - // Common for both release and debug - if(project->isActiveConfig("windows")) - conf.compiler.PreprocessorDefinitions += project->values("MSVCPROJ_WINCONDEF"); + if (project->isActiveConfig("windows")) + conf.compiler.PreprocessorDefinitions += "_WINDOWS"; + else if (project->isActiveConfig("console")) + conf.compiler.PreprocessorDefinitions += "_CONSOLE"; conf.compiler.PreprocessorDefinitions += project->values("DEFINES"); conf.compiler.PreprocessorDefinitions += project->values("PRL_EXPORT_DEFINES"); @@ -994,7 +1009,6 @@ void VcprojGenerator::initResourceTool() conf.resource.ResourceOutputFileName = project->first("DESTDIR") + "/$(InputName).res"; } - void VcprojGenerator::initIDLTool() { } @@ -1402,72 +1416,8 @@ void VcprojGenerator::initExtraCompilerOutputs() } } -/* \internal - Sets up all needed variables from the environment and all the different caches and .conf files -*/ - void VcprojGenerator::initOld() { - if(init_flag) - return; - - init_flag = true; - QStringList::Iterator it; - - // Decode version, and add it to $$MSVCPROJ_VERSION -------------- - if(!project->values("VERSION").isEmpty()) { - QString version = project->values("VERSION")[0]; - int firstDot = version.indexOf("."); - QString major = version.left(firstDot); - QString minor = version.right(version.length() - firstDot - 1); - minor.replace(QRegExp("\\."), ""); - project->values("MSVCPROJ_VERSION").append("/VERSION:" + major + "." + minor); - project->values("QMAKE_LFLAGS").append("/VERSION:" + major + "." + minor); - } - - project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); - project->values("QMAKE_LIBS_PRIVATE") += escapeFilePaths(project->values("LIBS_PRIVATE")); - - // Get filename w/o extension ----------------------------------- - QString msvcproj_project = ""; - QString targetfilename = ""; - if(!project->isEmpty("TARGET")) { - project->values("TARGET") = unescapeFilePaths(project->values("TARGET")); - targetfilename = msvcproj_project = project->first("TARGET"); - } - - // Init base class too ------------------------------------------- - MakefileGenerator::init(); - - if(msvcproj_project.isEmpty()) - msvcproj_project = Option::output.fileName(); - - msvcproj_project = msvcproj_project.right(msvcproj_project.length() - msvcproj_project.lastIndexOf("\\") - 1); - msvcproj_project = msvcproj_project.left(msvcproj_project.lastIndexOf(".")); - msvcproj_project.replace(QRegExp("-"), ""); - - project->values("MSVCPROJ_PROJECT").append(msvcproj_project); - QStringList &proj = project->values("MSVCPROJ_PROJECT"); - - for(it = proj.begin(); it != proj.end(); ++it) - (*it).replace(QRegExp("\\.[a-zA-Z0-9_]*$"), ""); - - // SUBSYSTEM ----------------------------------------------------- - if(!project->values("QMAKE_APP_FLAG").isEmpty()) { - project->values("MSVCPROJ_TEMPLATE").append("win32app" + project->first("VCPROJ_EXTENSION")); - if(project->isActiveConfig("console")) { - project->values("MSVCPROJ_CONSOLE").append("CONSOLE"); - project->values("MSVCPROJ_WINCONDEF").append("_CONSOLE"); - project->values("MSVCPROJ_VCPROJTYPE").append("0x0103"); - project->values("MSVCPROJ_SUBSYSTEM").append("CONSOLE"); - } else { - project->values("MSVCPROJ_CONSOLE").clear(); - project->values("MSVCPROJ_WINCONDEF").append("_WINDOWS"); - project->values("MSVCPROJ_VCPROJTYPE").append("0x0101"); - project->values("MSVCPROJ_SUBSYSTEM").append("WINDOWS"); - } - } - // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS"); project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS_PRIVATE"); @@ -1550,8 +1500,6 @@ QString VcprojGenerator::replaceExtraCompilerVariables(const QString &var, const return ret; } - - bool VcprojGenerator::openOutput(QFile &file, const QString &/*build*/) const { QString outdir; @@ -1603,7 +1551,6 @@ QString VcprojGenerator::findTemplate(QString file) return ret; } - void VcprojGenerator::processPrlVariable(const QString &var, const QStringList &l) { if(var == "QMAKE_PRL_DEFINES") { @@ -1622,9 +1569,8 @@ void VcprojGenerator::outputVariables() #if 0 qDebug("Generator: MSVC.NET: List of current variables:"); for(QMap::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) - qDebug("Generator: MSVC.NET: %s => %s", it.key().toLatin1().constData(), it.data().join(" | ").toLatin1().constData()); + qDebug("Generator: MSVC.NET: %s => %s", qPrintable(it.key()), qPrintable(it.value().join(" | "))); #endif } QT_END_NAMESPACE - diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index d87c0e8..802c596 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -275,9 +275,10 @@ void VcxprojGenerator::initCompilerTool() conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - // Common for both release and debug - if(project->isActiveConfig("windows")) - conf.compiler.PreprocessorDefinitions += project->values("MSVCPROJ_WINCONDEF"); + if (project->isActiveConfig("windows")) + conf.compiler.PreprocessorDefinitions += "_WINDOWS"; + else if (project->isActiveConfig("console")) + conf.compiler.PreprocessorDefinitions += "_CONSOLE"; conf.compiler.PreprocessorDefinitions += project->values("DEFINES"); conf.compiler.PreprocessorDefinitions += project->values("PRL_EXPORT_DEFINES"); -- cgit v0.12 From 5efe3ceeb7391a6854427f6e6f7bbf4c8a5add63 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 4 Aug 2010 14:36:00 +0200 Subject: qmake: fix misuse of static_cast in msvc_vcproj.cpp Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 08d34bf..e2315c7 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -763,11 +763,16 @@ void VcprojGenerator::init() bool VcprojGenerator::mergeBuildProject(MakefileGenerator *other) { - VcprojGenerator *otherVC = static_cast(other); - if (!otherVC) { + if (!other || !other->projectFile()) { + warn_msg(WarnLogic, "VcprojGenerator: Cannot merge null project."); + return false; + } + if (other->projectFile()->first("MAKEFILE_GENERATOR") != "MSVC.NET") { warn_msg(WarnLogic, "VcprojGenerator: Cannot merge other types of projects! (ignored)"); return false; } + + VcprojGenerator *otherVC = static_cast(other); mergedProjects += otherVC; return true; } -- cgit v0.12 From da4e951653fe6e441a37fb725683654955a66418 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 4 Aug 2010 16:19:50 +0200 Subject: qmake vcproj generator: introduce VCProjectWriter XML stream operator code moved to VCProjectWriter. Rubber-stamped-by: ossi --- qmake/generators/win32/msvc_objectmodel.cpp | 747 ++++++++++++++-------------- qmake/generators/win32/msvc_objectmodel.h | 29 +- qmake/generators/win32/msvc_vcproj.cpp | 15 +- qmake/generators/win32/msvc_vcproj.h | 4 +- 4 files changed, 398 insertions(+), 397 deletions(-) diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 1e060a0..ad4ac16 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -369,82 +369,6 @@ inline XmlOutput::xml_output xformExceptionHandlingNET2005(exceptionHandling eh, return attrS(_ExceptionHandling, (eh == ehNoSEH ? "true" : "false")); } -XmlOutput &operator<<(XmlOutput &xml, const VCCLCompilerTool &tool) -{ - return xml - << tag(_Tool) - << attrS(_Name, _VCCLCompilerTool) - << attrX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories) - << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories) - << attrS(_AssemblerListingLocation, tool.AssemblerListingLocation) - << attrE(_AssemblerOutput, tool.AssemblerOutput, /*ifNot*/ asmListingNone) - << attrE(_BasicRuntimeChecks, tool.BasicRuntimeChecks, /*ifNot*/ runtimeBasicCheckNone) - << attrE(_BrowseInformation, tool.BrowseInformation, /*ifNot*/ brInfoNone) - << attrS(_BrowseInformationFile, tool.BrowseInformationFile) - << attrT(_BufferSecurityCheck, tool.BufferSecurityCheck) - << attrE(_CallingConvention, tool.CallingConvention, /*ifNot*/ callConventionDefault) - << attrE(_CompileAs, tool.CompileAs, compileAsDefault) - << attrE(_CompileAsManaged, tool.CompileAsManaged, /*ifNot*/ managedDefault) - << attrT(_CompileOnly, tool.CompileOnly) - << attrE(_DebugInformationFormat, tool.DebugInformationFormat, /*ifNot*/ debugUnknown) - << attrT(_DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned) - << attrT(_Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems) - << attrT(_DisableLanguageExtensions, tool.DisableLanguageExtensions) - << attrX(_DisableSpecificWarnings, tool.DisableSpecificWarnings) - << attrE(_EnableEnhancedInstructionSet, tool.EnableEnhancedInstructionSet, /*ifnot*/ archNotSet) - << attrT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations) - << attrT(_EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking) - << attrT(_EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions) - << xformExceptionHandlingNET2005(tool.ExceptionHandling, tool.config->CompilerVersion) - << attrT(_ExpandAttributedSource, tool.ExpandAttributedSource) - << attrE(_FavorSizeOrSpeed, tool.FavorSizeOrSpeed, /*ifNot*/ favorNone) - - << attrE(_FloatingPointModel, tool.FloatingPointModel, /*ifNot*/ floatingPointNotSet) - << attrT(_FloatingPointExceptions, tool.FloatingPointExceptions) - - << attrT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope) - << attrX(_ForcedIncludeFiles, tool.ForcedIncludeFiles) - << attrX(_ForcedUsingFiles, tool.ForcedUsingFiles) - << attrE(_GeneratePreprocessedFile, tool.GeneratePreprocessedFile, /*ifNot*/ preprocessUnknown) - << attrT(_GlobalOptimizations, tool.GlobalOptimizations) - << attrT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrT(_ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency) - << attrE(_InlineFunctionExpansion, tool.InlineFunctionExpansion, /*ifNot*/ expandDefault) - << attrT(_KeepComments, tool.KeepComments) - << attrT(_MinimalRebuild, tool.MinimalRebuild) - << attrS(_ObjectFile, tool.ObjectFile) - << attrT(_OmitFramePointers, tool.OmitFramePointers) - << attrT(_OpenMP, tool.OpenMP) - << attrE(_Optimization, tool.Optimization, /*ifNot*/ optimizeDefault) - << attrE(_OptimizeForProcessor, tool.OptimizeForProcessor, /*ifNot*/ procOptimizeBlended) - << attrT(_OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication) - << attrS(_OutputFile, tool.OutputFile) - << attrS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile) - << attrS(_PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough) - << attrX(_PreprocessorDefinitions, tool.PreprocessorDefinitions) - << (tool.ProgramDataBaseFileName.isNull() ? noxml() : attr(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName)) - << attrE(_RuntimeLibrary, tool.RuntimeLibrary, /*ifNot*/ rtUnknown) - << attrT(_RuntimeTypeInfo, tool.RuntimeTypeInfo) - << attrT(_ShowIncludes, tool.ShowIncludes) - << attrT(_SmallerTypeCheck, tool.SmallerTypeCheck) - << attrT(_StringPooling, tool.StringPooling) - << attrE(_StructMemberAlignment, tool.StructMemberAlignment, /*ifNot*/ alignNotSet) - << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType) - << attrT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) - << attrT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions) - << attrX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) - << (!tool.PrecompiledHeaderFile.isEmpty() || !tool.PrecompiledHeaderThrough.isEmpty() ? xformUsePrecompiledHeaderForNET2005(tool.UsePrecompiledHeader, tool.config->CompilerVersion) : noxml()) - << attrT(_WarnAsError, tool.WarnAsError) - << attrE(_WarningLevel, tool.WarningLevel, /*ifNot*/ warningLevelUnknown) - << attrT(_WholeProgramOptimization, tool.WholeProgramOptimization) - << attrE(_CompileForArchitecture, tool.CompileForArchitecture, /*ifNot*/ archUnknown) - << attrT(_InterworkCalls, tool.InterworkCalls) - - << closetag(_Tool); -} - bool VCCLCompilerTool::parseOption(const char* option) { // skip index 0 ('/' or '-') @@ -1149,67 +1073,6 @@ VCLinkerTool::VCLinkerTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCLinkerTool &tool) -{ - return xml - << tag(_Tool) - << attrS(_Name, _VCLinkerTool) - << attrX(_AdditionalDependencies, tool.AdditionalDependencies, " ") - << attrX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories) - << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrX(_AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly) - << attrS(_BaseAddress, tool.BaseAddress) - << attrX(_DelayLoadDLLs, tool.DelayLoadDLLs) - << attrE(_EnableCOMDATFolding, tool.EnableCOMDATFolding, /*ifNot*/ optFoldingDefault) - << attrS(_EntryPointSymbol, tool.EntryPointSymbol) - << attrX(_ForceSymbolReferences, tool.ForceSymbolReferences) - << attrS(_FunctionOrder, tool.FunctionOrder) - << attrT(_GenerateDebugInformation, tool.GenerateDebugInformation) - << attrT(_GenerateMapFile, tool.GenerateMapFile) - << attrL(_HeapCommitSize, tool.HeapCommitSize, /*ifNot*/ -1) - << attrL(_HeapReserveSize, tool.HeapReserveSize, /*ifNot*/ -1) - << attrT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) - << attrX(_IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames) - << attrT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL) - << attrT(_IgnoreImportLibrary, tool.IgnoreImportLibrary) - << attrS(_ImportLibrary, tool.ImportLibrary) - << attrE(_LargeAddressAware, tool.LargeAddressAware, /*ifNot*/ addrAwareDefault) - << attrT(_LinkDLL, tool.LinkDLL) - << attrE(_LinkIncremental, tool.LinkIncremental, /*ifNot*/ linkIncrementalDefault) - << attrE(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) - << attrS(_LinkToManagedResourceFile, tool.LinkToManagedResourceFile) - << attrT(_MapExports, tool.MapExports) - << attrS(_MapFileName, tool.MapFileName) - << attrT(_MapLines, tool.MapLines) - << attrS(_MergedIDLBaseFileName, tool.MergedIDLBaseFileName) - << attrS(_MergeSections, tool.MergeSections) - << attrS(_MidlCommandFile, tool.MidlCommandFile) - << attrS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) - << attrE(_OptimizeForWindows98, tool.OptimizeForWindows98, /*ifNot*/ optWin98Default) - << attrE(_OptimizeReferences, tool.OptimizeReferences, /*ifNot*/ optReferencesDefault) - << attrS(_OutputFile, tool.OutputFile) - << attr(_ProgramDatabaseFile, tool.ProgramDatabaseFile) - << attrT(_RegisterOutput, tool.RegisterOutput) - << attrT(_ResourceOnlyDLL, tool.ResourceOnlyDLL) - << attrT(_SetChecksum, tool.SetChecksum) - << attrE(_ShowProgress, tool.ShowProgress, /*ifNot*/ linkProgressNotSet) - << attrL(_StackCommitSize, tool.StackCommitSize, /*ifNot*/ -1) - << attrL(_StackReserveSize, tool.StackReserveSize, /*ifNot*/ -1) - << attrS(_StripPrivateSymbols, tool.StripPrivateSymbols) - << attrE(_SubSystem, tool.SubSystem) - << attrT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL) - << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrT(_SwapRunFromCD, tool.SwapRunFromCD) - << attrT(_SwapRunFromNet, tool.SwapRunFromNet) - << attrE(_TargetMachine, tool.TargetMachine, /*ifNot*/ machineNotSet) - << attrE(_TerminalServerAware, tool.TerminalServerAware, /*ifNot*/ termSvrAwareDefault) - << attrT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) - << attrS(_TypeLibraryFile, tool.TypeLibraryFile) - << attrL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ rcUseDefault) - << attrS(_Version, tool.Version) - << closetag(_Tool); -} - // Hashing routine to do fast option lookups ---- // Slightly rewritten to stop on ':' ',' and '\0' // Original routine in qtranslator.cpp ---------- @@ -1608,44 +1471,6 @@ VCMIDLTool::VCMIDLTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCMIDLTool &tool) -{ - return xml - << tag(_Tool) - << attrS(_Name, _VCMIDLTool) - << attrX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories) - << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrX(_CPreprocessOptions, tool.CPreprocessOptions) - << attrE(_DefaultCharType, tool.DefaultCharType) - << attrS(_DLLDataFileName, tool.DLLDataFileName) - << attrE(_EnableErrorChecks, tool.EnableErrorChecks) - << attrT(_ErrorCheckAllocations, tool.ErrorCheckAllocations) - << attrT(_ErrorCheckBounds, tool.ErrorCheckBounds) - << attrT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange) - << attrT(_ErrorCheckRefPointers, tool.ErrorCheckRefPointers) - << attrT(_ErrorCheckStubData, tool.ErrorCheckStubData) - << attrX(_FullIncludePath, tool.FullIncludePath) - << attrT(_GenerateStublessProxies, tool.GenerateStublessProxies) - << attrT(_GenerateTypeLibrary, tool.GenerateTypeLibrary) - << attrS(_HeaderFileName, tool.HeaderFileName) - << attrT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrS(_InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName) - << attrT(_MkTypLibCompatible, tool.MkTypLibCompatible) - << attrS(_OutputDirectory, tool.OutputDirectory) - << attrX(_PreprocessorDefinitions, tool.PreprocessorDefinitions) - << attrS(_ProxyFileName, tool.ProxyFileName) - << attrS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors) - << attrE(_StructMemberAlignment, tool.StructMemberAlignment, /*ifNot*/ midlAlignNotSet) - << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrE(_TargetEnvironment, tool.TargetEnvironment, /*ifNot*/ midlTargetNotSet) - << attrS(_TypeLibraryName, tool.TypeLibraryName) - << attrX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) - << attrT(_ValidateParameters, tool.ValidateParameters) - << attrT(_WarnAsError, tool.WarnAsError) - << attrE(_WarningLevel, tool.WarningLevel) - << closetag(_Tool); -} - bool VCMIDLTool::parseOption(const char* option) { #ifdef USE_DISPLAY_HASH @@ -1886,68 +1711,12 @@ VCLibrarianTool::VCLibrarianTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCLibrarianTool &tool) -{ - return xml - << tag(_Tool) - << attrS(_Name, _VCLibrarianTool) - << attrX(_AdditionalDependencies, tool.AdditionalDependencies) - << attrX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories) - << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrX(_ExportNamedFunctions, tool.ExportNamedFunctions) - << attrX(_ForceSymbolReferences, tool.ForceSymbolReferences) - << attrT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) - << attrX(_IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames) - << attrS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) - << attrS(_OutputFile, tool.OutputFile) - << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << closetag(_Tool); -} - // VCCustomBuildTool ------------------------------------------------ VCCustomBuildTool::VCCustomBuildTool() { ToolName = "VCCustomBuildTool"; } -XmlOutput &operator<<(XmlOutput &xml, const VCCustomBuildTool &tool) -{ - // The code below offers two ways to split custom build step commands. - // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated - // in all generators. However, if you use $$escape_expand(\n\r) (or \n\h) instead, the VCPROJ - // generator will instead of binding the commands with " && " will insert a proper newline into - // the VCPROJ file. We sometimes use this method of splitting commands if the custom buildstep - // contains a command-line which is too big to run on certain OS. - QString cmds; - int end = tool.CommandLine.count(); - for(int i = 0; i < end; ++i) { - QString cmdl = tool.CommandLine.at(i); - if (cmdl.contains("\r\t")) { - if (i == end - 1) - cmdl = cmdl.trimmed(); - cmdl.replace("\r\t", " && "); - } else if (cmdl.contains("\r\n")) { - ; - } else if (cmdl.contains("\r\\h")) { - // The above \r\n should work, but doesn't, so we have this hack - cmdl.replace("\r\\h", "\r\n"); - } else { - if (i < end - 1) - cmdl += " && "; - } - cmds += cmdl; - } - return xml - << tag(_Tool) - << attrS(_Name, tool.ToolName) - << attrX(_AdditionalDependencies, tool.AdditionalDependencies, ";") - << attrS(_CommandLine, cmds) - << attrS(_Description, tool.Description) - << attrX(_Outputs, tool.Outputs, ";") - << attrS(_Path, tool.ToolPath) - << closetag(_Tool); -} - // VCResourceCompilerTool ------------------------------------------- VCResourceCompilerTool::VCResourceCompilerTool() : Culture(rcUseDefault), @@ -1957,23 +1726,6 @@ VCResourceCompilerTool::VCResourceCompilerTool() PreprocessorDefinitions = QStringList("NDEBUG"); } -XmlOutput &operator<<(XmlOutput &xml, const VCResourceCompilerTool &tool) -{ - return xml - << tag(_Tool) - << attrS(_Name, _VCResourceCompilerTool) - << attrS(_Path, tool.ToolPath) - << attrX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories) - << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrE(_Culture, tool.Culture, /*ifNot*/ rcUseDefault) - << attrX(_FullIncludePath, tool.FullIncludePath) - << attrT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrX(_PreprocessorDefinitions, tool.PreprocessorDefinitions) - << attrS(_ResourceOutputFileName, tool.ResourceOutputFileName) - << attrE(_ShowProgress, tool.ShowProgress, /*ifNot*/ linkProgressNotSet) - << closetag(_Tool); -} - // VCDeploymentTool -------------------------------------------- VCDeploymentTool::VCDeploymentTool() : RegisterOutput(registerNo) @@ -1982,31 +1734,6 @@ VCDeploymentTool::VCDeploymentTool() RemoteDirectory = ""; } -XmlOutput &operator<<(XmlOutput &xml, const VCDeploymentTool &tool) -{ - if (tool.AdditionalFiles.isEmpty()) - return xml; - return xml - << tag(tool.DeploymentTag) - << attrS(_RemoteDirectory, tool.RemoteDirectory) - << attrE(_RegisterOutput, tool.RegisterOutput) - << attrS(_AdditionalFiles, tool.AdditionalFiles) - << closetag(tool.DeploymentTag); -} - -// VCEventTool ------------------------------------------------- -XmlOutput &operator<<(XmlOutput &xml, const VCEventTool &tool) -{ - return xml - << tag(_Tool) - << attrS(_Name, tool.ToolName) - << attrS(_Path, tool.ToolPath) - << attrS(_CommandLine, tool.CommandLine) - << attrS(_Description, tool.Description) - << attrT(_ExcludedFromBuild, tool.ExcludedFromBuild) - << closetag(_Tool); -} - // VCPostBuildEventTool --------------------------------------------- VCPostBuildEventTool::VCPostBuildEventTool() { @@ -2042,39 +1769,6 @@ VCConfiguration::VCConfiguration() idl.config = this; } -XmlOutput &operator<<(XmlOutput &xml, const VCConfiguration &tool) -{ - xml << tag(_Configuration) - << attrS(_Name, tool.Name) - << attrS(_OutputDirectory, tool.OutputDirectory) - << attrT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage) - << attrT(_BuildBrowserInformation, tool.BuildBrowserInformation) - << attrE(_CharacterSet, tool.CharacterSet, /*ifNot*/ charSetNotSet) - << attrE(_ConfigurationType, tool.ConfigurationType) - << attrS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean) - << attrS(_ImportLibrary, tool.ImportLibrary) - << attrS(_IntermediateDirectory, tool.IntermediateDirectory) - << attrS(_PrimaryOutput, tool.PrimaryOutput) - << attrS(_ProgramDatabase, tool.ProgramDatabase) - << attrT(_RegisterOutput, tool.RegisterOutput) - << attrE(_UseOfATL, tool.UseOfATL, /*ifNot*/ useATLNotSet) - << attrE(_UseOfMfc, tool.UseOfMfc) - << attrT(_WholeProgramOptimization, tool.WholeProgramOptimization) - << tool.compiler - << tool.custom; - if (tool.ConfigurationType == typeStaticLibrary) - xml << tool.librarian; - else - xml << tool.linker; - xml << tool.idl - << tool.postBuild - << tool.preBuild - << tool.preLink - << tool.resource - << tool.deployment - << closetag(_Configuration); - return xml; -} // VCFilter --------------------------------------------------------- VCFilter::VCFilter() : ParseFiles(unset), @@ -2369,38 +2063,13 @@ void VCFilter::outputFileConfig(XmlOutput &xml, const QString &filename) << attr(_Name, (*Config).Name) << (!inBuild ? attrS(_ExcludedFromBuild, "true") : noxml()); if (useCustomBuildTool) - xml << CustomBuildTool; + Project->projectWriter->write(xml, CustomBuildTool); if (useCompilerTool) - xml << CompilerTool; + Project->projectWriter->write(xml, CompilerTool); xml << closetag(_FileConfiguration); } } -XmlOutput &operator<<(XmlOutput &xml, VCFilter &tool) -{ - if(!tool.Files.count()) - return xml; - - if (!tool.Name.isEmpty()) { - xml << tag(_Filter) - << attrS(_Name, tool.Name) - << attrS(_Filter, tool.Filter) - << attrS(_UniqueIdentifier, tool.Guid) - << attrT(_ParseFiles, tool.ParseFiles); - } - for (int i = 0; i < tool.Files.count(); ++i) { - const VCFilterFile &info = tool.Files.at(i); - xml << tag(q_File) - << attrS(_RelativePath, Option::fixPathToLocalOS(info.file)) - << data(); // In case no custom builds, to avoid "/>" endings - tool.outputFileConfig(xml, tool.Files.at(i).file); - xml << closetag(q_File); - } - if (!tool.Name.isEmpty()) - xml << closetag(_Filter); - return xml; -} - // VCProjectSingleConfig -------------------------------------------- VCFilter nullFilter; VCFilter& VCProjectSingleConfig::filterForExtraCompiler(const QString &compilerName) @@ -2411,48 +2080,6 @@ VCFilter& VCProjectSingleConfig::filterForExtraCompiler(const QString &compilerN return nullFilter; } - -XmlOutput &operator<<(XmlOutput &xml, const VCProjectSingleConfig &tool) -{ - xml << decl("1.0", "Windows-1252") - << tag(_VisualStudioProject) - << attrS(_ProjectType, "Visual C++") - << attrS(_Version, tool.Version) - << attrS(_Name, tool.Name) - << attrS(_ProjectGUID, tool.ProjectGUID) - << attrS(_Keyword, tool.Keyword) - << attrS(_SccProjectName, tool.SccProjectName) - << attrS(_SccLocalPath, tool.SccLocalPath) - << tag(_Platforms) - << tag(_Platform) - << attrS(_Name, tool.PlatformName) - << closetag(_Platforms) - << tag(_Configurations) - << tool.Configuration; - xml << closetag(_Configurations) - << tag(q_Files); - // Add this configuration into a multi-config project, since that's where we have the flat/tree - // XML output functionality - VCProject tempProj; - tempProj.SingleProjects += tool; - tempProj.outputFilter(xml, "Sources"); - tempProj.outputFilter(xml, "Headers"); - tempProj.outputFilter(xml, "GeneratedFiles"); - tempProj.outputFilter(xml, "LexYaccFiles"); - tempProj.outputFilter(xml, "TranslationFiles"); - tempProj.outputFilter(xml, "FormFiles"); - tempProj.outputFilter(xml, "ResourceFiles"); - for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { - tempProj.outputFilter(xml, tempProj.ExtraCompilers.at(x)); - } - tempProj.outputFilter(xml, "RootFiles"); - xml << closetag(q_Files) - << tag(_Globals) - << data(); // No "/>" end tag - return xml; -} - - // Tree file generation --------------------------------------------- void TreeNode::generateXML(XmlOutput &xml, const QString &tagName, VCProject &tool, const QString &filter) { if (children.size()) { @@ -2599,11 +2226,50 @@ void VCProject::outputFilter(XmlOutput &xml, xml << closetag(_Filter); } -XmlOutput &operator<<(XmlOutput &xml, VCProject &tool) +void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) +{ + xml << decl("1.0", "Windows-1252") + << tag(_VisualStudioProject) + << attrS(_ProjectType, "Visual C++") + << attrS(_Version, tool.Version) + << attrS(_Name, tool.Name) + << attrS(_ProjectGUID, tool.ProjectGUID) + << attrS(_Keyword, tool.Keyword) + << attrS(_SccProjectName, tool.SccProjectName) + << attrS(_SccLocalPath, tool.SccLocalPath) + << tag(_Platforms) + << tag(_Platform) + << attrS(_Name, tool.PlatformName) + << closetag(_Platforms) + << tag(_Configurations); + write(xml, tool.Configuration); + xml << closetag(_Configurations) + << tag(q_Files); + // Add this configuration into a multi-config project, since that's where we have the flat/tree + // XML output functionality + VCProject tempProj; + tempProj.SingleProjects += tool; + tempProj.outputFilter(xml, "Sources"); + tempProj.outputFilter(xml, "Headers"); + tempProj.outputFilter(xml, "GeneratedFiles"); + tempProj.outputFilter(xml, "LexYaccFiles"); + tempProj.outputFilter(xml, "TranslationFiles"); + tempProj.outputFilter(xml, "FormFiles"); + tempProj.outputFilter(xml, "ResourceFiles"); + for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { + tempProj.outputFilter(xml, tempProj.ExtraCompilers.at(x)); + } + tempProj.outputFilter(xml, "RootFiles"); + xml << closetag(q_Files) + << tag(_Globals) + << data(); // No "/>" end tag +} + +void VCProjectWriter::write(XmlOutput &xml, VCProject &tool) { if (tool.SingleProjects.count() == 0) { warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output"); - return xml; + return; } xml << decl("1.0", "Windows-1252") @@ -2622,7 +2288,7 @@ XmlOutput &operator<<(XmlOutput &xml, VCProject &tool) << tag(_Configurations); // Output each configuration for (int i = 0; i < tool.SingleProjects.count(); ++i) - xml << tool.SingleProjects.at(i).Configuration; + write(xml, tool.SingleProjects.at(i).Configuration); xml << closetag(_Configurations) << tag(q_Files); tool.outputFilter(xml, "Sources"); @@ -2639,7 +2305,330 @@ XmlOutput &operator<<(XmlOutput &xml, VCProject &tool) xml << closetag(q_Files) << tag(_Globals) << data(); // No "/>" end tag - return xml; +} + +void VCProjectWriter::write(XmlOutput &xml, const VCCLCompilerTool &tool) +{ + xml << tag(_Tool) + << attrS(_Name, _VCCLCompilerTool) + << attrX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories) + << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories) + << attrS(_AssemblerListingLocation, tool.AssemblerListingLocation) + << attrE(_AssemblerOutput, tool.AssemblerOutput, /*ifNot*/ asmListingNone) + << attrE(_BasicRuntimeChecks, tool.BasicRuntimeChecks, /*ifNot*/ runtimeBasicCheckNone) + << attrE(_BrowseInformation, tool.BrowseInformation, /*ifNot*/ brInfoNone) + << attrS(_BrowseInformationFile, tool.BrowseInformationFile) + << attrT(_BufferSecurityCheck, tool.BufferSecurityCheck) + << attrE(_CallingConvention, tool.CallingConvention, /*ifNot*/ callConventionDefault) + << attrE(_CompileAs, tool.CompileAs, compileAsDefault) + << attrE(_CompileAsManaged, tool.CompileAsManaged, /*ifNot*/ managedDefault) + << attrT(_CompileOnly, tool.CompileOnly) + << attrE(_DebugInformationFormat, tool.DebugInformationFormat, /*ifNot*/ debugUnknown) + << attrT(_DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned) + << attrT(_Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems) + << attrT(_DisableLanguageExtensions, tool.DisableLanguageExtensions) + << attrX(_DisableSpecificWarnings, tool.DisableSpecificWarnings) + << attrE(_EnableEnhancedInstructionSet, tool.EnableEnhancedInstructionSet, /*ifnot*/ archNotSet) + << attrT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations) + << attrT(_EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking) + << attrT(_EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions) + << xformExceptionHandlingNET2005(tool.ExceptionHandling, tool.config->CompilerVersion) + << attrT(_ExpandAttributedSource, tool.ExpandAttributedSource) + << attrE(_FavorSizeOrSpeed, tool.FavorSizeOrSpeed, /*ifNot*/ favorNone) + + << attrE(_FloatingPointModel, tool.FloatingPointModel, /*ifNot*/ floatingPointNotSet) + << attrT(_FloatingPointExceptions, tool.FloatingPointExceptions) + + << attrT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope) + << attrX(_ForcedIncludeFiles, tool.ForcedIncludeFiles) + << attrX(_ForcedUsingFiles, tool.ForcedUsingFiles) + << attrE(_GeneratePreprocessedFile, tool.GeneratePreprocessedFile, /*ifNot*/ preprocessUnknown) + << attrT(_GlobalOptimizations, tool.GlobalOptimizations) + << attrT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) + << attrT(_ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency) + << attrE(_InlineFunctionExpansion, tool.InlineFunctionExpansion, /*ifNot*/ expandDefault) + << attrT(_KeepComments, tool.KeepComments) + << attrT(_MinimalRebuild, tool.MinimalRebuild) + << attrS(_ObjectFile, tool.ObjectFile) + << attrT(_OmitFramePointers, tool.OmitFramePointers) + << attrT(_OpenMP, tool.OpenMP) + << attrE(_Optimization, tool.Optimization, /*ifNot*/ optimizeDefault) + << attrE(_OptimizeForProcessor, tool.OptimizeForProcessor, /*ifNot*/ procOptimizeBlended) + << attrT(_OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication) + << attrS(_OutputFile, tool.OutputFile) + << attrS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile) + << attrS(_PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough) + << attrX(_PreprocessorDefinitions, tool.PreprocessorDefinitions) + << (tool.ProgramDataBaseFileName.isNull() ? noxml() : attr(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName)) + << attrE(_RuntimeLibrary, tool.RuntimeLibrary, /*ifNot*/ rtUnknown) + << attrT(_RuntimeTypeInfo, tool.RuntimeTypeInfo) + << attrT(_ShowIncludes, tool.ShowIncludes) + << attrT(_SmallerTypeCheck, tool.SmallerTypeCheck) + << attrT(_StringPooling, tool.StringPooling) + << attrE(_StructMemberAlignment, tool.StructMemberAlignment, /*ifNot*/ alignNotSet) + << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType) + << attrT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) + << attrT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions) + << attrX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) + << (!tool.PrecompiledHeaderFile.isEmpty() || !tool.PrecompiledHeaderThrough.isEmpty() ? xformUsePrecompiledHeaderForNET2005(tool.UsePrecompiledHeader, tool.config->CompilerVersion) : noxml()) + << attrT(_WarnAsError, tool.WarnAsError) + << attrE(_WarningLevel, tool.WarningLevel, /*ifNot*/ warningLevelUnknown) + << attrT(_WholeProgramOptimization, tool.WholeProgramOptimization) + << attrE(_CompileForArchitecture, tool.CompileForArchitecture, /*ifNot*/ archUnknown) + << attrT(_InterworkCalls, tool.InterworkCalls) + + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCLinkerTool &tool) +{ + xml << tag(_Tool) + << attrS(_Name, _VCLinkerTool) + << attrX(_AdditionalDependencies, tool.AdditionalDependencies, " ") + << attrX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories) + << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrX(_AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly) + << attrS(_BaseAddress, tool.BaseAddress) + << attrX(_DelayLoadDLLs, tool.DelayLoadDLLs) + << attrE(_EnableCOMDATFolding, tool.EnableCOMDATFolding, /*ifNot*/ optFoldingDefault) + << attrS(_EntryPointSymbol, tool.EntryPointSymbol) + << attrX(_ForceSymbolReferences, tool.ForceSymbolReferences) + << attrS(_FunctionOrder, tool.FunctionOrder) + << attrT(_GenerateDebugInformation, tool.GenerateDebugInformation) + << attrT(_GenerateMapFile, tool.GenerateMapFile) + << attrL(_HeapCommitSize, tool.HeapCommitSize, /*ifNot*/ -1) + << attrL(_HeapReserveSize, tool.HeapReserveSize, /*ifNot*/ -1) + << attrT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) + << attrX(_IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames) + << attrT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL) + << attrT(_IgnoreImportLibrary, tool.IgnoreImportLibrary) + << attrS(_ImportLibrary, tool.ImportLibrary) + << attrE(_LargeAddressAware, tool.LargeAddressAware, /*ifNot*/ addrAwareDefault) + << attrT(_LinkDLL, tool.LinkDLL) + << attrE(_LinkIncremental, tool.LinkIncremental, /*ifNot*/ linkIncrementalDefault) + << attrE(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) + << attrS(_LinkToManagedResourceFile, tool.LinkToManagedResourceFile) + << attrT(_MapExports, tool.MapExports) + << attrS(_MapFileName, tool.MapFileName) + << attrT(_MapLines, tool.MapLines) + << attrS(_MergedIDLBaseFileName, tool.MergedIDLBaseFileName) + << attrS(_MergeSections, tool.MergeSections) + << attrS(_MidlCommandFile, tool.MidlCommandFile) + << attrS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) + << attrE(_OptimizeForWindows98, tool.OptimizeForWindows98, /*ifNot*/ optWin98Default) + << attrE(_OptimizeReferences, tool.OptimizeReferences, /*ifNot*/ optReferencesDefault) + << attrS(_OutputFile, tool.OutputFile) + << attr(_ProgramDatabaseFile, tool.ProgramDatabaseFile) + << attrT(_RegisterOutput, tool.RegisterOutput) + << attrT(_ResourceOnlyDLL, tool.ResourceOnlyDLL) + << attrT(_SetChecksum, tool.SetChecksum) + << attrE(_ShowProgress, tool.ShowProgress, /*ifNot*/ linkProgressNotSet) + << attrL(_StackCommitSize, tool.StackCommitSize, /*ifNot*/ -1) + << attrL(_StackReserveSize, tool.StackReserveSize, /*ifNot*/ -1) + << attrS(_StripPrivateSymbols, tool.StripPrivateSymbols) + << attrE(_SubSystem, tool.SubSystem) + << attrT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL) + << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrT(_SwapRunFromCD, tool.SwapRunFromCD) + << attrT(_SwapRunFromNet, tool.SwapRunFromNet) + << attrE(_TargetMachine, tool.TargetMachine, /*ifNot*/ machineNotSet) + << attrE(_TerminalServerAware, tool.TerminalServerAware, /*ifNot*/ termSvrAwareDefault) + << attrT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) + << attrS(_TypeLibraryFile, tool.TypeLibraryFile) + << attrL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ rcUseDefault) + << attrS(_Version, tool.Version) + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCMIDLTool &tool) +{ + xml << tag(_Tool) + << attrS(_Name, _VCMIDLTool) + << attrX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories) + << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrX(_CPreprocessOptions, tool.CPreprocessOptions) + << attrE(_DefaultCharType, tool.DefaultCharType) + << attrS(_DLLDataFileName, tool.DLLDataFileName) + << attrE(_EnableErrorChecks, tool.EnableErrorChecks) + << attrT(_ErrorCheckAllocations, tool.ErrorCheckAllocations) + << attrT(_ErrorCheckBounds, tool.ErrorCheckBounds) + << attrT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange) + << attrT(_ErrorCheckRefPointers, tool.ErrorCheckRefPointers) + << attrT(_ErrorCheckStubData, tool.ErrorCheckStubData) + << attrX(_FullIncludePath, tool.FullIncludePath) + << attrT(_GenerateStublessProxies, tool.GenerateStublessProxies) + << attrT(_GenerateTypeLibrary, tool.GenerateTypeLibrary) + << attrS(_HeaderFileName, tool.HeaderFileName) + << attrT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) + << attrS(_InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName) + << attrT(_MkTypLibCompatible, tool.MkTypLibCompatible) + << attrS(_OutputDirectory, tool.OutputDirectory) + << attrX(_PreprocessorDefinitions, tool.PreprocessorDefinitions) + << attrS(_ProxyFileName, tool.ProxyFileName) + << attrS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors) + << attrE(_StructMemberAlignment, tool.StructMemberAlignment, /*ifNot*/ midlAlignNotSet) + << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrE(_TargetEnvironment, tool.TargetEnvironment, /*ifNot*/ midlTargetNotSet) + << attrS(_TypeLibraryName, tool.TypeLibraryName) + << attrX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) + << attrT(_ValidateParameters, tool.ValidateParameters) + << attrT(_WarnAsError, tool.WarnAsError) + << attrE(_WarningLevel, tool.WarningLevel) + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCCustomBuildTool &tool) +{ + // The code below offers two ways to split custom build step commands. + // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated + // in all generators. However, if you use $$escape_expand(\n\r) (or \n\h) instead, the VCPROJ + // generator will instead of binding the commands with " && " will insert a proper newline into + // the VCPROJ file. We sometimes use this method of splitting commands if the custom buildstep + // contains a command-line which is too big to run on certain OS. + QString cmds; + int end = tool.CommandLine.count(); + for(int i = 0; i < end; ++i) { + QString cmdl = tool.CommandLine.at(i); + if (cmdl.contains("\r\t")) { + if (i == end - 1) + cmdl = cmdl.trimmed(); + cmdl.replace("\r\t", " && "); + } else if (cmdl.contains("\r\n")) { + ; + } else if (cmdl.contains("\r\\h")) { + // The above \r\n should work, but doesn't, so we have this hack + cmdl.replace("\r\\h", "\r\n"); + } else { + if (i < end - 1) + cmdl += " && "; + } + cmds += cmdl; + } + xml << tag(_Tool) + << attrS(_Name, tool.ToolName) + << attrX(_AdditionalDependencies, tool.AdditionalDependencies, ";") + << attrS(_CommandLine, cmds) + << attrS(_Description, tool.Description) + << attrX(_Outputs, tool.Outputs, ";") + << attrS(_Path, tool.ToolPath) + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCLibrarianTool &tool) +{ + xml + << tag(_Tool) + << attrS(_Name, _VCLibrarianTool) + << attrX(_AdditionalDependencies, tool.AdditionalDependencies) + << attrX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories) + << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrX(_ExportNamedFunctions, tool.ExportNamedFunctions) + << attrX(_ForceSymbolReferences, tool.ForceSymbolReferences) + << attrT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) + << attrX(_IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames) + << attrS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) + << attrS(_OutputFile, tool.OutputFile) + << attrT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCResourceCompilerTool &tool) +{ + xml + << tag(_Tool) + << attrS(_Name, _VCResourceCompilerTool) + << attrS(_Path, tool.ToolPath) + << attrX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories) + << attrX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrE(_Culture, tool.Culture, /*ifNot*/ rcUseDefault) + << attrX(_FullIncludePath, tool.FullIncludePath) + << attrT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) + << attrX(_PreprocessorDefinitions, tool.PreprocessorDefinitions) + << attrS(_ResourceOutputFileName, tool.ResourceOutputFileName) + << attrE(_ShowProgress, tool.ShowProgress, /*ifNot*/ linkProgressNotSet) + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCEventTool &tool) +{ + xml + << tag(_Tool) + << attrS(_Name, tool.ToolName) + << attrS(_Path, tool.ToolPath) + << attrS(_CommandLine, tool.CommandLine) + << attrS(_Description, tool.Description) + << attrT(_ExcludedFromBuild, tool.ExcludedFromBuild) + << closetag(_Tool); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCDeploymentTool &tool) +{ + if (tool.AdditionalFiles.isEmpty()) + return; + xml << tag(tool.DeploymentTag) + << attrS(_RemoteDirectory, tool.RemoteDirectory) + << attrE(_RegisterOutput, tool.RegisterOutput) + << attrS(_AdditionalFiles, tool.AdditionalFiles) + << closetag(tool.DeploymentTag); +} + +void VCProjectWriter::write(XmlOutput &xml, const VCConfiguration &tool) +{ + xml << tag(_Configuration) + << attrS(_Name, tool.Name) + << attrS(_OutputDirectory, tool.OutputDirectory) + << attrT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage) + << attrT(_BuildBrowserInformation, tool.BuildBrowserInformation) + << attrE(_CharacterSet, tool.CharacterSet, /*ifNot*/ charSetNotSet) + << attrE(_ConfigurationType, tool.ConfigurationType) + << attrS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean) + << attrS(_ImportLibrary, tool.ImportLibrary) + << attrS(_IntermediateDirectory, tool.IntermediateDirectory) + << attrS(_PrimaryOutput, tool.PrimaryOutput) + << attrS(_ProgramDatabase, tool.ProgramDatabase) + << attrT(_RegisterOutput, tool.RegisterOutput) + << attrE(_UseOfATL, tool.UseOfATL, /*ifNot*/ useATLNotSet) + << attrE(_UseOfMfc, tool.UseOfMfc) + << attrT(_WholeProgramOptimization, tool.WholeProgramOptimization); + write(xml, tool.compiler); + write(xml, tool.custom); + if (tool.ConfigurationType == typeStaticLibrary) + write(xml, tool.librarian); + else + write(xml, tool.linker); + write(xml, tool.idl); + write(xml, tool.postBuild); + write(xml, tool.preBuild); + write(xml, tool.preLink); + write(xml, tool.resource); + write(xml, tool.deployment); + xml << closetag(_Configuration); +} + +void VCProjectWriter::write(XmlOutput &xml, VCFilter &tool) +{ + if(!tool.Files.count()) + return; + + if (!tool.Name.isEmpty()) { + xml << tag(_Filter) + << attrS(_Name, tool.Name) + << attrS(_Filter, tool.Filter) + << attrS(_UniqueIdentifier, tool.Guid) + << attrT(_ParseFiles, tool.ParseFiles); + } + for (int i = 0; i < tool.Files.count(); ++i) { + const VCFilterFile &info = tool.Files.at(i); + xml << tag(q_File) + << attrS(_RelativePath, Option::fixPathToLocalOS(info.file)) + << data(); // In case no custom builds, to avoid "/>" endings + tool.outputFileConfig(xml, tool.Files.at(i).file); + xml << closetag(q_File); + } + if (!tool.Name.isEmpty()) + xml << closetag(_Filter); } QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 97f8570..c7f8ed0 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -1062,18 +1062,23 @@ public: const QString &filtername); }; -XmlOutput &operator<<(XmlOutput &, const VCCLCompilerTool &); -XmlOutput &operator<<(XmlOutput &, const VCLinkerTool &); -XmlOutput &operator<<(XmlOutput &, const VCMIDLTool &); -XmlOutput &operator<<(XmlOutput &, const VCCustomBuildTool &); -XmlOutput &operator<<(XmlOutput &, const VCLibrarianTool &); -XmlOutput &operator<<(XmlOutput &, const VCResourceCompilerTool &); -XmlOutput &operator<<(XmlOutput &, const VCEventTool &); -XmlOutput &operator<<(XmlOutput &, const VCDeploymentTool &); -XmlOutput &operator<<(XmlOutput &, const VCConfiguration &); -XmlOutput &operator<<(XmlOutput &, VCFilter &); -XmlOutput &operator<<(XmlOutput &, const VCProjectSingleConfig &); -XmlOutput &operator<<(XmlOutput &, VCProject &); +class VCProjectWriter +{ +public: + virtual void write(XmlOutput &, VCProjectSingleConfig &); + virtual void write(XmlOutput &, VCProject &); + + virtual void write(XmlOutput &, const VCCLCompilerTool &); + virtual void write(XmlOutput &, const VCLinkerTool &); + virtual void write(XmlOutput &, const VCMIDLTool &); + virtual void write(XmlOutput &, const VCCustomBuildTool &); + virtual void write(XmlOutput &, const VCLibrarianTool &); + virtual void write(XmlOutput &, const VCResourceCompilerTool &); + virtual void write(XmlOutput &, const VCEventTool &); + virtual void write(XmlOutput &, const VCDeploymentTool &); + virtual void write(XmlOutput &, const VCConfiguration &); + virtual void write(XmlOutput &, VCFilter &); +}; QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index e2315c7..9e2da06 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -205,8 +205,17 @@ const char _slnExtSections[] = "\n\tGlobalSection(ExtensibilityGlobals) = pos "\n\tEndGlobalSection"; // ------------------------------------------------------------------ -VcprojGenerator::VcprojGenerator() : Win32MakefileGenerator(), init_flag(false) +VcprojGenerator::VcprojGenerator() + : Win32MakefileGenerator(), + init_flag(false), + projectWriter(0) { + projectWriter = new VCProjectWriter; +} + +VcprojGenerator::~VcprojGenerator() +{ + delete projectWriter; } bool VcprojGenerator::writeMakefile(QTextStream &t) @@ -229,7 +238,7 @@ bool VcprojGenerator::writeMakefile(QTextStream &t) if(!project->isActiveConfig("build_pass")) { debug_msg(1, "Generator: MSVC.NET: Writing single configuration project file"); XmlOutput xmlOut(t); - xmlOut << vcProject; + projectWriter->write(xmlOut, vcProject); } return true; } @@ -281,7 +290,7 @@ bool VcprojGenerator::writeProjectMakefile() mergedProject.PlatformName = mergedProjects.at(0)->vcProject.PlatformName; XmlOutput xmlOut(t); - xmlOut << mergedProject; + projectWriter->write(xmlOut, mergedProject); return true; } else if(project->first("TEMPLATE") == "vcsubdirs") { return writeMakefile(t); diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 8f028a1..436a056 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -78,6 +78,7 @@ public: QMap extraCompilerSources; QMap extraCompilerOutputs; bool usePCH; + VCProjectWriter *projectWriter; protected: virtual bool doDepends() const { return false; } //never necesary @@ -135,9 +136,6 @@ private: friend class VCFilter; }; -inline VcprojGenerator::~VcprojGenerator() -{ } - inline QString VcprojGenerator::defaultMakefile() const { return project->first("TARGET") + project->first("VCPROJ_EXTENSION"); -- cgit v0.12 From 2f53be33a1f014e40507b6bb7d547f630542d497 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Aug 2010 13:46:49 +0200 Subject: qmake vcxproj generator: introduce VCXProjectWriter Rubber-stamped-by: ossi --- qmake/generators/win32/msbuild_objectmodel.cpp | 1388 ++++++++++++------------ qmake/generators/win32/msbuild_objectmodel.h | 31 +- qmake/generators/win32/msvc_objectmodel.h | 2 + qmake/generators/win32/msvc_vcproj.cpp | 10 +- qmake/generators/win32/msvc_vcproj.h | 1 + qmake/generators/win32/msvc_vcxproj.cpp | 11 +- qmake/generators/win32/msvc_vcxproj.h | 2 + 7 files changed, 728 insertions(+), 717 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 75fc910..c2b2ee1 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -414,82 +414,6 @@ VCXCLCompilerTool::VCXCLCompilerTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCXCLCompilerTool &tool) -{ - return xml - << tag(_CLCompile) - << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") - << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrTagX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories, ";") - << attrTagS(_AlwaysAppend, tool.AlwaysAppend) - << attrTagS(_AssemblerListingLocation, tool.AssemblerListingLocation) - << attrTagS(_AssemblerOutput, tool.AssemblerOutput) - << attrTagS(_BasicRuntimeChecks, tool.BasicRuntimeChecks) - << attrTagT(_BrowseInformation, tool.BrowseInformation) - << attrTagS(_BrowseInformationFile, tool.BrowseInformationFile) - << attrTagT(_BufferSecurityCheck, tool.BufferSecurityCheck) - << attrTagS(_CallingConvention, tool.CallingConvention) - << attrTagS(_CompileAs, tool.CompileAs) - << attrTagS(_CompileAsManaged, tool.CompileAsManaged) - << attrTagT(_CreateHotpatchableImage, tool.CreateHotpatchableImage) - << attrTagS(_DebugInformationFormat, tool.DebugInformationFormat) - << attrTagT(_DisableLanguageExtensions, tool.DisableLanguageExtensions) - << attrTagX(_DisableSpecificWarnings, tool.DisableSpecificWarnings, ";") - << attrTagS(_EnableEnhancedInstructionSet, tool.EnableEnhancedInstructionSet) - << attrTagT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations) - << attrTagT(_EnablePREfast, tool.EnablePREfast) - << attrTagS(_ErrorReporting, tool.ErrorReporting) - << attrTagS(_ExceptionHandling, tool.ExceptionHandling) - << attrTagT(_ExpandAttributedSource, tool.ExpandAttributedSource) - << attrTagS(_FavorSizeOrSpeed, tool.FavorSizeOrSpeed) - << attrTagT(_FloatingPointExceptions, tool.FloatingPointExceptions) - << attrTagS(_FloatingPointModel, tool.FloatingPointModel) - << attrTagT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope) - << attrTagX(_ForcedIncludeFiles, tool.ForcedIncludeFiles, ";") - << attrTagX(_ForcedUsingFiles, tool.ForcedUsingFiles, ";") - << attrTagT(_FunctionLevelLinking, tool.FunctionLevelLinking) - << attrTagT(_GenerateXMLDocumentationFiles, tool.GenerateXMLDocumentationFiles) - << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrTagS(_InlineFunctionExpansion, tool.InlineFunctionExpansion) - << attrTagT(_IntrinsicFunctions, tool.IntrinsicFunctions) - << attrTagT(_MinimalRebuild, tool.MinimalRebuild) - << attrTagT(_MultiProcessorCompilation, tool.MultiProcessorCompilation) - << attrTagS(_ObjectFileName, tool.ObjectFileName) - << attrTagX(_ObjectFiles, tool.ObjectFiles, ";") - << attrTagT(_OmitDefaultLibName, tool.OmitDefaultLibName) - << attrTagT(_OmitFramePointers, tool.OmitFramePointers) - << attrTagT(_OpenMPSupport, tool.OpenMPSupport) - << attrTagS(_Optimization, tool.Optimization) - << attrTagS(_PrecompiledHeader, tool.PrecompiledHeader) - << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile) - << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderOutputFile) - << attrTagT(_PreprocessKeepComments, tool.PreprocessKeepComments) - << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") - << attrTagS(_PreprocessOutputPath, tool.PreprocessOutputPath) - << attrTagT(_PreprocessSuppressLineNumbers, tool.PreprocessSuppressLineNumbers) - << attrTagT(_PreprocessToFile, tool.PreprocessToFile) - << attrTagS(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName) - << attrTagS(_ProcessorNumber, tool.ProcessorNumber) - << attrTagS(_RuntimeLibrary, tool.RuntimeLibrary) - << attrTagT(_RuntimeTypeInfo, tool.RuntimeTypeInfo) - << attrTagT(_ShowIncludes, tool.ShowIncludes) - << attrTagT(_SmallerTypeCheck, tool.SmallerTypeCheck) - << attrTagT(_StringPooling, tool.StringPooling) - << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment) - << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TreatSpecificWarningsAsErrors, tool.TreatSpecificWarningsAsErrors) - << attrTagT(_TreatWarningAsError, tool.TreatWarningAsError) - << attrTagT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType) - << attrTagT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions) - << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";") - << attrTagT(_UseFullPaths, tool.UseFullPaths) - << attrTagT(_UseUnicodeForAssemblerListing, tool.UseUnicodeForAssemblerListing) - << attrTagS(_WarningLevel, tool.WarningLevel) - << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization) - << attrTagS(_XMLDocumentationFileName, tool.XMLDocumentationFileName) - << closetag(_CLCompile); -} - bool VCXCLCompilerTool::parseOption(const char* option) { // skip index 0 ('/' or '-') @@ -1099,97 +1023,6 @@ VCXLinkerTool::VCXLinkerTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCXLinkerTool &tool) -{ - return xml - << tag(_Link) - << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";") - << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";") - << attrTagX(_AdditionalManifestDependencies, tool.AdditionalManifestDependencies, ";") - << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrTagX(_AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly, ";") - << attrTagT(_AllowIsolation, tool.AllowIsolation) - << attrTagT(_AssemblyDebug, tool.AssemblyDebug) - << attrTagX(_AssemblyLinkResource, tool.AssemblyLinkResource, ";") - << attrTagS(_BaseAddress, tool.BaseAddress) - << attrTagS(_CLRImageType, tool.CLRImageType) - << attrTagS(_CLRSupportLastError, tool.CLRSupportLastError) - << attrTagS(_CLRThreadAttribute, tool.CLRThreadAttribute) - << attrTagS(_CLRUnmanagedCodeCheck, tool.CLRUnmanagedCodeCheck) - << attrTagS(_CreateHotPatchableImage, tool.CreateHotPatchableImage) - << attrTagT(_DataExecutionPrevention, tool.DataExecutionPrevention) - << attrTagX(_DelayLoadDLLs, tool.DelayLoadDLLs, ";") - << attrTagT(_DelaySign, tool.DelaySign) - << attrTagS(_Driver, tool.Driver) - << attrTagX(_EmbedManagedResourceFile, tool.EmbedManagedResourceFile, ";") - << attrTagT(_EnableCOMDATFolding, tool.EnableCOMDATFolding) - << attrTagT(_EnableUAC, tool.EnableUAC) - << attrTagS(_EntryPointSymbol, tool.EntryPointSymbol) - << attrTagT(_FixedBaseAddress, tool.FixedBaseAddress) - << attrTagS(_ForceFileOutput, tool.ForceFileOutput) - << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";") - << attrTagS(_FunctionOrder, tool.FunctionOrder) - << attrTagT(_GenerateDebugInformation, tool.GenerateDebugInformation) - << attrTagT(_GenerateManifest, tool.GenerateManifest) - << attrTagT(_GenerateMapFile, tool.GenerateMapFile) - << attrTagL(_HeapCommitSize, tool.HeapCommitSize, /*ifNot*/ -1) - << attrTagL(_HeapReserveSize, tool.HeapReserveSize, /*ifNot*/ -1) - << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) - << attrTagT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL) - << attrTagT(_IgnoreImportLibrary, tool.IgnoreImportLibrary) - << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";") - << attrTagT(_ImageHasSafeExceptionHandlers, tool.ImageHasSafeExceptionHandlers) - << attrTagS(_ImportLibrary, tool.ImportLibrary) - << attrTagS(_KeyContainer, tool.KeyContainer) - << attrTagS(_KeyFile, tool.KeyFile) - << attrTagT(_LargeAddressAware, tool.LargeAddressAware) - << attrTagT(_LinkDLL, tool.LinkDLL) - << attrTagS(_LinkErrorReporting, tool.LinkErrorReporting) - << attrTagT(_LinkIncremental, tool.LinkIncremental) - << attrTagT(_LinkStatus, tool.LinkStatus) - << attrTagS(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) - << attrTagS(_ManifestFile, tool.ManifestFile) - << attrTagT(_MapExports, tool.MapExports) - << attrTagS(_MapFileName, tool.MapFileName) - << attrTagS(_MergedIDLBaseFileName, tool.MergedIDLBaseFileName) - << attrTagS(_MergeSections, tool.MergeSections) - << attrTagS(_MidlCommandFile, tool.MidlCommandFile) - << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) - << attrTagS(_MSDOSStubFileName, tool.MSDOSStubFileName) - << attrTagT(_NoEntryPoint, tool.NoEntryPoint) - << attrTagT(_OptimizeReferences, tool.OptimizeReferences) - << attrTagS(_OutputFile, tool.OutputFile) - << attrTagT(_PreventDllBinding, tool.PreventDllBinding) - << attrTagS(_Profile, tool.Profile) - << attrTagS(_ProfileGuidedDatabase, tool.ProfileGuidedDatabase) - << attrTagS(_ProgramDatabaseFile, tool.ProgramDatabaseFile) - << attrTagT(_RandomizedBaseAddress, tool.RandomizedBaseAddress) - << attrTagT(_RegisterOutput, tool.RegisterOutput) - << attrTagL(_SectionAlignment, tool.SectionAlignment, /*ifNot*/ -1) - << attrTagT(_SetChecksum, tool.SetChecksum) - << attrTagS(_ShowProgress, tool.ShowProgress) - << attrTagS(_SpecifySectionAttributes, tool.SpecifySectionAttributes) - << attrTagS(_StackCommitSize, tool.StackCommitSize) - << attrTagS(_StackReserveSize, tool.StackReserveSize) - << attrTagS(_StripPrivateSymbols, tool.StripPrivateSymbols) - << attrTagS(_SubSystem, tool.SubSystem) - << attrTagT(_SupportNobindOfDelayLoadedDLL, tool.SupportNobindOfDelayLoadedDLL) - << attrTagT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL) - << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagT(_SwapRunFromCD, tool.SwapRunFromCD) - << attrTagT(_SwapRunFromNet, tool.SwapRunFromNet) - << attrTagS(_TargetMachine, tool.TargetMachine) - << attrTagT(_TerminalServerAware, tool.TerminalServerAware) - << attrTagT(_TreatLinkerWarningAsErrors, tool.TreatLinkerWarningAsErrors) - << attrTagT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) - << attrTagS(_TypeLibraryFile, tool.TypeLibraryFile) - << attrTagL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ 0) - << attrTagS(_UACExecutionLevel, tool.UACExecutionLevel) - << attrTagT(_UACUIAccess, tool.UACUIAccess) - << attrTagS(_Version, tool.Version) - << closetag(_Link); -} - // Hashing routine to do fast option lookups ---- // Slightly rewritten to stop on ':' ',' and '\0' // Original routine in qtranslator.cpp ---------- @@ -1790,50 +1623,6 @@ VCXMIDLTool::VCXMIDLTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCXMIDLTool &tool) -{ - return xml - << tag(_Midl) - << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") - << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrTagT(_ApplicationConfigurationMode, tool.ApplicationConfigurationMode) - << attrTagS(_ClientStubFile, tool.ClientStubFile) - << attrTagS(_CPreprocessOptions, tool.CPreprocessOptions) - << attrTagS(_DefaultCharType, tool.DefaultCharType) - << attrTagS(_DLLDataFileName, tool.DLLDataFileName) - << attrTagS(_EnableErrorChecks, tool.EnableErrorChecks) - << attrTagT(_ErrorCheckAllocations, tool.ErrorCheckAllocations) - << attrTagT(_ErrorCheckBounds, tool.ErrorCheckBounds) - << attrTagT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange) - << attrTagT(_ErrorCheckRefPointers, tool.ErrorCheckRefPointers) - << attrTagT(_ErrorCheckStubData, tool.ErrorCheckStubData) - << attrTagS(_GenerateClientFiles, tool.GenerateClientFiles) - << attrTagS(_GenerateServerFiles, tool.GenerateServerFiles) - << attrTagT(_GenerateStublessProxies, tool.GenerateStublessProxies) - << attrTagT(_GenerateTypeLibrary, tool.GenerateTypeLibrary) - << attrTagS(_HeaderFileName, tool.HeaderFileName) - << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrTagS(_InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName) - << attrTagL(_LocaleID, tool.LocaleID, /*ifNot*/ -1) - << attrTagT(_MkTypLibCompatible, tool.MkTypLibCompatible) - << attrTagS(_OutputDirectory, tool.OutputDirectory) - << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") - << attrTagS(_ProxyFileName, tool.ProxyFileName) - << attrTagS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors) - << attrTagS(_ServerStubFile, tool.ServerStubFile) - << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment) - << attrTagT(_SuppressCompilerWarnings, tool.SuppressCompilerWarnings) - << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TargetEnvironment, tool.TargetEnvironment) - << attrTagS(_TypeLibFormat, tool.TypeLibFormat) - << attrTagS(_TypeLibraryName, tool.TypeLibraryName) - << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";") - << attrTagT(_ValidateAllParameters, tool.ValidateAllParameters) - << attrTagT(_WarnAsError, tool.WarnAsError) - << attrTagS(_WarningLevel, tool.WarningLevel) - << closetag(_Midl); -} - bool VCXMIDLTool::parseOption(const char* option) { #ifdef USE_DISPLAY_HASH @@ -2106,125 +1895,22 @@ VCXLibrarianTool::VCXLibrarianTool() { } -XmlOutput &operator<<(XmlOutput &xml, const VCXLibrarianTool &tool) -{ - return xml - << tag(_Link) - << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";") - << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";") - << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrTagS(_DisplayLibrary, tool.DisplayLibrary) - << attrTagS(_ErrorReporting, tool.ErrorReporting) - << attrTagX(_ExportNamedFunctions, tool.ExportNamedFunctions, ";") - << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";") - << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) - << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";") - << attrTagT(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) - << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) - << attrTagS(_Name, tool.Name) - << attrTagS(_OutputFile, tool.OutputFile) - << attrTagX(_RemoveObjects, tool.RemoveObjects, ";") - << attrTagS(_SubSystem, tool.SubSystem) - << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TargetMachine, tool.TargetMachine) - << attrTagT(_TreatLibWarningAsErrors, tool.TreatLibWarningAsErrors) - << attrTagT(_Verbose, tool.Verbose) - << closetag(_Link); -} - // VCCustomBuildTool ------------------------------------------------ VCXCustomBuildTool::VCXCustomBuildTool() { ToolName = "VCXCustomBuildTool"; } -XmlOutput &operator<<(XmlOutput &xml, const VCXCustomBuildTool &tool) -{ - // The code below offers two ways to split custom build step commands. - // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated - // in all generators. However, if you use $$escape_expand(\n\r) (or \n\h) instead, the VCPROJ - // generator will instead of binding the commands with " && " will insert a proper newline into - // the VCPROJ file. We sometimes use this method of splitting commands if the custom buildstep - // contains a command-line which is too big to run on certain OS. - QString cmds; - int end = tool.CommandLine.count(); - for(int i = 0; i < end; ++i) { - QString cmdl = tool.CommandLine.at(i); - if (cmdl.contains("\r\t")) { - if (i == end - 1) - cmdl = cmdl.trimmed(); - cmdl.replace("\r\t", " && "); - } else if (cmdl.contains("\r\n")) { - ; - } else if (cmdl.contains("\r\\h")) { - // The above \r\n should work, but doesn't, so we have this hack - cmdl.replace("\r\\h", "\r\n"); - } else { - if (i < end - 1) - cmdl += " && "; - } - cmds += cmdl; - } - - if ( !tool.AdditionalDependencies.isEmpty() ) - { - xml << tag("AdditionalInputs") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) - << valueTagDefX(tool.AdditionalDependencies, "AdditionalInputs", ";"); - } - - if( !cmds.isEmpty() ) - { - xml << tag("Command") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) - << valueTag(cmds); - } - - if ( !tool.Description.isEmpty() ) - { - xml << tag("Message") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) - << valueTag(tool.Description); - } - - if ( !tool.Outputs.isEmpty() ) - { - xml << tag("Outputs") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) - << valueTagDefX(tool.Outputs, "Outputs", ";"); - } - - return xml; -} - -// VCResourceCompilerTool ------------------------------------------- -VCXResourceCompilerTool::VCXResourceCompilerTool() - : IgnoreStandardIncludePath(unset), - NullTerminateStrings(unset), - ShowProgress(unset), - SuppressStartupBanner(unset) +// VCResourceCompilerTool ------------------------------------------- +VCXResourceCompilerTool::VCXResourceCompilerTool() + : IgnoreStandardIncludePath(unset), + NullTerminateStrings(unset), + ShowProgress(unset), + SuppressStartupBanner(unset) { PreprocessorDefinitions = QStringList("NDEBUG"); } -XmlOutput &operator<<(XmlOutput &xml, const VCXResourceCompilerTool &tool) -{ - return xml - << tag(_ResourceCompile) - << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") - << attrTagS(_AdditionalOptions, tool.AdditionalOptions) - << attrTagS(_Culture, tool.Culture) - << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrTagT(_NullTerminateStrings, tool.NullTerminateStrings) - << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") - << attrTagS(_ResourceOutputFileName, tool.ResourceOutputFileName) - << attrTagT(_ShowProgress, tool.ShowProgress) - << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TrackerLogDirectory, tool.TrackerLogDirectory) - << attrTagS(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) - << closetag(_ResourceCompile); -} - // VCXDeploymentTool -------------------------------------------- VCXDeploymentTool::VCXDeploymentTool() { @@ -2232,26 +1918,6 @@ VCXDeploymentTool::VCXDeploymentTool() RemoteDirectory = ""; } -// http://msdn.microsoft.com/en-us/library/sa69he4t.aspx -XmlOutput &operator<<(XmlOutput &xml, const VCXDeploymentTool &tool) -{ - if (tool.AdditionalFiles.isEmpty()) - return xml; - return xml - << tag(tool.DeploymentTag) - << closetag(tool.DeploymentTag); -} - -// VCEventTool ------------------------------------------------- -XmlOutput &operator<<(XmlOutput &xml, const VCXEventTool &tool) -{ - return xml - << tag(tool.EventName) - << attrTagS(_Command, tool.CommandLine) - << attrTagS(_Message, tool.Description) - << closetag(tool.EventName); -} - // VCXPostBuildEventTool --------------------------------------------- VCXPostBuildEventTool::VCXPostBuildEventTool() { @@ -2283,28 +1949,6 @@ VCXConfiguration::VCXConfiguration() idl.config = this; } -XmlOutput &operator<<(XmlOutput &xml, const VCXConfiguration &tool) -{ - xml << tag("PropertyGroup") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Name)) - << attrTag("Label", "Configuration") - << attrTagS(_OutputDirectory, tool.OutputDirectory) - << attrTagT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage) - << attrTagT(_BuildBrowserInformation, tool.BuildBrowserInformation) - << attrTagS(_CharacterSet, tool.CharacterSet) - << attrTagS(_ConfigurationType, tool.ConfigurationType) - << attrTagS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean) - << attrTagS(_ImportLibrary, tool.ImportLibrary) - << attrTagS(_IntermediateDirectory, tool.IntermediateDirectory) - << attrTagS(_PrimaryOutput, tool.PrimaryOutput) - << attrTagS(_ProgramDatabase, tool.ProgramDatabase) - << attrTagT(_RegisterOutput, tool.RegisterOutput) - << attrTagS(_UseOfATL, tool.UseOfATL) - << attrTagS(_UseOfMfc, tool.UseOfMfc) - << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization) - << closetag(); - return xml; -} // VCXFilter --------------------------------------------------------- VCXFilter::VCXFilter() : ParseFiles(unset), @@ -2614,7 +2258,7 @@ bool VCXFilter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QSt xml << attrTagS("FileType", "Document"); } - xml << CustomBuildTool; + Project->projectWriter->write(xml, CustomBuildTool); } if ( !fileAdded && !fileAllreadyAdded ) @@ -2731,303 +2375,117 @@ VCXFilter& VCXProjectSingleConfig::filterForExtraCompiler(const QString &compile return nullVCXFilter; } +// Tree file generation --------------------------------------------- +void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &tool, const QString &filter) { -XmlOutput &operator<<(XmlOutput &xml, const VCXProjectSingleConfig &tool) -{ - xml.setIndentString(" "); + if (children.size()) { + // Filter + ChildrenMap::ConstIterator it, end = children.constEnd(); + if (!tagName.isEmpty()) { + xmlFilter << tag("Filter") + << attrTag("Include", tagName) + << attrTagS("Extensions", ""); + } + // First round, do nested filters + for (it = children.constBegin(); it != end; ++it) + if ((*it)->children.size()) + (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); + // Second round, do leafs + for (it = children.constBegin(); it != end; ++it) + if (!(*it)->children.size()) + (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); - xml << decl("1.0", "utf-8") - << tag("Project") - << attrTag("DefaultTargets","Build") - << attrTag("ToolsVersion", "4.0") - << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003") - << tag("ItemGroup") - << attrTag("Label", "ProjectConfigurations"); + if (!tagName.isEmpty()) + xml << closetag("Filter"); + } else { + // Leaf + tool.outputFileConfigs(xml, xmlFilter, info, filter); + } +} - xml << tag("ProjectConfiguration") - << attrTag("Include" , tool.Configuration.Name) - << tagValue("Configuration", tool.Configuration.ConfigurationName) - << tagValue("Platform", tool.PlatformName) - << closetag(); - xml << closetag() - << tag("PropertyGroup") - << attrTag("Label", "Globals") - << tagValue("ProjectGuid", tool.ProjectGUID) - << tagValue("RootNamespace", tool.Name) - << tagValue("Keyword", tool.Keyword) - << closetag(); +// Flat file generation --------------------------------------------- +void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCXProject &tool, const QString &filter) { + if (children.size()) { + ChildrenMapFlat::ConstIterator it = children.constBegin(); + ChildrenMapFlat::ConstIterator end = children.constEnd(); + xml << tag(_ItemGroup); + xmlFilter << tag(_ItemGroup); + for (; it != end; ++it) { + tool.outputFileConfigs(xml, xmlFilter, (*it), filter); + } + xml << closetag(); + xmlFilter << closetag(); + } +} - // config part. - xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - xml << tool.Configuration; +// VCXProject -------------------------------------------------------- +// Output all configurations (by filtername) for a file (by info) +// A filters config output is in VCXFilter.outputFileConfig() +void VCXProject::outputFileConfigs(XmlOutput &xml, + XmlOutput &xmlFilter, + const VCXFilterFile &info, + const QString &filtername) +{ + // We need to check if the file has any custom build step. + // If there is one then it has to be included with "CustomBuild Include" + bool fileAdded = false; - xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); + for (int i = 0; i < SingleProjects.count(); ++i) { + VCXFilter filter; + if (filtername == "Root Files") { + filter = SingleProjects.at(i).RootFiles; + } else if (filtername == "Source Files") { + filter = SingleProjects.at(i).SourceFiles; + } else if (filtername == "Header Files") { + filter = SingleProjects.at(i).HeaderFiles; + } else if (filtername == "Generated Files") { + filter = SingleProjects.at(i).GeneratedFiles; + } else if (filtername == "LexYacc Files") { + filter = SingleProjects.at(i).LexYaccFiles; + } else if (filtername == "Translation Files") { + filter = SingleProjects.at(i).TranslationFiles; + } else if (filtername == "Form Files") { + filter = SingleProjects.at(i).FormFiles; + } else if (filtername == "Resource Files") { + filter = SingleProjects.at(i).ResourceFiles; + } else { + // ExtraCompilers + filter = SingleProjects[i].filterForExtraCompiler(filtername); + } - // Extension settings - xml << tag("ImportGroup") - << attrTag("Label", "ExtensionSettings") - << closetag(); + if (filter.Config) // only if the filter is not empty + if (filter.outputFileConfig(xml, xmlFilter, info.file, filtername, fileAdded)) // only add it once. + fileAdded = true; + } - // PropertySheets - xml << tag("ImportGroup") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << attrTag("Label", "PropertySheets"); + if ( !fileAdded ) + { + if (filtername == "Source Files") { - xml << tag("Import") - << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props") - << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')") - << closetag() - << closetag(); + xmlFilter << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + xml << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); - // UserMacros - xml << tag("PropertyGroup") - << attrTag("Label", "UserMacros") - << closetag(); + } else if(filtername == "Header Files") { - xml << tag("PropertyGroup"); + xmlFilter << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); - if ( !tool.Configuration.OutputDirectory.isEmpty() ) { - xml<< tag("OutDir") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.OutputDirectory); - } - if ( !tool.Configuration.IntermediateDirectory.isEmpty() ) { - xml<< tag("IntDir") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.IntermediateDirectory); - } - if ( !tool.Configuration.TargetName.isEmpty() ) { - xml<< tag("TargetName") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.TargetName); - } + xml << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } else if(filtername == "Generated Files" || filtername == "Form Files") { - if ( tool.Configuration.linker.IgnoreImportLibrary != unset) { - xml<< tag("IgnoreImportLibrary") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.linker.IgnoreImportLibrary); - } + if (info.file.endsWith(".h")) { - if ( tool.Configuration.linker.LinkIncremental != unset) { - xml<< tag("LinkIncremental") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.linker.LinkIncremental); - } - - if ( tool.Configuration.preBuild.UseInBuild != unset ) - { - xml<< tag("PreBuildEventUseInBuild") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.preBuild.UseInBuild); - } - - if ( tool.Configuration.preLink.UseInBuild != unset ) - { - xml<< tag("PreLinkEventUseInBuild") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.preLink.UseInBuild); - } - - if ( tool.Configuration.postBuild.UseInBuild != unset ) - { - xml<< tag("PostBuildEventUseInBuild") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.postBuild.UseInBuild); - } - xml << closetag(); - - xml << tag("ItemDefinitionGroup") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)); - - // ClCompile - xml << tool.Configuration.compiler; - - // Link - xml << tool.Configuration.linker; - - // Midl - xml << tool.Configuration.idl; - - // ResourceCompiler - xml << tool.Configuration.resource; - - // Post build event - if ( tool.Configuration.postBuild.UseInBuild != unset ) - xml << tool.Configuration.postBuild; - - // Pre build event - if ( tool.Configuration.preBuild.UseInBuild != unset ) - xml << tool.Configuration.preBuild; - - // Pre link event - if ( tool.Configuration.preLink.UseInBuild != unset ) - xml << tool.Configuration.preLink; - - xml << closetag(); - - QFile filterFile; - filterFile.setFileName(Option::output.fileName().append(".filters")); - filterFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); - QTextStream ts(&filterFile); - XmlOutput xmlFilter(ts, XmlOutput::NoConversion); - - xmlFilter.setIndentString(" "); - - xmlFilter << decl("1.0", "utf-8") - << tag("Project") - << attrTag("ToolsVersion", "4.0") - << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); - - xmlFilter << tag("ItemGroup"); - - VCXProject tempProj; - tempProj.SingleProjects += tool; - - tempProj.addFilters(xmlFilter, "Form Files"); - tempProj.addFilters(xmlFilter, "Generated Files"); - tempProj.addFilters(xmlFilter, "Header Files"); - tempProj.addFilters(xmlFilter, "LexYacc Files"); - tempProj.addFilters(xmlFilter, "Resource Files"); - tempProj.addFilters(xmlFilter, "Source Files"); - tempProj.addFilters(xmlFilter, "Translation Files"); - xmlFilter << closetag(); - - tempProj.outputFilter(xml, xmlFilter, "Source Files"); - tempProj.outputFilter(xml, xmlFilter, "Header Files"); - tempProj.outputFilter(xml, xmlFilter, "Generated Files"); - tempProj.outputFilter(xml, xmlFilter, "LexYacc Files"); - tempProj.outputFilter(xml, xmlFilter, "Translation Files"); - tempProj.outputFilter(xml, xmlFilter, "Form Files"); - tempProj.outputFilter(xml, xmlFilter, "Resource Files"); - - for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { - tempProj.outputFilter(xml, xmlFilter, tempProj.ExtraCompilers.at(x)); - } - - xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); - - xml << tag("ImportGroup") - << attrTag("Label", "ExtensionTargets") - << closetag(); - - return xml; -} - - -// Tree file generation --------------------------------------------- -void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &tool, const QString &filter) { - - if (children.size()) { - // Filter - ChildrenMap::ConstIterator it, end = children.constEnd(); - if (!tagName.isEmpty()) { - xmlFilter << tag("Filter") - << attrTag("Include", tagName) - << attrTagS("Extensions", ""); - } - // First round, do nested filters - for (it = children.constBegin(); it != end; ++it) - if ((*it)->children.size()) - (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); - // Second round, do leafs - for (it = children.constBegin(); it != end; ++it) - if (!(*it)->children.size()) - (*it)->generateXML(xml, xmlFilter, it.key(), tool, filter); - - if (!tagName.isEmpty()) - xml << closetag("Filter"); - } else { - // Leaf - tool.outputFileConfigs(xml, xmlFilter, info, filter); - } -} - - -// Flat file generation --------------------------------------------- -void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCXProject &tool, const QString &filter) { - if (children.size()) { - ChildrenMapFlat::ConstIterator it = children.constBegin(); - ChildrenMapFlat::ConstIterator end = children.constEnd(); - xml << tag(_ItemGroup); - xmlFilter << tag(_ItemGroup); - for (; it != end; ++it) { - tool.outputFileConfigs(xml, xmlFilter, (*it), filter); - } - xml << closetag(); - xmlFilter << closetag(); - } -} - - -// VCXProject -------------------------------------------------------- -// Output all configurations (by filtername) for a file (by info) -// A filters config output is in VCXFilter.outputFileConfig() -void VCXProject::outputFileConfigs(XmlOutput &xml, - XmlOutput &xmlFilter, - const VCXFilterFile &info, - const QString &filtername) -{ - // We need to check if the file has any custom build step. - // If there is one then it has to be included with "CustomBuild Include" - bool fileAdded = false; - - for (int i = 0; i < SingleProjects.count(); ++i) { - VCXFilter filter; - if (filtername == "Root Files") { - filter = SingleProjects.at(i).RootFiles; - } else if (filtername == "Source Files") { - filter = SingleProjects.at(i).SourceFiles; - } else if (filtername == "Header Files") { - filter = SingleProjects.at(i).HeaderFiles; - } else if (filtername == "Generated Files") { - filter = SingleProjects.at(i).GeneratedFiles; - } else if (filtername == "LexYacc Files") { - filter = SingleProjects.at(i).LexYaccFiles; - } else if (filtername == "Translation Files") { - filter = SingleProjects.at(i).TranslationFiles; - } else if (filtername == "Form Files") { - filter = SingleProjects.at(i).FormFiles; - } else if (filtername == "Resource Files") { - filter = SingleProjects.at(i).ResourceFiles; - } else { - // ExtraCompilers - filter = SingleProjects[i].filterForExtraCompiler(filtername); - } - - if (filter.Config) // only if the filter is not empty - if (filter.outputFileConfig(xml, xmlFilter, info.file, filtername, fileAdded)) // only add it once. - fileAdded = true; - } - - if ( !fileAdded ) - { - if (filtername == "Source Files") { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - - } else if(filtername == "Header Files") { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(filtername == "Generated Files" || filtername == "Form Files") { - - if (info.file.endsWith(".h")) { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); + xmlFilter << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); xml << tag("ClInclude") << attrTag("Include",Option::fixPathToLocalOS(info.file)); @@ -3179,15 +2637,8 @@ void VCXProject::addFilters(XmlOutput &xmlFilter, } } - -XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) +void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) { - - if (tool.SingleProjects.count() == 0) { - warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output"); - return xml; - } - xml.setIndentString(" "); xml << decl("1.0", "utf-8") @@ -3198,13 +2649,11 @@ XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) << tag("ItemGroup") << attrTag("Label", "ProjectConfigurations"); - for (int i = 0; i < tool.SingleProjects.count(); ++i) { - xml << tag("ProjectConfiguration") - << attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name) - << tagValue("Configuration", tool.SingleProjects.at(i).Configuration.ConfigurationName) - << tagValue("Platform", tool.SingleProjects.at(i).PlatformName) - << closetag(); - } + xml << tag("ProjectConfiguration") + << attrTag("Include" , tool.Configuration.Name) + << tagValue("Configuration", tool.Configuration.ConfigurationName) + << tagValue("Platform", tool.PlatformName) + << closetag(); xml << closetag() << tag("PropertyGroup") @@ -3216,8 +2665,9 @@ XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) // config part. xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - for (int i = 0; i < tool.SingleProjects.count(); ++i) - xml << tool.SingleProjects.at(i).Configuration; + + write(xml, tool.Configuration); + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); // Extension settings @@ -3226,17 +2676,16 @@ XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) << closetag(); // PropertySheets - for (int i = 0; i < tool.SingleProjects.count(); ++i) { - xml << tag("ImportGroup") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << attrTag("Label", "PropertySheets"); + xml << tag("ImportGroup") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << attrTag("Label", "PropertySheets"); + + xml << tag("Import") + << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props") + << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')") + << closetag() + << closetag(); - xml << tag("Import") - << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props") - << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')") - << closetag() - << closetag(); - } // UserMacros xml << tag("PropertyGroup") @@ -3244,26 +2693,215 @@ XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) << closetag(); xml << tag("PropertyGroup"); - for (int i = 0; i < tool.SingleProjects.count(); ++i) { - - if ( !tool.SingleProjects.at(i).Configuration.OutputDirectory.isEmpty() ) { - xml << tag("OutDir") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTag(tool.SingleProjects.at(i).Configuration.OutputDirectory); - } - if ( !tool.SingleProjects.at(i).Configuration.IntermediateDirectory.isEmpty() ) { - xml << tag("IntDir") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTag(tool.SingleProjects.at(i).Configuration.IntermediateDirectory); - } - if ( !tool.SingleProjects.at(i).Configuration.TargetName.isEmpty() ) { - xml << tag("TargetName") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTag(tool.SingleProjects.at(i).Configuration.TargetName); - } - if ( tool.SingleProjects.at(i).Configuration.linker.IgnoreImportLibrary != unset) { - xml << tag("IgnoreImportLibrary") + if ( !tool.Configuration.OutputDirectory.isEmpty() ) { + xml<< tag("OutDir") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTag(tool.Configuration.OutputDirectory); + } + if ( !tool.Configuration.IntermediateDirectory.isEmpty() ) { + xml<< tag("IntDir") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTag(tool.Configuration.IntermediateDirectory); + } + if ( !tool.Configuration.TargetName.isEmpty() ) { + xml<< tag("TargetName") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTag(tool.Configuration.TargetName); + } + + if ( tool.Configuration.linker.IgnoreImportLibrary != unset) { + xml<< tag("IgnoreImportLibrary") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTagT(tool.Configuration.linker.IgnoreImportLibrary); + } + + if ( tool.Configuration.linker.LinkIncremental != unset) { + xml<< tag("LinkIncremental") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTagT(tool.Configuration.linker.LinkIncremental); + } + + if ( tool.Configuration.preBuild.UseInBuild != unset ) + { + xml<< tag("PreBuildEventUseInBuild") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTagT(tool.Configuration.preBuild.UseInBuild); + } + + if ( tool.Configuration.preLink.UseInBuild != unset ) + { + xml<< tag("PreLinkEventUseInBuild") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTagT(tool.Configuration.preLink.UseInBuild); + } + + if ( tool.Configuration.postBuild.UseInBuild != unset ) + { + xml<< tag("PostBuildEventUseInBuild") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTagT(tool.Configuration.postBuild.UseInBuild); + } + xml << closetag(); + + xml << tag("ItemDefinitionGroup") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)); + + // ClCompile + write(xml, tool.Configuration.compiler); + + // Link + write(xml, tool.Configuration.linker); + + // Midl + write(xml, tool.Configuration.idl); + + // ResourceCompiler + write(xml, tool.Configuration.resource); + + // Post build event + if ( tool.Configuration.postBuild.UseInBuild != unset ) + write(xml, tool.Configuration.postBuild); + + // Pre build event + if ( tool.Configuration.preBuild.UseInBuild != unset ) + write(xml, tool.Configuration.preBuild); + + // Pre link event + if ( tool.Configuration.preLink.UseInBuild != unset ) + write(xml, tool.Configuration.preLink); + + xml << closetag(); + + QFile filterFile; + filterFile.setFileName(Option::output.fileName().append(".filters")); + filterFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); + QTextStream ts(&filterFile); + XmlOutput xmlFilter(ts, XmlOutput::NoConversion); + + xmlFilter.setIndentString(" "); + + xmlFilter << decl("1.0", "utf-8") + << tag("Project") + << attrTag("ToolsVersion", "4.0") + << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); + + xmlFilter << tag("ItemGroup"); + + VCXProject tempProj; + tempProj.SingleProjects += tool; + + tempProj.addFilters(xmlFilter, "Form Files"); + tempProj.addFilters(xmlFilter, "Generated Files"); + tempProj.addFilters(xmlFilter, "Header Files"); + tempProj.addFilters(xmlFilter, "LexYacc Files"); + tempProj.addFilters(xmlFilter, "Resource Files"); + tempProj.addFilters(xmlFilter, "Source Files"); + tempProj.addFilters(xmlFilter, "Translation Files"); + xmlFilter << closetag(); + + tempProj.outputFilter(xml, xmlFilter, "Source Files"); + tempProj.outputFilter(xml, xmlFilter, "Header Files"); + tempProj.outputFilter(xml, xmlFilter, "Generated Files"); + tempProj.outputFilter(xml, xmlFilter, "LexYacc Files"); + tempProj.outputFilter(xml, xmlFilter, "Translation Files"); + tempProj.outputFilter(xml, xmlFilter, "Form Files"); + tempProj.outputFilter(xml, xmlFilter, "Resource Files"); + + for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { + tempProj.outputFilter(xml, xmlFilter, tempProj.ExtraCompilers.at(x)); + } + + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); + + xml << tag("ImportGroup") + << attrTag("Label", "ExtensionTargets") + << closetag(); +} + +void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) +{ + if (tool.SingleProjects.count() == 0) { + warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output"); + return; + } + + xml.setIndentString(" "); + + xml << decl("1.0", "utf-8") + << tag("Project") + << attrTag("DefaultTargets","Build") + << attrTag("ToolsVersion", "4.0") + << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003") + << tag("ItemGroup") + << attrTag("Label", "ProjectConfigurations"); + + for (int i = 0; i < tool.SingleProjects.count(); ++i) { + xml << tag("ProjectConfiguration") + << attrTag("Include" , tool.SingleProjects.at(i).Configuration.Name) + << tagValue("Configuration", tool.SingleProjects.at(i).Configuration.ConfigurationName) + << tagValue("Platform", tool.SingleProjects.at(i).PlatformName) + << closetag(); + } + + xml << closetag() + << tag("PropertyGroup") + << attrTag("Label", "Globals") + << tagValue("ProjectGuid", tool.ProjectGUID) + << tagValue("RootNamespace", tool.Name) + << tagValue("Keyword", tool.Keyword) + << closetag(); + + // config part. + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); + for (int i = 0; i < tool.SingleProjects.count(); ++i) + write(xml, tool.SingleProjects.at(i).Configuration); + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); + + // Extension settings + xml << tag("ImportGroup") + << attrTag("Label", "ExtensionSettings") + << closetag(); + + // PropertySheets + for (int i = 0; i < tool.SingleProjects.count(); ++i) { + xml << tag("ImportGroup") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) + << attrTag("Label", "PropertySheets"); + + xml << tag("Import") + << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props") + << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')") + << closetag() + << closetag(); + } + + // UserMacros + xml << tag("PropertyGroup") + << attrTag("Label", "UserMacros") + << closetag(); + + xml << tag("PropertyGroup"); + for (int i = 0; i < tool.SingleProjects.count(); ++i) { + + if ( !tool.SingleProjects.at(i).Configuration.OutputDirectory.isEmpty() ) { + xml << tag("OutDir") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) + << valueTag(tool.SingleProjects.at(i).Configuration.OutputDirectory); + } + if ( !tool.SingleProjects.at(i).Configuration.IntermediateDirectory.isEmpty() ) { + xml << tag("IntDir") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) + << valueTag(tool.SingleProjects.at(i).Configuration.IntermediateDirectory); + } + if ( !tool.SingleProjects.at(i).Configuration.TargetName.isEmpty() ) { + xml << tag("TargetName") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) + << valueTag(tool.SingleProjects.at(i).Configuration.TargetName); + } + + if ( tool.SingleProjects.at(i).Configuration.linker.IgnoreImportLibrary != unset) { + xml << tag("IgnoreImportLibrary") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) << valueTagT(tool.SingleProjects.at(i).Configuration.linker.IgnoreImportLibrary); } @@ -3302,28 +2940,28 @@ XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)); // ClCompile - xml << tool.SingleProjects.at(i).Configuration.compiler; + write(xml, tool.SingleProjects.at(i).Configuration.compiler); // Link - xml << tool.SingleProjects.at(i).Configuration.linker; + write(xml, tool.SingleProjects.at(i).Configuration.linker); // Midl - xml << tool.SingleProjects.at(i).Configuration.idl; + write(xml, tool.SingleProjects.at(i).Configuration.idl); // ResourceCompiler - xml << tool.SingleProjects.at(i).Configuration.resource; + write(xml, tool.SingleProjects.at(i).Configuration.resource); // Post build event if ( tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild != unset ) - xml << tool.SingleProjects.at(i).Configuration.postBuild; - + write(xml, tool.SingleProjects.at(i).Configuration.postBuild); + // Pre build event if ( tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild != unset ) - xml << tool.SingleProjects.at(i).Configuration.preBuild; + write(xml, tool.SingleProjects.at(i).Configuration.preBuild); // Pre link event if ( tool.SingleProjects.at(i).Configuration.preLink.UseInBuild != unset ) - xml << tool.SingleProjects.at(i).Configuration.preLink; + write(xml, tool.SingleProjects.at(i).Configuration.preLink); xml << closetag(); } @@ -3370,8 +3008,360 @@ XmlOutput &operator<<(XmlOutput &xml, VCXProject &tool) xml << tag("ImportGroup") << attrTag("Label", "ExtensionTargets") << closetag(); +} - return xml; +void VCXProjectWriter::write(XmlOutput &xml, const VCXCLCompilerTool &tool) +{ + xml + << tag(_CLCompile) + << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") + << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrTagX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories, ";") + << attrTagS(_AlwaysAppend, tool.AlwaysAppend) + << attrTagS(_AssemblerListingLocation, tool.AssemblerListingLocation) + << attrTagS(_AssemblerOutput, tool.AssemblerOutput) + << attrTagS(_BasicRuntimeChecks, tool.BasicRuntimeChecks) + << attrTagT(_BrowseInformation, tool.BrowseInformation) + << attrTagS(_BrowseInformationFile, tool.BrowseInformationFile) + << attrTagT(_BufferSecurityCheck, tool.BufferSecurityCheck) + << attrTagS(_CallingConvention, tool.CallingConvention) + << attrTagS(_CompileAs, tool.CompileAs) + << attrTagS(_CompileAsManaged, tool.CompileAsManaged) + << attrTagT(_CreateHotpatchableImage, tool.CreateHotpatchableImage) + << attrTagS(_DebugInformationFormat, tool.DebugInformationFormat) + << attrTagT(_DisableLanguageExtensions, tool.DisableLanguageExtensions) + << attrTagX(_DisableSpecificWarnings, tool.DisableSpecificWarnings, ";") + << attrTagS(_EnableEnhancedInstructionSet, tool.EnableEnhancedInstructionSet) + << attrTagT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations) + << attrTagT(_EnablePREfast, tool.EnablePREfast) + << attrTagS(_ErrorReporting, tool.ErrorReporting) + << attrTagS(_ExceptionHandling, tool.ExceptionHandling) + << attrTagT(_ExpandAttributedSource, tool.ExpandAttributedSource) + << attrTagS(_FavorSizeOrSpeed, tool.FavorSizeOrSpeed) + << attrTagT(_FloatingPointExceptions, tool.FloatingPointExceptions) + << attrTagS(_FloatingPointModel, tool.FloatingPointModel) + << attrTagT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope) + << attrTagX(_ForcedIncludeFiles, tool.ForcedIncludeFiles, ";") + << attrTagX(_ForcedUsingFiles, tool.ForcedUsingFiles, ";") + << attrTagT(_FunctionLevelLinking, tool.FunctionLevelLinking) + << attrTagT(_GenerateXMLDocumentationFiles, tool.GenerateXMLDocumentationFiles) + << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) + << attrTagS(_InlineFunctionExpansion, tool.InlineFunctionExpansion) + << attrTagT(_IntrinsicFunctions, tool.IntrinsicFunctions) + << attrTagT(_MinimalRebuild, tool.MinimalRebuild) + << attrTagT(_MultiProcessorCompilation, tool.MultiProcessorCompilation) + << attrTagS(_ObjectFileName, tool.ObjectFileName) + << attrTagX(_ObjectFiles, tool.ObjectFiles, ";") + << attrTagT(_OmitDefaultLibName, tool.OmitDefaultLibName) + << attrTagT(_OmitFramePointers, tool.OmitFramePointers) + << attrTagT(_OpenMPSupport, tool.OpenMPSupport) + << attrTagS(_Optimization, tool.Optimization) + << attrTagS(_PrecompiledHeader, tool.PrecompiledHeader) + << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile) + << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderOutputFile) + << attrTagT(_PreprocessKeepComments, tool.PreprocessKeepComments) + << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") + << attrTagS(_PreprocessOutputPath, tool.PreprocessOutputPath) + << attrTagT(_PreprocessSuppressLineNumbers, tool.PreprocessSuppressLineNumbers) + << attrTagT(_PreprocessToFile, tool.PreprocessToFile) + << attrTagS(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName) + << attrTagS(_ProcessorNumber, tool.ProcessorNumber) + << attrTagS(_RuntimeLibrary, tool.RuntimeLibrary) + << attrTagT(_RuntimeTypeInfo, tool.RuntimeTypeInfo) + << attrTagT(_ShowIncludes, tool.ShowIncludes) + << attrTagT(_SmallerTypeCheck, tool.SmallerTypeCheck) + << attrTagT(_StringPooling, tool.StringPooling) + << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment) + << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrTagS(_TreatSpecificWarningsAsErrors, tool.TreatSpecificWarningsAsErrors) + << attrTagT(_TreatWarningAsError, tool.TreatWarningAsError) + << attrTagT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType) + << attrTagT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions) + << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";") + << attrTagT(_UseFullPaths, tool.UseFullPaths) + << attrTagT(_UseUnicodeForAssemblerListing, tool.UseUnicodeForAssemblerListing) + << attrTagS(_WarningLevel, tool.WarningLevel) + << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization) + << attrTagS(_XMLDocumentationFileName, tool.XMLDocumentationFileName) + << closetag(_CLCompile); +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXLinkerTool &tool) +{ + xml + << tag(_Link) + << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";") + << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";") + << attrTagX(_AdditionalManifestDependencies, tool.AdditionalManifestDependencies, ";") + << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrTagX(_AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly, ";") + << attrTagT(_AllowIsolation, tool.AllowIsolation) + << attrTagT(_AssemblyDebug, tool.AssemblyDebug) + << attrTagX(_AssemblyLinkResource, tool.AssemblyLinkResource, ";") + << attrTagS(_BaseAddress, tool.BaseAddress) + << attrTagS(_CLRImageType, tool.CLRImageType) + << attrTagS(_CLRSupportLastError, tool.CLRSupportLastError) + << attrTagS(_CLRThreadAttribute, tool.CLRThreadAttribute) + << attrTagS(_CLRUnmanagedCodeCheck, tool.CLRUnmanagedCodeCheck) + << attrTagS(_CreateHotPatchableImage, tool.CreateHotPatchableImage) + << attrTagT(_DataExecutionPrevention, tool.DataExecutionPrevention) + << attrTagX(_DelayLoadDLLs, tool.DelayLoadDLLs, ";") + << attrTagT(_DelaySign, tool.DelaySign) + << attrTagS(_Driver, tool.Driver) + << attrTagX(_EmbedManagedResourceFile, tool.EmbedManagedResourceFile, ";") + << attrTagT(_EnableCOMDATFolding, tool.EnableCOMDATFolding) + << attrTagT(_EnableUAC, tool.EnableUAC) + << attrTagS(_EntryPointSymbol, tool.EntryPointSymbol) + << attrTagT(_FixedBaseAddress, tool.FixedBaseAddress) + << attrTagS(_ForceFileOutput, tool.ForceFileOutput) + << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";") + << attrTagS(_FunctionOrder, tool.FunctionOrder) + << attrTagT(_GenerateDebugInformation, tool.GenerateDebugInformation) + << attrTagT(_GenerateManifest, tool.GenerateManifest) + << attrTagT(_GenerateMapFile, tool.GenerateMapFile) + << attrTagL(_HeapCommitSize, tool.HeapCommitSize, /*ifNot*/ -1) + << attrTagL(_HeapReserveSize, tool.HeapReserveSize, /*ifNot*/ -1) + << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) + << attrTagT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL) + << attrTagT(_IgnoreImportLibrary, tool.IgnoreImportLibrary) + << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";") + << attrTagT(_ImageHasSafeExceptionHandlers, tool.ImageHasSafeExceptionHandlers) + << attrTagS(_ImportLibrary, tool.ImportLibrary) + << attrTagS(_KeyContainer, tool.KeyContainer) + << attrTagS(_KeyFile, tool.KeyFile) + << attrTagT(_LargeAddressAware, tool.LargeAddressAware) + << attrTagT(_LinkDLL, tool.LinkDLL) + << attrTagS(_LinkErrorReporting, tool.LinkErrorReporting) + << attrTagT(_LinkIncremental, tool.LinkIncremental) + << attrTagT(_LinkStatus, tool.LinkStatus) + << attrTagS(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) + << attrTagS(_ManifestFile, tool.ManifestFile) + << attrTagT(_MapExports, tool.MapExports) + << attrTagS(_MapFileName, tool.MapFileName) + << attrTagS(_MergedIDLBaseFileName, tool.MergedIDLBaseFileName) + << attrTagS(_MergeSections, tool.MergeSections) + << attrTagS(_MidlCommandFile, tool.MidlCommandFile) + << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) + << attrTagS(_MSDOSStubFileName, tool.MSDOSStubFileName) + << attrTagT(_NoEntryPoint, tool.NoEntryPoint) + << attrTagT(_OptimizeReferences, tool.OptimizeReferences) + << attrTagS(_OutputFile, tool.OutputFile) + << attrTagT(_PreventDllBinding, tool.PreventDllBinding) + << attrTagS(_Profile, tool.Profile) + << attrTagS(_ProfileGuidedDatabase, tool.ProfileGuidedDatabase) + << attrTagS(_ProgramDatabaseFile, tool.ProgramDatabaseFile) + << attrTagT(_RandomizedBaseAddress, tool.RandomizedBaseAddress) + << attrTagT(_RegisterOutput, tool.RegisterOutput) + << attrTagL(_SectionAlignment, tool.SectionAlignment, /*ifNot*/ -1) + << attrTagT(_SetChecksum, tool.SetChecksum) + << attrTagS(_ShowProgress, tool.ShowProgress) + << attrTagS(_SpecifySectionAttributes, tool.SpecifySectionAttributes) + << attrTagS(_StackCommitSize, tool.StackCommitSize) + << attrTagS(_StackReserveSize, tool.StackReserveSize) + << attrTagS(_StripPrivateSymbols, tool.StripPrivateSymbols) + << attrTagS(_SubSystem, tool.SubSystem) + << attrTagT(_SupportNobindOfDelayLoadedDLL, tool.SupportNobindOfDelayLoadedDLL) + << attrTagT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL) + << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrTagT(_SwapRunFromCD, tool.SwapRunFromCD) + << attrTagT(_SwapRunFromNet, tool.SwapRunFromNet) + << attrTagS(_TargetMachine, tool.TargetMachine) + << attrTagT(_TerminalServerAware, tool.TerminalServerAware) + << attrTagT(_TreatLinkerWarningAsErrors, tool.TreatLinkerWarningAsErrors) + << attrTagT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) + << attrTagS(_TypeLibraryFile, tool.TypeLibraryFile) + << attrTagL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ 0) + << attrTagS(_UACExecutionLevel, tool.UACExecutionLevel) + << attrTagT(_UACUIAccess, tool.UACUIAccess) + << attrTagS(_Version, tool.Version) + << closetag(_Link); +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXMIDLTool &tool) +{ + xml + << tag(_Midl) + << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") + << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrTagT(_ApplicationConfigurationMode, tool.ApplicationConfigurationMode) + << attrTagS(_ClientStubFile, tool.ClientStubFile) + << attrTagS(_CPreprocessOptions, tool.CPreprocessOptions) + << attrTagS(_DefaultCharType, tool.DefaultCharType) + << attrTagS(_DLLDataFileName, tool.DLLDataFileName) + << attrTagS(_EnableErrorChecks, tool.EnableErrorChecks) + << attrTagT(_ErrorCheckAllocations, tool.ErrorCheckAllocations) + << attrTagT(_ErrorCheckBounds, tool.ErrorCheckBounds) + << attrTagT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange) + << attrTagT(_ErrorCheckRefPointers, tool.ErrorCheckRefPointers) + << attrTagT(_ErrorCheckStubData, tool.ErrorCheckStubData) + << attrTagS(_GenerateClientFiles, tool.GenerateClientFiles) + << attrTagS(_GenerateServerFiles, tool.GenerateServerFiles) + << attrTagT(_GenerateStublessProxies, tool.GenerateStublessProxies) + << attrTagT(_GenerateTypeLibrary, tool.GenerateTypeLibrary) + << attrTagS(_HeaderFileName, tool.HeaderFileName) + << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) + << attrTagS(_InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName) + << attrTagL(_LocaleID, tool.LocaleID, /*ifNot*/ -1) + << attrTagT(_MkTypLibCompatible, tool.MkTypLibCompatible) + << attrTagS(_OutputDirectory, tool.OutputDirectory) + << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") + << attrTagS(_ProxyFileName, tool.ProxyFileName) + << attrTagS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors) + << attrTagS(_ServerStubFile, tool.ServerStubFile) + << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment) + << attrTagT(_SuppressCompilerWarnings, tool.SuppressCompilerWarnings) + << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrTagS(_TargetEnvironment, tool.TargetEnvironment) + << attrTagS(_TypeLibFormat, tool.TypeLibFormat) + << attrTagS(_TypeLibraryName, tool.TypeLibraryName) + << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";") + << attrTagT(_ValidateAllParameters, tool.ValidateAllParameters) + << attrTagT(_WarnAsError, tool.WarnAsError) + << attrTagS(_WarningLevel, tool.WarningLevel) + << closetag(_Midl); +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXCustomBuildTool &tool) +{ + // The code below offers two ways to split custom build step commands. + // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated + // in all generators. However, if you use $$escape_expand(\n\r) (or \n\h) instead, the VCPROJ + // generator will instead of binding the commands with " && " will insert a proper newline into + // the VCPROJ file. We sometimes use this method of splitting commands if the custom buildstep + // contains a command-line which is too big to run on certain OS. + QString cmds; + int end = tool.CommandLine.count(); + for(int i = 0; i < end; ++i) { + QString cmdl = tool.CommandLine.at(i); + if (cmdl.contains("\r\t")) { + if (i == end - 1) + cmdl = cmdl.trimmed(); + cmdl.replace("\r\t", " && "); + } else if (cmdl.contains("\r\n")) { + ; + } else if (cmdl.contains("\r\\h")) { + // The above \r\n should work, but doesn't, so we have this hack + cmdl.replace("\r\\h", "\r\n"); + } else { + if (i < end - 1) + cmdl += " && "; + } + cmds += cmdl; + } + + if ( !tool.AdditionalDependencies.isEmpty() ) + { + xml << tag("AdditionalInputs") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << valueTagDefX(tool.AdditionalDependencies, "AdditionalInputs", ";"); + } + + if( !cmds.isEmpty() ) + { + xml << tag("Command") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << valueTag(cmds); + } + + if ( !tool.Description.isEmpty() ) + { + xml << tag("Message") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << valueTag(tool.Description); + } + + if ( !tool.Outputs.isEmpty() ) + { + xml << tag("Outputs") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << valueTagDefX(tool.Outputs, "Outputs", ";"); + } +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXLibrarianTool &tool) +{ + xml + << tag(_Link) + << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";") + << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";") + << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrTagS(_DisplayLibrary, tool.DisplayLibrary) + << attrTagS(_ErrorReporting, tool.ErrorReporting) + << attrTagX(_ExportNamedFunctions, tool.ExportNamedFunctions, ";") + << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";") + << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) + << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";") + << attrTagT(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) + << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) + << attrTagS(_Name, tool.Name) + << attrTagS(_OutputFile, tool.OutputFile) + << attrTagX(_RemoveObjects, tool.RemoveObjects, ";") + << attrTagS(_SubSystem, tool.SubSystem) + << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrTagS(_TargetMachine, tool.TargetMachine) + << attrTagT(_TreatLibWarningAsErrors, tool.TreatLibWarningAsErrors) + << attrTagT(_Verbose, tool.Verbose) + << closetag(_Link); +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXResourceCompilerTool &tool) +{ + xml + << tag(_ResourceCompile) + << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") + << attrTagS(_AdditionalOptions, tool.AdditionalOptions) + << attrTagS(_Culture, tool.Culture) + << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) + << attrTagT(_NullTerminateStrings, tool.NullTerminateStrings) + << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") + << attrTagS(_ResourceOutputFileName, tool.ResourceOutputFileName) + << attrTagT(_ShowProgress, tool.ShowProgress) + << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) + << attrTagS(_TrackerLogDirectory, tool.TrackerLogDirectory) + << attrTagS(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) + << closetag(_ResourceCompile); +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXEventTool &tool) +{ + xml + << tag(tool.EventName) + << attrTagS(_Command, tool.CommandLine) + << attrTagS(_Message, tool.Description) + << closetag(tool.EventName); +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCDeploymentTool &tool) +{ + Q_UNUSED(xml); + Q_UNUSED(tool); + // SmartDevice deployment not supported in VS 2010 +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCXConfiguration &tool) +{ + xml << tag("PropertyGroup") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Name)) + << attrTag("Label", "Configuration") + << attrTagS(_OutputDirectory, tool.OutputDirectory) + << attrTagT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage) + << attrTagT(_BuildBrowserInformation, tool.BuildBrowserInformation) + << attrTagS(_CharacterSet, tool.CharacterSet) + << attrTagS(_ConfigurationType, tool.ConfigurationType) + << attrTagS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean) + << attrTagS(_ImportLibrary, tool.ImportLibrary) + << attrTagS(_IntermediateDirectory, tool.IntermediateDirectory) + << attrTagS(_PrimaryOutput, tool.PrimaryOutput) + << attrTagS(_ProgramDatabase, tool.ProgramDatabase) + << attrTagT(_RegisterOutput, tool.RegisterOutput) + << attrTagS(_UseOfATL, tool.UseOfATL) + << attrTagS(_UseOfMfc, tool.UseOfMfc) + << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization) + << closetag(); +} + +void VCXProjectWriter::write(XmlOutput &xml, VCFilter &tool) +{ } QT_END_NAMESPACE diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index 567985d..2446c77 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -689,19 +689,24 @@ public: }; - -XmlOutput &operator<<(XmlOutput &, const VCXCLCompilerTool &); -XmlOutput &operator<<(XmlOutput &, const VCXLinkerTool &); -XmlOutput &operator<<(XmlOutput &, const VCXMIDLTool &); -XmlOutput &operator<<(XmlOutput &, const VCXCustomBuildTool &); -XmlOutput &operator<<(XmlOutput &, const VCXLibrarianTool &); -XmlOutput &operator<<(XmlOutput &, const VCXResourceCompilerTool &); -XmlOutput &operator<<(XmlOutput &, const VCXEventTool &); -XmlOutput &operator<<(XmlOutput &, const VCXDeploymentTool &); -XmlOutput &operator<<(XmlOutput &, const VCXConfiguration &); -XmlOutput &operator<<(XmlOutput &, const VCXProjectSingleConfig &); -XmlOutput &operator<<(XmlOutput &, VCXProject &); - +class VCXProjectWriter : public VCProjectWriter +{ +public: + // ### replace the X classes by the standard names! + void write(XmlOutput &, VCXProjectSingleConfig &); + void write(XmlOutput &, VCXProject &); + + void write(XmlOutput &, const VCXCLCompilerTool &); + void write(XmlOutput &, const VCXLinkerTool &); + void write(XmlOutput &, const VCXMIDLTool &); + void write(XmlOutput &, const VCXCustomBuildTool &); + void write(XmlOutput &, const VCXLibrarianTool &); + void write(XmlOutput &, const VCXResourceCompilerTool &); + void write(XmlOutput &, const VCXEventTool &); + void write(XmlOutput &, const VCDeploymentTool &); + void write(XmlOutput &, const VCXConfiguration &); + void write(XmlOutput &, VCFilter &); +}; QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index c7f8ed0..bb692b1 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -1065,6 +1065,8 @@ public: class VCProjectWriter { public: + virtual ~VCProjectWriter() {} + virtual void write(XmlOutput &, VCProjectSingleConfig &); virtual void write(XmlOutput &, VCProject &); diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 9e2da06..55d50c0 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -207,10 +207,9 @@ const char _slnExtSections[] = "\n\tGlobalSection(ExtensibilityGlobals) = pos VcprojGenerator::VcprojGenerator() : Win32MakefileGenerator(), - init_flag(false), - projectWriter(0) + init_flag(false) { - projectWriter = new VCProjectWriter; + projectWriter = createProjectWriter(); } VcprojGenerator::~VcprojGenerator() @@ -1496,6 +1495,11 @@ void VcprojGenerator::initOld() // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ +VCProjectWriter *VcprojGenerator::createProjectWriter() +{ + return new VCProjectWriter; +} + QString VcprojGenerator::replaceExtraCompilerVariables(const QString &var, const QStringList &in, const QStringList &out) { QString ret = MakefileGenerator::replaceExtraCompilerVariables(var, in, out); diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h index 436a056..a603500 100644 --- a/qmake/generators/win32/msvc_vcproj.h +++ b/qmake/generators/win32/msvc_vcproj.h @@ -81,6 +81,7 @@ public: VCProjectWriter *projectWriter; protected: + virtual VCProjectWriter *createProjectWriter(); virtual bool doDepends() const { return false; } //never necesary virtual void processSources() { filterIncludedFiles("SOURCES"); filterIncludedFiles("GENERATED_SOURCES"); } virtual QString replaceExtraCompilerVariables(const QString &, const QStringList &, const QStringList &); diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index 802c596..b95e9cf 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -63,7 +63,14 @@ QT_BEGIN_NAMESPACE VcxprojGenerator::VcxprojGenerator() : VcprojGenerator() { + projectWriter = new VCXProjectWriter; } + +VCProjectWriter *VcxprojGenerator::createProjectWriter() +{ + return new VCXProjectWriter; +} + bool VcxprojGenerator::writeMakefile(QTextStream &t) { initProject(); // Fills the whole project with proper data @@ -84,7 +91,7 @@ bool VcxprojGenerator::writeMakefile(QTextStream &t) if(!project->isActiveConfig("build_pass")) { debug_msg(1, "Generator: MSVC.NET: Writing single configuration project file"); XmlOutput xmlOut(t); - xmlOut << vcxProject; + projectWriter->write(xmlOut, vcxProject); } return true; } @@ -643,7 +650,7 @@ bool VcxprojGenerator::writeProjectMakefile() mergedProject.PlatformName = mergedProjects.at(0)->vcxProject.PlatformName; XmlOutput xmlOut(t); - xmlOut << mergedProject; + projectWriter->write(xmlOut, mergedProject); return true; } else if(project->first("TEMPLATE") == "vcsubdirs") { return writeMakefile(t); diff --git a/qmake/generators/win32/msvc_vcxproj.h b/qmake/generators/win32/msvc_vcxproj.h index efbfcb8..bc79c0b 100644 --- a/qmake/generators/win32/msvc_vcxproj.h +++ b/qmake/generators/win32/msvc_vcxproj.h @@ -56,8 +56,10 @@ class VcxprojGenerator : public VcprojGenerator public: VcxprojGenerator(); ~VcxprojGenerator(); + VCXProjectWriter *projectWriter; // ### remove, once we've killed the VCX classes protected: + virtual VCProjectWriter *createProjectWriter(); virtual bool supportsMetaBuild() { return true; } virtual bool supportsMergedBuilds() { return true; } virtual bool mergeBuildProject(MakefileGenerator *other); -- cgit v0.12 From 79c4e65945b4741deed948c0c8e8d80818f0fbfb Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 4 Aug 2010 17:15:43 +0200 Subject: qmake: move XML generating code from data classes to VCXProjectWriter Rubber-stamped-by: ossi --- qmake/generators/win32/msbuild_objectmodel.cpp | 1014 +++++++++++------------- qmake/generators/win32/msbuild_objectmodel.h | 37 +- qmake/generators/win32/msvc_objectmodel.cpp | 3 +- 3 files changed, 494 insertions(+), 560 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index c2b2ee1..1a65a04 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -50,26 +50,14 @@ QT_BEGIN_NAMESPACE // XML Tags --------------------------------------------------------- const char _CLCompile[] = "ClCompile"; -const char _Configuration[] = "Configuration"; -const char _Configurations[] = "Configurations"; -const char q_File[] = "File"; -const char _FileConfiguration[] = "FileConfiguration"; -const char q_Files[] = "Files"; -const char _Filter[] = "Filter"; -const char _Globals[] = "Globals"; const char _ItemGroup[] = "ItemGroup"; const char _Link[] = "Link"; const char _Midl[] = "Midl"; -const char _Platform[] = "Platform"; -const char _Platforms[] = "Platforms"; const char _ResourceCompile[] = "ResourceCompile"; -const char _Tool[] = "Tool"; -const char _VisualStudioProject[] = "VisualStudioProject"; // XML Properties --------------------------------------------------- const char _AddModuleNamesToAssembly[] = "AddModuleNamesToAssembly"; const char _AdditionalDependencies[] = "AdditionalDependencies"; -const char _AdditionalFiles[] = "AdditionalFiles"; const char _AdditionalIncludeDirectories[] = "AdditionalIncludeDirectories"; const char _AdditionalLibraryDirectories[] = "AdditionalLibraryDirectories"; const char _AdditionalManifestDependencies[] = "AdditionalManifestDependencies"; @@ -97,11 +85,8 @@ const char _CLRSupportLastError[] = "CLRSupportLastError"; const char _CLRThreadAttribute[] = "CLRThreadAttribute"; const char _CLRUnmanagedCodeCheck[] = "CLRUnmanagedCodeCheck"; const char _Command[] = "Command"; -const char _CommandLine[] = "CommandLine"; const char _CompileAs[] = "CompileAs"; const char _CompileAsManaged[] = "CompileAsManaged"; -const char _CompileForArchitecture[] = "CompileForArchitecture"; -const char _CompileOnly[] = "CompileOnly"; const char _ConfigurationType[] = "ConfigurationType"; const char _CPreprocessOptions[] = "CPreprocessOptions"; const char _CreateHotpatchableImage[] = "CreateHotpatchableImage"; @@ -109,13 +94,10 @@ const char _CreateHotPatchableImage[] = "CreateHotPatchableImage"; const char _Culture[] = "Culture"; const char _DataExecutionPrevention[] = "DataExecutionPrevention"; const char _DebugInformationFormat[] = "DebugInformationFormat"; -const char _DefaultCharIsUnsigned[] = "DefaultCharIsUnsigned"; const char _DefaultCharType[] = "DefaultCharType"; const char _DelayLoadDLLs[] = "DelayLoadDLLs"; const char _DelaySign[] = "DelaySign"; const char _DeleteExtensionsOnClean[] = "DeleteExtensionsOnClean"; -const char _Description[] = "Description"; -const char _Detect64BitPortabilityProblems[] = "Detect64BitPortabilityProblems"; const char _DisableLanguageExtensions[] = "DisableLanguageExtensions"; const char _DisableSpecificWarnings[] = "DisableSpecificWarnings"; const char _DisplayLibrary[] = "DisplayLibrary"; @@ -127,8 +109,6 @@ const char _EnableUAC[] = "EnableUAC"; const char _EnableErrorChecks[] = "EnableErrorChecks"; const char _EnableEnhancedInstructionSet[] = "EnableEnhancedInstructionSet"; const char _EnableFiberSafeOptimizations[] = "EnableFiberSafeOptimizations"; -const char _EnableFunctionLevelLinking[] = "EnableFunctionLevelLinking"; -const char _EnableIntrinsicFunctions[] = "EnableIntrinsicFunctions"; const char _EnablePREfast[] = "EnablePREfast"; const char _EntryPointSymbol[] = "EntryPointSymbol"; const char _ErrorCheckAllocations[] = "ErrorCheckAllocations"; @@ -138,7 +118,6 @@ const char _ErrorCheckRefPointers[] = "ErrorCheckRefPointers"; const char _ErrorCheckStubData[] = "ErrorCheckStubData"; const char _ErrorReporting[] = "ErrorReporting"; const char _ExceptionHandling[] = "ExceptionHandling"; -const char _ExcludedFromBuild[] = "ExcludedFromBuild"; const char _ExpandAttributedSource[] = "ExpandAttributedSource"; const char _ExportNamedFunctions[] = "ExportNamedFunctions"; const char _FavorSizeOrSpeed[] = "FavorSizeOrSpeed"; @@ -150,52 +129,42 @@ const char _ForceFileOutput[] = "ForceFileOutput"; const char _ForceSymbolReferences[] = "ForceSymbolReferences"; const char _ForcedIncludeFiles[] = "ForcedIncludeFiles"; const char _ForcedUsingFiles[] = "ForcedUsingFiles"; -const char _FullIncludePath[] = "FullIncludePath"; const char _FunctionLevelLinking[] = "FunctionLevelLinking"; const char _FunctionOrder[] = "FunctionOrder"; const char _GenerateClientFiles[] = "GenerateClientFiles"; const char _GenerateDebugInformation[] = "GenerateDebugInformation"; const char _GenerateManifest[] = "GenerateManifest"; const char _GenerateMapFile[] = "GenerateMapFile"; -const char _GeneratePreprocessedFile[] = "GeneratePreprocessedFile"; const char _GenerateServerFiles[] = "GenerateServerFiles"; const char _GenerateStublessProxies[] = "GenerateStublessProxies"; const char _GenerateTypeLibrary[] = "GenerateTypeLibrary"; const char _GenerateXMLDocumentationFiles[] = "GenerateXMLDocumentationFiles"; -const char _GlobalOptimizations[] = "GlobalOptimizations"; const char _HeaderFileName[] = "HeaderFileName"; const char _HeapCommitSize[] = "HeapCommitSize"; const char _HeapReserveSize[] = "HeapReserveSize"; const char _IgnoreAllDefaultLibraries[] = "IgnoreAllDefaultLibraries"; -const char _IgnoreDefaultLibraryNames[] = "IgnoreDefaultLibraryNames"; const char _IgnoreEmbeddedIDL[] = "IgnoreEmbeddedIDL"; const char _IgnoreImportLibrary[] = "IgnoreImportLibrary"; const char _IgnoreSpecificDefaultLibraries[] = "IgnoreSpecificDefaultLibraries"; const char _IgnoreStandardIncludePath[] = "IgnoreStandardIncludePath"; const char _ImageHasSafeExceptionHandlers[] = "ImageHasSafeExceptionHandlers"; const char _ImportLibrary[] = "ImportLibrary"; -const char _ImproveFloatingPointConsistency[] = "ImproveFloatingPointConsistency"; const char _InlineFunctionExpansion[] = "InlineFunctionExpansion"; const char _IntrinsicFunctions[] = "IntrinsicFunctions"; const char _InterfaceIdentifierFileName[] = "InterfaceIdentifierFileName"; const char _IntermediateDirectory[] = "IntermediateDirectory"; -const char _InterworkCalls[] = "InterworkCalls"; const char _KeyContainer[] = "KeyContainer"; const char _KeyFile[] = "KeyFile"; -const char _Keyword[] = "Keyword"; -const char _KeepComments[] = "KeepComments"; const char _LargeAddressAware[] = "LargeAddressAware"; const char _LinkDLL[] = "LinkDLL"; const char _LinkErrorReporting[] = "LinkErrorReporting"; const char _LinkIncremental[] = "LinkIncremental"; const char _LinkStatus[] = "LinkStatus"; const char _LinkTimeCodeGeneration[] = "LinkTimeCodeGeneration"; -const char _LinkToManagedResourceFile[] = "LinkToManagedResourceFile"; const char _LocaleID[] = "LocaleID"; const char _ManifestFile[] = "ManifestFile"; const char _MapExports[] = "MapExports"; const char _MapFileName[] = "MapFileName"; -const char _MapLines[] = "MapLines "; const char _MergedIDLBaseFileName[] = "MergedIDLBaseFileName"; const char _MergeSections[] = "MergeSections"; const char _Message[] = "Message"; @@ -208,27 +177,18 @@ const char _MultiProcessorCompilation[] = "MultiProcessorCompilation"; const char _Name[] = "Name"; const char _NoEntryPoint[] = "NoEntryPoint"; const char _NullTerminateStrings[] = "NullTerminateStrings"; -const char _ObjectFile[] = "ObjectFile"; const char _ObjectFiles[] = "ObjectFiles"; const char _ObjectFileName[] = "ObjectFileName"; const char _OmitDefaultLibName[] = "OmitDefaultLibName"; const char _OmitFramePointers[] = "OmitFramePointers"; -const char _OpenMP[] = "OpenMP"; const char _OpenMPSupport[] = "OpenMPSupport"; const char _Optimization[] = "Optimization"; -const char _OptimizeForProcessor[] = "OptimizeForProcessor"; -const char _OptimizeForWindows98[] = "OptimizeForWindows98"; -const char _OptimizeForWindowsApplication[] = "OptimizeForWindowsApplication"; const char _OptimizeReferences[] = "OptimizeReferences"; const char _OutputDirectory[] = "OutputDirectory"; const char _OutputFile[] = "OutputFile"; -const char _Outputs[] = "Outputs"; -const char _ParseFiles[] = "ParseFiles"; -const char _Path[] = "Path"; const char _PrecompiledHeader[] = "PrecompiledHeader"; const char _PrecompiledHeaderFile[] = "PrecompiledHeaderFile"; const char _PrecompiledHeaderOutputFile[] = "PrecompiledHeaderOutputFile"; -const char _PrecompiledHeaderThrough[] = "PrecompiledHeaderThrough"; const char _PreprocessorDefinitions[] = "PreprocessorDefinitions"; const char _PreprocessKeepComments[] = "PreprocessKeepComments"; const char _PreprocessOutputPath[] = "PreprocessOutputPath"; @@ -238,9 +198,7 @@ const char _PreventDllBinding[] = "PreventDllBinding"; const char _PrimaryOutput[] = "PrimaryOutput"; const char _Profile[] = "Profile"; const char _ProfileGuidedDatabase[] = "ProfileGuidedDatabase"; -const char _ProjectGUID[] = "ProjectGUID"; const char _ProcessorNumber[] = "ProcessorNumber"; -const char _ProjectType[] = "ProjectType"; const char _ProgramDatabase[] = "ProgramDatabase"; const char _ProgramDataBaseFileName[] = "ProgramDataBaseFileName"; const char _ProgramDatabaseFile[] = "ProgramDatabaseFile"; @@ -248,15 +206,10 @@ const char _ProxyFileName[] = "ProxyFileName"; const char _RandomizedBaseAddress[] = "RandomizedBaseAddress"; const char _RedirectOutputAndErrors[] = "RedirectOutputAndErrors"; const char _RegisterOutput[] = "RegisterOutput"; -const char _RelativePath[] = "RelativePath"; -const char _RemoteDirectory[] = "RemoteDirectory"; const char _RemoveObjects[] = "RemoveObjects"; -const char _ResourceOnlyDLL[] = "ResourceOnlyDLL"; const char _ResourceOutputFileName[] = "ResourceOutputFileName"; const char _RuntimeLibrary[] = "RuntimeLibrary"; const char _RuntimeTypeInfo[] = "RuntimeTypeInfo"; -const char _SccProjectName[] = "SccProjectName"; -const char _SccLocalPath[] = "SccLocalPath"; const char _SectionAlignment[] = "SectionAlignment"; const char _ServerStubFile[] = "ServerStubFile"; const char _SetChecksum[] = "SetChecksum"; @@ -294,19 +247,12 @@ const char _UACExecutionLevel[] = "UACExecutionLevel"; const char _UACUIAccess[] = "UACUIAccess"; const char _UndefineAllPreprocessorDefinitions[]= "UndefineAllPreprocessorDefinitions"; const char _UndefinePreprocessorDefinitions[] = "UndefinePreprocessorDefinitions"; -const char _UniqueIdentifier[] = "UniqueIdentifier"; const char _UseFullPaths[] = "UseFullPaths"; const char _UseOfATL[] = "UseOfATL"; const char _UseOfMfc[] = "UseOfMfc"; -const char _UsePrecompiledHeader[] = "UsePrecompiledHeader"; const char _UseUnicodeForAssemblerListing[] = "UseUnicodeForAssemblerListing"; const char _ValidateAllParameters[] = "ValidateAllParameters"; -const char _VCCLCompilerTool[] = "VCCLCompilerTool"; -const char _VCLibrarianTool[] = "VCLibrarianTool"; -const char _VCLinkerTool[] = "VCLinkerTool"; const char _VCCustomBuildTool[] = "VCCustomBuildTool"; -const char _VCResourceCompilerTool[] = "VCResourceCompilerTool"; -const char _VCMIDLTool[] = "VCMIDLTool"; const char _Verbose[] = "Verbose"; const char _Version[] = "Version"; const char _WarnAsError[] = "WarnAsError"; @@ -343,7 +289,6 @@ inline XmlOutput::xml_output attrTagS(const char *name, const QString &v) return tagValue(name, v); } - inline XmlOutput::xml_output attrTagX(const char *name, const QStringList &v, const char *s = ",") { if(v.isEmpty()) @@ -2196,175 +2141,6 @@ bool VCXFilter::addExtraCompiler(const VCXFilterFile &info) return useCustomBuildTool; } -bool VCXFilter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded) -{ - bool fileAdded = false; - - // Clearing each filter tool - useCustomBuildTool = false; - useCompilerTool = false; - CustomBuildTool = VCXCustomBuildTool(); - CompilerTool = VCXCLCompilerTool(); - - // Unset some default options - CompilerTool.BufferSecurityCheck = unset; - CompilerTool.DebugInformationFormat = ""; - CompilerTool.ExceptionHandling = ""; - //CompilerTool.Optimization = optimizeDefault; - CompilerTool.ProgramDataBaseFileName.clear(); - CompilerTool.RuntimeLibrary = ""; - //CompilerTool.WarningLevel = warningLevelUnknown; - CompilerTool.config = Config; - - bool inBuild = false; - VCXFilterFile info; - for (int i = 0; i < Files.count(); ++i) { - if (Files.at(i).file == filename) { - info = Files.at(i); - inBuild = true; - } - } - inBuild &= !info.excludeFromBuild; - - if (inBuild) { - addExtraCompiler(info); - if(Project->usePCH) - modifyPCHstage(info.file); - } else { - // Excluded files uses an empty compiler stage - if(info.excludeFromBuild) - useCompilerTool = true; - } - - // Actual XML output ---------------------------------- - if(useCustomBuildTool || useCompilerTool || !inBuild) { - - if (useCustomBuildTool) - { - CustomBuildTool.ConfigName = (*Config).Name; - - if ( !fileAllreadyAdded ) { - - fileAdded = true; - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - - if ( filtername == "Form Files" || filtername == "Generated Files" || filtername == "Resource Files" ) - xml << attrTagS("FileType", "Document"); - } - - Project->projectWriter->write(xml, CustomBuildTool); - } - - if ( !fileAdded && !fileAllreadyAdded ) - { - fileAdded = true; - - if (filtername == "Source Files") { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - - } else if(filtername == "Header Files") { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else if(filtername == "Generated Files" || filtername == "Form Files") { - - if (filename.endsWith(".h")) { - - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else if(filename.endsWith(".cpp")) { - - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else if(filename.endsWith(".res")) { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } else { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } - } else if(filtername == "Root Files") { - - if (filename.endsWith(".rc")) { - - xmlFilter << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - - xml << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(filename)); - } - } - } - - if(!inBuild) { - - xml << tag("ExcludedFromBuild") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name)) - << valueTag("true"); - } - - if (useCompilerTool) { - - if ( !CompilerTool.ForcedIncludeFiles.isEmpty() ) { - xml << tag("ForcedIncludeFiles") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name)) - << valueTagX(CompilerTool.ForcedIncludeFiles); - } - - if ( !CompilerTool.PrecompiledHeaderFile.isEmpty() ) { - - xml << tag("PrecompiledHeaderFile") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name)) - << valueTag(CompilerTool.PrecompiledHeaderFile); - } - - if ( !CompilerTool.PrecompiledHeader.isEmpty() ) { - - xml << tag("PrecompiledHeader") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg((*Config).Name)) - << valueTag(CompilerTool.PrecompiledHeader); - } - } - } - - return fileAdded; -} - - // VCXProjectSingleConfig -------------------------------------------- VCXFilter nullVCXFilter; VCXFilter& VCXProjectSingleConfig::filterForExtraCompiler(const QString &compilerName) @@ -2399,7 +2175,7 @@ void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString xml << closetag("Filter"); } else { // Leaf - tool.outputFileConfigs(xml, xmlFilter, info, filter); + VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, info, filter); } } @@ -2412,309 +2188,91 @@ void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString xml << tag(_ItemGroup); xmlFilter << tag(_ItemGroup); for (; it != end; ++it) { - tool.outputFileConfigs(xml, xmlFilter, (*it), filter); + VCXProjectWriter::outputFileConfigs(tool, xml, xmlFilter, (*it), filter); } xml << closetag(); xmlFilter << closetag(); } } - -// VCXProject -------------------------------------------------------- -// Output all configurations (by filtername) for a file (by info) -// A filters config output is in VCXFilter.outputFileConfig() -void VCXProject::outputFileConfigs(XmlOutput &xml, - XmlOutput &xmlFilter, - const VCXFilterFile &info, - const QString &filtername) +void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) { - // We need to check if the file has any custom build step. - // If there is one then it has to be included with "CustomBuild Include" - bool fileAdded = false; - - for (int i = 0; i < SingleProjects.count(); ++i) { - VCXFilter filter; - if (filtername == "Root Files") { - filter = SingleProjects.at(i).RootFiles; - } else if (filtername == "Source Files") { - filter = SingleProjects.at(i).SourceFiles; - } else if (filtername == "Header Files") { - filter = SingleProjects.at(i).HeaderFiles; - } else if (filtername == "Generated Files") { - filter = SingleProjects.at(i).GeneratedFiles; - } else if (filtername == "LexYacc Files") { - filter = SingleProjects.at(i).LexYaccFiles; - } else if (filtername == "Translation Files") { - filter = SingleProjects.at(i).TranslationFiles; - } else if (filtername == "Form Files") { - filter = SingleProjects.at(i).FormFiles; - } else if (filtername == "Resource Files") { - filter = SingleProjects.at(i).ResourceFiles; - } else { - // ExtraCompilers - filter = SingleProjects[i].filterForExtraCompiler(filtername); - } + xml.setIndentString(" "); - if (filter.Config) // only if the filter is not empty - if (filter.outputFileConfig(xml, xmlFilter, info.file, filtername, fileAdded)) // only add it once. - fileAdded = true; - } + xml << decl("1.0", "utf-8") + << tag("Project") + << attrTag("DefaultTargets","Build") + << attrTag("ToolsVersion", "4.0") + << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003") + << tag("ItemGroup") + << attrTag("Label", "ProjectConfigurations"); - if ( !fileAdded ) - { - if (filtername == "Source Files") { + xml << tag("ProjectConfiguration") + << attrTag("Include" , tool.Configuration.Name) + << tagValue("Configuration", tool.Configuration.ConfigurationName) + << tagValue("Platform", tool.PlatformName) + << closetag(); - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); + xml << closetag() + << tag("PropertyGroup") + << attrTag("Label", "Globals") + << tagValue("ProjectGuid", tool.ProjectGUID) + << tagValue("RootNamespace", tool.Name) + << tagValue("Keyword", tool.Keyword) + << closetag(); - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); + // config part. + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - } else if(filtername == "Header Files") { + write(xml, tool.Configuration); - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); + xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(filtername == "Generated Files" || filtername == "Form Files") { + // Extension settings + xml << tag("ImportGroup") + << attrTag("Label", "ExtensionSettings") + << closetag(); - if (info.file.endsWith(".h")) { + // PropertySheets + xml << tag("ImportGroup") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << attrTag("Label", "PropertySheets"); - xmlFilter << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); + xml << tag("Import") + << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props") + << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')") + << closetag() + << closetag(); - xml << tag("ClInclude") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(info.file.endsWith(".cpp")) { - xmlFilter << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); + // UserMacros + xml << tag("PropertyGroup") + << attrTag("Label", "UserMacros") + << closetag(); - xml << tag("ClCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else if(info.file.endsWith(".res")) { + xml << tag("PropertyGroup"); - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); + if ( !tool.Configuration.OutputDirectory.isEmpty() ) { + xml<< tag("OutDir") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTag(tool.Configuration.OutputDirectory); + } + if ( !tool.Configuration.IntermediateDirectory.isEmpty() ) { + xml<< tag("IntDir") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTag(tool.Configuration.IntermediateDirectory); + } + if ( !tool.Configuration.TargetName.isEmpty() ) { + xml<< tag("TargetName") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTag(tool.Configuration.TargetName); + } - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } else { - - xmlFilter << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("CustomBuild") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } - - } else if(filtername == "Root Files") { - - if (info.file.endsWith(".rc")) { - - xmlFilter << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - - xml << tag("ResourceCompile") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } - } else { - - xmlFilter << tag("None") - << attrTag("Include",Option::fixPathToLocalOS(info.file)) - << attrTagS("Filter", filtername); - - xml << tag("None") - << attrTag("Include",Option::fixPathToLocalOS(info.file)); - } - } - - xml << closetag(); - xmlFilter << closetag(); -} - -// outputs a given filter for all existing configurations of a project -void VCXProject::outputFilter(XmlOutput &xml, - XmlOutput &xmlFilter, - const QString &filtername) -{ - XNode *root; - if (SingleProjects.at(0).flat_files) - root = new XFlatNode; - else - root = new XTreeNode; - - QString name, extfilter; - triState parse; - - for (int i = 0; i < SingleProjects.count(); ++i) { - VCXFilter filter; - if (filtername == "Root Files") { - filter = SingleProjects.at(i).RootFiles; - } else if (filtername == "Source Files") { - filter = SingleProjects.at(i).SourceFiles; - } else if (filtername == "Header Files") { - filter = SingleProjects.at(i).HeaderFiles; - } else if (filtername == "Generated Files") { - filter = SingleProjects.at(i).GeneratedFiles; - } else if (filtername == "LexYacc Files") { - filter = SingleProjects.at(i).LexYaccFiles; - } else if (filtername == "Translation Files") { - filter = SingleProjects.at(i).TranslationFiles; - } else if (filtername == "Form Files") { - filter = SingleProjects.at(i).FormFiles; - } else if (filtername == "Resource Files") { - filter = SingleProjects.at(i).ResourceFiles; - } else { - // ExtraCompilers - filter = SingleProjects[i].filterForExtraCompiler(filtername); - } - - // Merge all files in this filter to root tree - for (int x = 0; x < filter.Files.count(); ++x) - root->addElement(filter.Files.at(x)); - - // Save filter setting from first filter. Next filters - // may differ but we cannot handle that. (ex. extfilter) - if (name.isEmpty()) { - name = filter.Name; - extfilter = filter.Filter; - parse = filter.ParseFiles; - } - } - - if (!root->hasElements()) - return; - - root->generateXML(xml, xmlFilter, "", *this, filtername); // output root tree -} - - -void VCXProject::addFilters(XmlOutput &xmlFilter, - const QString &filtername) -{ - bool added = false; - - for (int i = 0; i < SingleProjects.count(); ++i) { - VCXFilter filter; - if (filtername == "Root Files") { - filter = SingleProjects.at(i).RootFiles; - } else if (filtername == "Source Files") { - filter = SingleProjects.at(i).SourceFiles; - } else if (filtername == "Header Files") { - filter = SingleProjects.at(i).HeaderFiles; - } else if (filtername == "Generated Files") { - filter = SingleProjects.at(i).GeneratedFiles; - } else if (filtername == "LexYacc Files") { - filter = SingleProjects.at(i).LexYaccFiles; - } else if (filtername == "Translation Files") { - filter = SingleProjects.at(i).TranslationFiles; - } else if (filtername == "Form Files") { - filter = SingleProjects.at(i).FormFiles; - } else if (filtername == "Resource Files") { - filter = SingleProjects.at(i).ResourceFiles; - } else { - // ExtraCompilers - filter = SingleProjects[i].filterForExtraCompiler(filtername); - } - - if(!filter.Files.isEmpty() && !added) { - added = true; - xmlFilter << tag("Filter") - << attrTag("Include", filtername) - << attrTagS("UniqueIdentifier", filter.Guid) - << attrTagS("Extensions", filter.Filter) - << attrTagT("ParseFiles", filter.ParseFiles) - << closetag(); - } - } -} - -void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) -{ - xml.setIndentString(" "); - - xml << decl("1.0", "utf-8") - << tag("Project") - << attrTag("DefaultTargets","Build") - << attrTag("ToolsVersion", "4.0") - << attrTag("xmlns", "http://schemas.microsoft.com/developer/msbuild/2003") - << tag("ItemGroup") - << attrTag("Label", "ProjectConfigurations"); - - xml << tag("ProjectConfiguration") - << attrTag("Include" , tool.Configuration.Name) - << tagValue("Configuration", tool.Configuration.ConfigurationName) - << tagValue("Platform", tool.PlatformName) - << closetag(); - - xml << closetag() - << tag("PropertyGroup") - << attrTag("Label", "Globals") - << tagValue("ProjectGuid", tool.ProjectGUID) - << tagValue("RootNamespace", tool.Name) - << tagValue("Keyword", tool.Keyword) - << closetag(); - - // config part. - xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); - - write(xml, tool.Configuration); - - xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); - - // Extension settings - xml << tag("ImportGroup") - << attrTag("Label", "ExtensionSettings") - << closetag(); - - // PropertySheets - xml << tag("ImportGroup") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << attrTag("Label", "PropertySheets"); - - xml << tag("Import") - << attrTag("Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props") - << attrTag("Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')") - << closetag() - << closetag(); - - - // UserMacros - xml << tag("PropertyGroup") - << attrTag("Label", "UserMacros") - << closetag(); - - xml << tag("PropertyGroup"); - - if ( !tool.Configuration.OutputDirectory.isEmpty() ) { - xml<< tag("OutDir") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.OutputDirectory); - } - if ( !tool.Configuration.IntermediateDirectory.isEmpty() ) { - xml<< tag("IntDir") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.IntermediateDirectory); - } - if ( !tool.Configuration.TargetName.isEmpty() ) { - xml<< tag("TargetName") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.TargetName); - } - - if ( tool.Configuration.linker.IgnoreImportLibrary != unset) { - xml<< tag("IgnoreImportLibrary") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.linker.IgnoreImportLibrary); - } + if ( tool.Configuration.linker.IgnoreImportLibrary != unset) { + xml<< tag("IgnoreImportLibrary") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) + << valueTagT(tool.Configuration.linker.IgnoreImportLibrary); + } if ( tool.Configuration.linker.LinkIncremental != unset) { xml<< tag("LinkIncremental") @@ -2791,25 +2349,25 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) VCXProject tempProj; tempProj.SingleProjects += tool; - tempProj.addFilters(xmlFilter, "Form Files"); - tempProj.addFilters(xmlFilter, "Generated Files"); - tempProj.addFilters(xmlFilter, "Header Files"); - tempProj.addFilters(xmlFilter, "LexYacc Files"); - tempProj.addFilters(xmlFilter, "Resource Files"); - tempProj.addFilters(xmlFilter, "Source Files"); - tempProj.addFilters(xmlFilter, "Translation Files"); + addFilters(tempProj, xmlFilter, "Form Files"); + addFilters(tempProj, xmlFilter, "Generated Files"); + addFilters(tempProj, xmlFilter, "Header Files"); + addFilters(tempProj, xmlFilter, "LexYacc Files"); + addFilters(tempProj, xmlFilter, "Resource Files"); + addFilters(tempProj, xmlFilter, "Source Files"); + addFilters(tempProj, xmlFilter, "Translation Files"); xmlFilter << closetag(); - tempProj.outputFilter(xml, xmlFilter, "Source Files"); - tempProj.outputFilter(xml, xmlFilter, "Header Files"); - tempProj.outputFilter(xml, xmlFilter, "Generated Files"); - tempProj.outputFilter(xml, xmlFilter, "LexYacc Files"); - tempProj.outputFilter(xml, xmlFilter, "Translation Files"); - tempProj.outputFilter(xml, xmlFilter, "Form Files"); - tempProj.outputFilter(xml, xmlFilter, "Resource Files"); + outputFilter(tempProj, xml, xmlFilter, "Source Files"); + outputFilter(tempProj, xml, xmlFilter, "Header Files"); + outputFilter(tempProj, xml, xmlFilter, "Generated Files"); + outputFilter(tempProj, xml, xmlFilter, "LexYacc Files"); + outputFilter(tempProj, xml, xmlFilter, "Translation Files"); + outputFilter(tempProj, xml, xmlFilter, "Form Files"); + outputFilter(tempProj, xml, xmlFilter, "Resource Files"); for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { - tempProj.outputFilter(xml, xmlFilter, tempProj.ExtraCompilers.at(x)); + outputFilter(tempProj, xml, xmlFilter, tempProj.ExtraCompilers.at(x)); } xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); @@ -2982,26 +2540,26 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) xmlFilter << tag("ItemGroup"); - tool.addFilters(xmlFilter, "Form Files"); - tool.addFilters(xmlFilter, "Generated Files"); - tool.addFilters(xmlFilter, "Header Files"); - tool.addFilters(xmlFilter, "LexYacc Files"); - tool.addFilters(xmlFilter, "Resource Files"); - tool.addFilters(xmlFilter, "Source Files"); - tool.addFilters(xmlFilter, "Translation Files"); + addFilters(tool, xmlFilter, "Form Files"); + addFilters(tool, xmlFilter, "Generated Files"); + addFilters(tool, xmlFilter, "Header Files"); + addFilters(tool, xmlFilter, "LexYacc Files"); + addFilters(tool, xmlFilter, "Resource Files"); + addFilters(tool, xmlFilter, "Source Files"); + addFilters(tool, xmlFilter, "Translation Files"); xmlFilter << closetag(); - tool.outputFilter(xml, xmlFilter, "Source Files"); - tool.outputFilter(xml, xmlFilter, "Header Files"); - tool.outputFilter(xml, xmlFilter, "Generated Files"); - tool.outputFilter(xml, xmlFilter, "LexYacc Files"); - tool.outputFilter(xml, xmlFilter, "Translation Files"); - tool.outputFilter(xml, xmlFilter, "Form Files"); - tool.outputFilter(xml, xmlFilter, "Resource Files"); + outputFilter(tool, xml, xmlFilter, "Source Files"); + outputFilter(tool, xml, xmlFilter, "Header Files"); + outputFilter(tool, xml, xmlFilter, "Generated Files"); + outputFilter(tool, xml, xmlFilter, "LexYacc Files"); + outputFilter(tool, xml, xmlFilter, "Translation Files"); + outputFilter(tool, xml, xmlFilter, "Form Files"); + outputFilter(tool, xml, xmlFilter, "Resource Files"); for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { - tool.outputFilter(xml, xmlFilter, tool.ExtraCompilers.at(x)); + outputFilter(tool, xml, xmlFilter, tool.ExtraCompilers.at(x)); } - tool.outputFilter(xml, xmlFilter, "Root Files"); + outputFilter(tool, xml, xmlFilter, "Root Files"); xml << import("Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); @@ -3362,6 +2920,386 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXConfiguration &tool) void VCXProjectWriter::write(XmlOutput &xml, VCFilter &tool) { + Q_UNUSED(xml); + Q_UNUSED(tool); + // unused in this generator +} + +void VCXProjectWriter::addFilters(VCXProject &project, XmlOutput &xmlFilter, const QString &filtername) +{ + bool added = false; + + for (int i = 0; i < project.SingleProjects.count(); ++i) { + VCXFilter filter; + const VCXProjectSingleConfig &singleCfg = project.SingleProjects.at(i); + if (filtername == "Root Files") { + filter = singleCfg.RootFiles; + } else if (filtername == "Source Files") { + filter = singleCfg.SourceFiles; + } else if (filtername == "Header Files") { + filter = singleCfg.HeaderFiles; + } else if (filtername == "Generated Files") { + filter = singleCfg.GeneratedFiles; + } else if (filtername == "LexYacc Files") { + filter = singleCfg.LexYaccFiles; + } else if (filtername == "Translation Files") { + filter = singleCfg.TranslationFiles; + } else if (filtername == "Form Files") { + filter = singleCfg.FormFiles; + } else if (filtername == "Resource Files") { + filter = singleCfg.ResourceFiles; + } else { + // ExtraCompilers + filter = project.SingleProjects[i].filterForExtraCompiler(filtername); + } + + if(!filter.Files.isEmpty() && !added) { + xmlFilter << tag("Filter") + << attrTag("Include", filtername) + << attrTagS("UniqueIdentifier", filter.Guid) + << attrTagS("Extensions", filter.Filter) + << attrTagT("ParseFiles", filter.ParseFiles) + << closetag(); + } + } +} + +// outputs a given filter for all existing configurations of a project +void VCXProjectWriter::outputFilter(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername) +{ + XNode *root; + if (project.SingleProjects.at(0).flat_files) + root = new XFlatNode; + else + root = new XTreeNode; + + QString name, extfilter; + triState parse; + + for (int i = 0; i < project.SingleProjects.count(); ++i) { + VCXFilter filter; + const VCXProjectSingleConfig &singleCfg = project.SingleProjects.at(i); + if (filtername == "Root Files") { + filter = singleCfg.RootFiles; + } else if (filtername == "Source Files") { + filter = singleCfg.SourceFiles; + } else if (filtername == "Header Files") { + filter = singleCfg.HeaderFiles; + } else if (filtername == "Generated Files") { + filter = singleCfg.GeneratedFiles; + } else if (filtername == "LexYacc Files") { + filter = singleCfg.LexYaccFiles; + } else if (filtername == "Translation Files") { + filter = singleCfg.TranslationFiles; + } else if (filtername == "Form Files") { + filter = singleCfg.FormFiles; + } else if (filtername == "Resource Files") { + filter = singleCfg.ResourceFiles; + } else { + // ExtraCompilers + filter = project.SingleProjects[i].filterForExtraCompiler(filtername); + } + + // Merge all files in this filter to root tree + for (int x = 0; x < filter.Files.count(); ++x) + root->addElement(filter.Files.at(x)); + + // Save filter setting from first filter. Next filters + // may differ but we cannot handle that. (ex. extfilter) + if (name.isEmpty()) { + name = filter.Name; + extfilter = filter.Filter; + parse = filter.ParseFiles; + } + } + + if (!root->hasElements()) + return; + + root->generateXML(xml, xmlFilter, "", project, filtername); // output root tree +} + +// Output all configurations (by filtername) for a file (by info) +// A filters config output is in VCXFilter.outputFileConfig() +void VCXProjectWriter::outputFileConfigs(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCXFilterFile &info, const QString &filtername) +{ + // We need to check if the file has any custom build step. + // If there is one then it has to be included with "CustomBuild Include" + bool fileAdded = false; + + for (int i = 0; i < project.SingleProjects.count(); ++i) { + VCXFilter filter; + const VCXProjectSingleConfig &singleCfg = project.SingleProjects.at(i); + if (filtername == "Root Files") { + filter = singleCfg.RootFiles; + } else if (filtername == "Source Files") { + filter = singleCfg.SourceFiles; + } else if (filtername == "Header Files") { + filter = singleCfg.HeaderFiles; + } else if (filtername == "Generated Files") { + filter = singleCfg.GeneratedFiles; + } else if (filtername == "LexYacc Files") { + filter = singleCfg.LexYaccFiles; + } else if (filtername == "Translation Files") { + filter = singleCfg.TranslationFiles; + } else if (filtername == "Form Files") { + filter = singleCfg.FormFiles; + } else if (filtername == "Resource Files") { + filter = singleCfg.ResourceFiles; + } else { + // ExtraCompilers + filter = project.SingleProjects[i].filterForExtraCompiler(filtername); + } + + if (filter.Config) // only if the filter is not empty + if (outputFileConfig(filter, xml, xmlFilter, info.file, filtername, fileAdded)) // only add it once. + fileAdded = true; + } + + if ( !fileAdded ) + { + if (filtername == "Source Files") { + + xmlFilter << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + + } else if(filtername == "Header Files") { + + xmlFilter << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } else if(filtername == "Generated Files" || filtername == "Form Files") { + + if (info.file.endsWith(".h")) { + + xmlFilter << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } else if(info.file.endsWith(".cpp")) { + + xmlFilter << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } else if(info.file.endsWith(".res")) { + + xmlFilter << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } else { + + xmlFilter << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } + + } else if(filtername == "Root Files") { + + if (info.file.endsWith(".rc")) { + + xmlFilter << tag("ResourceCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + + xml << tag("ResourceCompile") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } + } else { + + xmlFilter << tag("None") + << attrTag("Include",Option::fixPathToLocalOS(info.file)) + << attrTagS("Filter", filtername); + + xml << tag("None") + << attrTag("Include",Option::fixPathToLocalOS(info.file)); + } + } + + xml << closetag(); + xmlFilter << closetag(); +} + +bool VCXProjectWriter::outputFileConfig(VCXFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded) +{ + bool fileAdded = false; + + // Clearing each filter tool + filter.useCustomBuildTool = false; + filter.useCompilerTool = false; + filter.CustomBuildTool = VCXCustomBuildTool(); + filter.CompilerTool = VCXCLCompilerTool(); + + // Unset some default options + filter.CompilerTool.BufferSecurityCheck = unset; + filter.CompilerTool.DebugInformationFormat = ""; + filter.CompilerTool.ExceptionHandling = ""; + filter.CompilerTool.ProgramDataBaseFileName.clear(); + filter.CompilerTool.RuntimeLibrary = ""; + filter.CompilerTool.config = filter.Config; + + bool inBuild = false; + VCXFilterFile info; + for (int i = 0; i < filter.Files.count(); ++i) { + if (filter.Files.at(i).file == filename) { + info = filter.Files.at(i); + inBuild = true; + } + } + inBuild &= !info.excludeFromBuild; + + if (inBuild) { + filter.addExtraCompiler(info); + if (filter.Project->usePCH) + filter.modifyPCHstage(info.file); + } else { + // Excluded files uses an empty compiler stage + if(info.excludeFromBuild) + filter.useCompilerTool = true; + } + + // Actual XML output ---------------------------------- + if (filter.useCustomBuildTool || filter.useCompilerTool || !inBuild) { + + if (filter.useCustomBuildTool) + { + filter.CustomBuildTool.ConfigName = (*filter.Config).Name; + + if ( !fileAllreadyAdded ) { + + fileAdded = true; + + xmlFilter << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + + if ( filtername == "Form Files" || filtername == "Generated Files" || filtername == "Resource Files" ) + xml << attrTagS("FileType", "Document"); + } + + filter.Project->projectWriter->write(xml, filter.CustomBuildTool); + } + + if ( !fileAdded && !fileAllreadyAdded ) + { + fileAdded = true; + + if (filtername == "Source Files") { + + xmlFilter << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + + } else if(filtername == "Header Files") { + + xmlFilter << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + } else if(filtername == "Generated Files" || filtername == "Form Files") { + + if (filename.endsWith(".h")) { + + xmlFilter << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("ClInclude") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + } else if(filename.endsWith(".cpp")) { + + xmlFilter << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("ClCompile") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + } else if(filename.endsWith(".res")) { + + xmlFilter << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + } else { + + xmlFilter << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(filename)) + << attrTagS("Filter", filtername); + + xml << tag("CustomBuild") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + } + } else if(filtername == "Root Files") { + + if (filename.endsWith(".rc")) { + + xmlFilter << tag("ResourceCompile") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + + xml << tag("ResourceCompile") + << attrTag("Include",Option::fixPathToLocalOS(filename)); + } + } + } + + if(!inBuild) { + + xml << tag("ExcludedFromBuild") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) + << valueTag("true"); + } + + if (filter.useCompilerTool) { + + if ( !filter.CompilerTool.ForcedIncludeFiles.isEmpty() ) { + xml << tag("ForcedIncludeFiles") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) + << valueTagX(filter.CompilerTool.ForcedIncludeFiles); + } + + if ( !filter.CompilerTool.PrecompiledHeaderFile.isEmpty() ) { + + xml << tag("PrecompiledHeaderFile") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) + << valueTag(filter.CompilerTool.PrecompiledHeaderFile); + } + + if ( !filter.CompilerTool.PrecompiledHeader.isEmpty() ) { + + xml << tag("PrecompiledHeader") + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) + << valueTag(filter.CompilerTool.PrecompiledHeader); + } + } + } + + return fileAdded; } QT_END_NAMESPACE diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index 2446c77..af45330 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -476,12 +476,11 @@ public: VCXFilter(); ~VCXFilter(){}; - void addFile(const QString& filename); - void addFile(const VCXFilterFile& fileInfo); - void addFiles(const QStringList& fileList); - bool addExtraCompiler(const VCXFilterFile &info); - void modifyPCHstage(QString str); - bool outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded); + void addFile(const QString& filename); // equal + void addFile(const VCXFilterFile& fileInfo);// equal + void addFiles(const QStringList& fileList);// equal + bool addExtraCompiler(const VCXFilterFile &info); //equal + void modifyPCHstage(QString str); //almost equal -> file comment .vcxproj, PrecompiledHeader property // Variables QString Name; @@ -544,6 +543,7 @@ public: // Accessor for extracompilers VCXFilter &filterForExtraCompiler(const QString &compilerName); + // ### this function is the same as in VCProjectSingleConfig ----> DIE DIE DIE }; @@ -673,26 +673,12 @@ public: // List of all extracompilers QStringList ExtraCompilers; - - // Functions - void outputFilter(XmlOutput &xml, - XmlOutput &xmlFilter, - const QString &filtername); - - void outputFileConfigs(XmlOutput &xml, - XmlOutput &xmlFilter, - const VCXFilterFile &info, - const QString &filtername); - - void addFilters(XmlOutput &xmlFilter, - const QString &filtername); - }; class VCXProjectWriter : public VCProjectWriter { public: - // ### replace the X classes by the standard names! + // ### replace the X classes with the standard names! void write(XmlOutput &, VCXProjectSingleConfig &); void write(XmlOutput &, VCXProject &); @@ -706,6 +692,15 @@ public: void write(XmlOutput &, const VCDeploymentTool &); void write(XmlOutput &, const VCXConfiguration &); void write(XmlOutput &, VCFilter &); + +private: + static void addFilters(VCXProject &project, XmlOutput &xmlFilter, const QString &filterName); + static void outputFilter(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername); + static void outputFileConfigs(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCXFilterFile &info, const QString &filtername); + static bool outputFileConfig(VCXFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded); + + friend class XTreeNode; + friend class XFlatNode; }; QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index ad4ac16..1d18dc8 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2071,12 +2071,13 @@ void VCFilter::outputFileConfig(XmlOutput &xml, const QString &filename) } // VCProjectSingleConfig -------------------------------------------- -VCFilter nullFilter; VCFilter& VCProjectSingleConfig::filterForExtraCompiler(const QString &compilerName) { for (int i = 0; i < ExtraCompilersFiles.count(); ++i) if (ExtraCompilersFiles.at(i).Name == compilerName) return ExtraCompilersFiles[i]; + + static VCFilter nullFilter; return nullFilter; } -- cgit v0.12 From 88002eb433150615bc2b171d3642bca6a18c9916 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Aug 2010 17:26:07 +0200 Subject: qmake: duplicated code removed from msbuild_objectmodel.cpp Rubber-stamped-by: ossi --- qmake/generators/win32/msbuild_objectmodel.cpp | 2612 ++++++------------------ qmake/generators/win32/msbuild_objectmodel.h | 562 +---- qmake/generators/win32/msvc_objectmodel.cpp | 350 +++- qmake/generators/win32/msvc_objectmodel.h | 66 +- qmake/generators/win32/msvc_vcxproj.cpp | 103 +- qmake/generators/win32/msvc_vcxproj.h | 5 +- 6 files changed, 1060 insertions(+), 2638 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 1a65a04..c9ba248 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -102,7 +102,6 @@ const char _DisableLanguageExtensions[] = "DisableLanguageExtensions"; const char _DisableSpecificWarnings[] = "DisableSpecificWarnings"; const char _DisplayLibrary[] = "DisplayLibrary"; const char _DLLDataFileName[] = "DLLDataFileName"; -const char _Driver[] = "Driver"; const char _EmbedManagedResourceFile[] = "EmbedManagedResourceFile"; const char _EnableCOMDATFolding[] = "EnableCOMDATFolding"; const char _EnableUAC[] = "EnableUAC"; @@ -121,11 +120,9 @@ const char _ExceptionHandling[] = "ExceptionHandling"; const char _ExpandAttributedSource[] = "ExpandAttributedSource"; const char _ExportNamedFunctions[] = "ExportNamedFunctions"; const char _FavorSizeOrSpeed[] = "FavorSizeOrSpeed"; -const char _FixedBaseAddress[] = "FixedBaseAddress"; const char _FloatingPointModel[] = "FloatingPointModel"; const char _FloatingPointExceptions[] = "FloatingPointExceptions"; const char _ForceConformanceInForLoopScope[] = "ForceConformanceInForLoopScope"; -const char _ForceFileOutput[] = "ForceFileOutput"; const char _ForceSymbolReferences[] = "ForceSymbolReferences"; const char _ForcedIncludeFiles[] = "ForcedIncludeFiles"; const char _ForcedUsingFiles[] = "ForcedUsingFiles"; @@ -147,7 +144,6 @@ const char _IgnoreEmbeddedIDL[] = "IgnoreEmbeddedIDL"; const char _IgnoreImportLibrary[] = "IgnoreImportLibrary"; const char _IgnoreSpecificDefaultLibraries[] = "IgnoreSpecificDefaultLibraries"; const char _IgnoreStandardIncludePath[] = "IgnoreStandardIncludePath"; -const char _ImageHasSafeExceptionHandlers[] = "ImageHasSafeExceptionHandlers"; const char _ImportLibrary[] = "ImportLibrary"; const char _InlineFunctionExpansion[] = "InlineFunctionExpansion"; const char _IntrinsicFunctions[] = "IntrinsicFunctions"; @@ -172,7 +168,6 @@ const char _MidlCommandFile[] = "MidlCommandFile"; const char _MinimalRebuild[] = "MinimalRebuild"; const char _MkTypLibCompatible[] = "MkTypLibCompatible"; const char _ModuleDefinitionFile[] = "ModuleDefinitionFile"; -const char _MSDOSStubFileName[] = "MSDOSStubFileName"; const char _MultiProcessorCompilation[] = "MultiProcessorCompilation"; const char _Name[] = "Name"; const char _NoEntryPoint[] = "NoEntryPoint"; @@ -196,8 +191,6 @@ const char _PreprocessSuppressLineNumbers[] = "PreprocessSuppressLineNumbers const char _PreprocessToFile[] = "PreprocessToFile"; const char _PreventDllBinding[] = "PreventDllBinding"; const char _PrimaryOutput[] = "PrimaryOutput"; -const char _Profile[] = "Profile"; -const char _ProfileGuidedDatabase[] = "ProfileGuidedDatabase"; const char _ProcessorNumber[] = "ProcessorNumber"; const char _ProgramDatabase[] = "ProgramDatabase"; const char _ProgramDataBaseFileName[] = "ProgramDataBaseFileName"; @@ -216,7 +209,6 @@ const char _SetChecksum[] = "SetChecksum"; const char _ShowIncludes[] = "ShowIncludes"; const char _ShowProgress[] = "ShowProgress"; const char _SmallerTypeCheck[] = "SmallerTypeCheck"; -const char _SpecifySectionAttributes[] = "SpecifySectionAttributes"; const char _StackCommitSize[] = "StackCommitSize"; const char _StackReserveSize[] = "StackReserveSize"; const char _StringPooling[] = "StringPooling"; @@ -321,1838 +313,8 @@ inline XmlOutput::xml_output valueTagT( const triState v) return valueTag(v == _True ? "true" : "false"); } - -// VCXCLCompilerTool ------------------------------------------------- -VCXCLCompilerTool::VCXCLCompilerTool() - : BrowseInformation(_False), - BufferSecurityCheck(_False), - CreateHotpatchableImage(unset), - DisableLanguageExtensions(unset), - EnableFiberSafeOptimizations(unset), - EnablePREfast(unset), - ExpandAttributedSource(unset), - FloatingPointExceptions(unset), - ForceConformanceInForLoopScope(unset), - FunctionLevelLinking(unset), - GenerateXMLDocumentationFiles(unset), - IgnoreStandardIncludePath(unset), - IntrinsicFunctions(unset), - MinimalRebuild(unset), - MultiProcessorCompilation(unset), - OmitDefaultLibName(unset), - OmitFramePointers(unset), - Optimization("Disabled"), - OpenMPSupport(unset), - PreprocessKeepComments(unset), - PreprocessSuppressLineNumbers(unset), - RuntimeTypeInfo(unset), - ShowIncludes(unset), - SmallerTypeCheck(unset), - StringPooling(unset), - SuppressStartupBanner(unset), - TreatWarningAsError(unset), - TreatWChar_tAsBuiltInType(unset), - UndefineAllPreprocessorDefinitions(unset), - UseFullPaths(unset), - UseUnicodeForAssemblerListing(unset), - WholeProgramOptimization(unset) -{ -} - -bool VCXCLCompilerTool::parseOption(const char* option) -{ - // skip index 0 ('/' or '-') - char first = option[1]; - char second = option[2]; - char third = option[3]; - char fourth = option[4]; - bool found = true; - - switch (first) { - case '?': - qWarning("Generator: Option '/?' : MSVC.NET projects do not support outputting help info"); - found = false; - break; - case '@': - qWarning("Generator: Option '/@': MSVC.NET projects do not support the use of a response file"); - found = false; - break; - case 'l': - qWarning("Generator: Option '/link': qmake generator does not support passing link options through the compiler tool"); - found = false; - break; - case 'A': - if(second != 'I') { - found = false; - break; - } - AdditionalUsingDirectories += option+3; - break; - case 'C': - PreprocessKeepComments = _True; - break; - case 'D': - PreprocessorDefinitions += option+2; - break; - case 'E': - if(second == 'H') { - QString opt(option); - if (opt.endsWith("EHa")) - ExceptionHandling = "Async"; - else if (opt.endsWith("EHsc")) - ExceptionHandling = "Sync"; - else if (opt.endsWith("EHs")) - ExceptionHandling = "SyncCThrow"; - else { - ExceptionHandling = "false"; - } - break; - }else if(second == 'P') { - PreprocessSuppressLineNumbers = _True; - } - found = false; - break; - case 'F': - if(second <= '9' && second >= '0') { - AdditionalOptions += option; - break; - } else { - switch (second) { - case 'A': - if(third == 'c') { - AssemblerOutput = "AssemblyAndMachineCode"; - if(fourth == 's') - AssemblerOutput = "All"; - } else if(third == 's') { - AssemblerOutput = "AssemblyAndSourceCode"; - } else if(third == 'u') { - UseUnicodeForAssemblerListing = _True; - } else { - AssemblerOutput = "AssemblyCode"; - } - break; - case 'a': - AssemblerListingLocation = option+3; - break; - case 'C': - UseFullPaths = _True; - break; - case 'd': - ProgramDataBaseFileName += option+3; - case 'I': - ForcedIncludeFiles += option+3; - break; - case 'i': - PreprocessOutputPath += option+3; - break; - case 'm': - AdditionalOptions += option; - break; - case 'R': - BrowseInformation = _True; - BrowseInformationFile = option+3; - break; - case 'r': - BrowseInformation = _True; - BrowseInformationFile = option+3; - break; - case 'U': - ForcedUsingFiles += option+3; - break; - case 'o': - ObjectFileName = option+3; - break; - case 'p': - PrecompiledHeaderOutputFile = option+3; - break; - case 'x': - ExpandAttributedSource = _True; - break; - default: - found = false; - break; - } - } - break; - case 'G': - switch (second) { - case 'F': - StringPooling = _True; - break; - case 'L': - WholeProgramOptimization = _True; - if(third == '-') - WholeProgramOptimization = _False; - break; - case 'R': - RuntimeTypeInfo = _True; - if(third == '-') - RuntimeTypeInfo = _False; - break; - case 'S': - BufferSecurityCheck = _True; - if(third == '-') - BufferSecurityCheck = _False; - break; - case 'T': - EnableFiberSafeOptimizations = _True; - break; - case 'd': - CallingConvention = "Cdecl"; - break; - case 'm': - MinimalRebuild = _True; - if(third == '-') - MinimalRebuild = _False; - break; - case 'r': - CallingConvention = "FastCall"; - break; - case 'y': - FunctionLevelLinking = _True; - break; - case 'z': - CallingConvention = "StdCall"; - break; - default: - found = false; - break; - } - break; - case 'H': - AdditionalOptions += option; - break; - case 'I': - AdditionalIncludeDirectories += option+2; - break; - case 'L': - if(second == 'D') { - AdditionalOptions += option; - break; - } - found = false; - break; - case 'M': - if(second == 'D') { - RuntimeLibrary = "MultiThreadedDLL"; - if(third == 'd') - RuntimeLibrary = "MultiThreadedDebugDLL"; - break; - } else if(second == 'P') { - MultiProcessorCompilation = _True; - ProcessorNumber = option+3; - break; - } else if(second == 'T') { - RuntimeLibrary = "MultiThreaded"; - if(third == 'd') - RuntimeLibrary = "MultiThreadedDebug"; - break; - } - found = false; - break; - case 'O': - switch (second) { - case '1': - Optimization = "MinSpace"; - break; - case '2': - Optimization = "MaxSpeed"; - break; - case 'b': - if(third == '0') - InlineFunctionExpansion = "Disabled"; - else if(third == '1') - InlineFunctionExpansion = "OnlyExplicitInline"; - else if(third == '2') - InlineFunctionExpansion = "AnySuitable"; - else - found = false; - break; - case 'd': - Optimization = "Disabled"; - break; - case 'i': - IntrinsicFunctions = _True; - break; - case 'p': - if(third == 'e') - OpenMPSupport = _True; - else - found = false; - break; - case 's': - FavorSizeOrSpeed = "Size"; - break; - case 't': - FavorSizeOrSpeed = "Speed"; - break; - case 'x': - Optimization = "Full"; - break; - case 'y': - OmitFramePointers = _True; - if(third == '-') - OmitFramePointers = _False; - break; - default: - found = false; - break; - } - break; - case 'P': - PreprocessToFile = _True; - break; - case 'Q': - if(second == 'I') { - AdditionalOptions += option; - break; - } - found = false; - break; - case 'R': - if(second == 'T' && third == 'C') { - if(fourth == '1') - BasicRuntimeChecks = "EnableFastChecks"; - else if(fourth == 'c') - SmallerTypeCheck = _True; - else if(fourth == 's') - BasicRuntimeChecks = "StackFrameRuntimeCheck"; - else if(fourth == 'u') - BasicRuntimeChecks = "UninitializedLocalUsageCheck"; - else - found = false; break; - } - break; - case 'T': - if(second == 'C') { - CompileAs = "CompileAsC"; - } else if(second == 'P') { - CompileAs = "CompileAsCpp"; - } else { - qWarning("Generator: Options '/Tp' and '/Tc' are not supported by qmake"); - found = false; break; - } - break; - case 'U': - UndefinePreprocessorDefinitions += option+2; - break; - case 'V': - AdditionalOptions += option; - break; - case 'W': - switch (second) { - case 'a': - WarningLevel = "EnableAllWarnings"; - break; - case '4': - WarningLevel = "Level4"; - break; - case '3': - WarningLevel = "Level3"; - break; - case '2': - WarningLevel = "Level2"; - break; - case '1': - WarningLevel = "Level1"; - break; - case '0': - WarningLevel = "TurnOffAllWarnings"; - break; - case 'L': - AdditionalOptions += option; - break; - case 'X': - TreatWarningAsError = _True; - break; - case 'p': - if(third == '6' && fourth == '4') { - // Deprecated for VS2010 but can be used under Additional Options. - AdditionalOptions += option; - break; - } - // Fallthrough - default: - found = false; break; - } - break; - case 'X': - IgnoreStandardIncludePath = _True; - break; - case 'Y': - switch (second) { - case '\0': - case '-': - AdditionalOptions += option; - break; - case 'c': - PrecompiledHeader = "Create"; - PrecompiledHeaderFile = option+3; - break; - case 'd': - case 'l': - AdditionalOptions += option; - break; - case 'u': - PrecompiledHeader = "Use"; - PrecompiledHeaderFile = option+3; - break; - default: - found = false; break; - } - break; - case 'Z': - switch (second) { - case '7': - DebugInformationFormat = "OldStyle"; - break; - case 'I': - DebugInformationFormat = "EditAndContinue"; - break; - case 'i': - DebugInformationFormat = "ProgramDatabase"; - break; - case 'l': - OmitDefaultLibName = _True; - break; - case 'a': - DisableLanguageExtensions = _True; - break; - case 'e': - DisableLanguageExtensions = _False; - break; - case 'c': - if(third == ':') { - const char *c = option + 4; - // Go to the end of the option - while ( *c != '\0' && *c != ' ' && *c != '-') - ++c; - if(fourth == 'f') - ForceConformanceInForLoopScope = ((*c) == '-' ? _False : _True); - else if(fourth == 'w') - TreatWChar_tAsBuiltInType = ((*c) == '-' ? _False : _True); - else - found = false; - } else { - found = false; break; - } - break; - case 'g': - case 'm': - case 's': - AdditionalOptions += option; - break; - case 'p': - switch (third) - { - case '\0': - case '1': - StructMemberAlignment = "1Byte"; - if(fourth == '6') - StructMemberAlignment = "16Bytes"; - break; - case '2': - StructMemberAlignment = "2Bytes"; - break; - case '4': - StructMemberAlignment = "4Bytes"; - break; - case '8': - StructMemberAlignment = "8Bytes"; - break; - default: - found = false; break; - } - break; - default: - found = false; break; - } - break; - case 'a': - if (second == 'r' && third == 'c' && fourth == 'h') { - if (option[5] == ':') { - const char *o = option; - if (o[6] == 'S' && o[7] == 'S' && o[8] == 'E') { - EnableEnhancedInstructionSet = o[9] == '2' ? "StreamingSIMDExtensions2" : "StreamingSIMDExtensions"; - break; - } - } - } else if (second == 'n' && third == 'a' && fourth == 'l') { - EnablePREfast = _True; - break; - } - found = false; - break; - case 'b': // see http://msdn.microsoft.com/en-us/library/fwkeyyhe%28VS.100%29.aspx - if (second == 'i' && third == 'g' && fourth == 'o') { - const char *o = option; - if (o[5] == 'b' && o[6] == 'j') { - AdditionalOptions += option; - break; - } - } - found = false; - break; - case 'c': - if(second == 'l') { - if(*(option+5) == 'p') { - CompileAsManaged = "Pure"; - } else if(*(option+5) == 's') { - CompileAsManaged = "Safe"; - } else if(*(option+5) == 'o') { - CompileAsManaged = "OldSyntax"; - } else { - CompileAsManaged = "true"; - } - } else { - found = false; - break; - } - break; - case 'd': - if(second != 'o' && third == 'c') { - GenerateXMLDocumentationFiles = _True; - XMLDocumentationFileName += option+4; - break; - } - found = false; - break; - case 'e': - if (second == 'r' && third == 'r' && fourth == 'o') { - if (option[12] == ':') { - if ( option[13] == 'n') { - ErrorReporting = "None"; - } else if (option[13] == 'p') { - ErrorReporting = "Prompt"; - } else if (option[13] == 'q') { - ErrorReporting = "Queue"; - } else if (option[13] == 's') { - ErrorReporting = "Send"; - } else { - found = false; - } - break; - } - } - found = false; - break; - case 'f': - if(second == 'p' && third == ':') { - // Go to the end of the option - const char *c = option + 4; - while (*c != '\0' && *c != ' ' && *c != '-') - ++c; - switch (fourth) { - case 'e': - FloatingPointExceptions = ((*c) == '-' ? _False : _True); - break; - case 'f': - FloatingPointModel = "Fast"; - break; - case 'p': - FloatingPointModel = "Precise"; - break; - case 's': - FloatingPointModel = "Strict"; - break; - default: - found = false; - break; - } - } - break; - case 'h': - if(second == 'o' && third == 't' && fourth == 'p') { - CreateHotpatchableImage = _True; - break; - } - qWarning("Generator: Option '/help': MSVC.NET projects do not support outputting help info"); - found = false; - break; - case 'n': - if(second == 'o' && third == 'l' && fourth == 'o') { - SuppressStartupBanner = _True; - break; - } - found = false; - break; - case 'o': - if (second == 'p' && third == 'e' && fourth == 'n') { - OpenMPSupport = _True; - break; - } - found = false; - break; - case 's': - if(second == 'h' && third == 'o' && fourth == 'w') { - ShowIncludes = _True; - break; - } - found = false; - break; - case 'u': - UndefineAllPreprocessorDefinitions = _True; - break; - case 'v': - if(second == 'd' || second == 'm') { - AdditionalOptions += option; - break; - } - found = false; - break; - case 'w': - switch (second) { - case 'd': - DisableSpecificWarnings += option+3; - break; - case 'e': - TreatSpecificWarningsAsErrors = option+3; - break; - default: - AdditionalOptions += option; - } - break; - default: - AdditionalOptions += option; - break; - } - if(!found) { - warn_msg(WarnLogic, "Could not parse Compiler option: %s, added as AdditionalOption", option); - AdditionalOptions += option; - } - return true; -} - -// VCLinkerTool ----------------------------------------------------- -VCXLinkerTool::VCXLinkerTool() - : AllowIsolation(unset), - AssemblyDebug(unset), - DataExecutionPrevention(unset), - DelaySign(unset), - EnableCOMDATFolding(unset), - EnableUAC(unset), - FixedBaseAddress(unset), - GenerateDebugInformation(unset), - GenerateManifest(unset), - GenerateMapFile(unset), - HeapCommitSize(-1), - HeapReserveSize(-1), - IgnoreAllDefaultLibraries(unset), - IgnoreEmbeddedIDL(unset), - IgnoreImportLibrary(_True), - ImageHasSafeExceptionHandlers(unset), - LargeAddressAware(unset), - LinkDLL(unset), - LinkIncremental(unset), - LinkStatus(unset), - MapExports(unset), - NoEntryPoint(unset), - OptimizeReferences(unset), - PreventDllBinding(unset), - RandomizedBaseAddress(unset), - RegisterOutput(unset), - SectionAlignment(-1), - SetChecksum(unset), - //StackCommitSize(-1), - //StackReserveSize(-1), - SupportNobindOfDelayLoadedDLL(unset), - SupportUnloadOfDelayLoadedDLL(unset), - SuppressStartupBanner(unset), - SwapRunFromCD(unset), - SwapRunFromNet(unset), - TerminalServerAware(unset), - TreatLinkerWarningAsErrors(unset), - TurnOffAssemblyGeneration(unset), - TypeLibraryResourceID(0), - UACUIAccess(unset) -{ -} - -// Hashing routine to do fast option lookups ---- -// Slightly rewritten to stop on ':' ',' and '\0' -// Original routine in qtranslator.cpp ---------- -static uint elfHash(const char* name) -{ - const uchar *k; - uint h = 0; - uint g; - - if(name) { - k = (const uchar *) name; - while((*k) && - (*k)!= ':' && - (*k)!=',' && - (*k)!=' ') { - h = (h << 4) + *k++; - if((g = (h & 0xf0000000)) != 0) - h ^= g >> 24; - h &= ~g; - } - } - if(!h) - h = 1; - return h; -} - -//#define USE_DISPLAY_HASH -#ifdef USE_DISPLAY_HASH -static void displayHash(const char* str) -{ - printf("case 0x%07x: // %s\n break;\n", elfHash(str), str); -} -#endif - -bool VCXLinkerTool::parseOption(const char* option) -{ -#ifdef USE_DISPLAY_HASH - // Main options - displayHash("/ALIGN"); displayHash("/ALLOWBIND"); displayHash("/ASSEMBLYMODULE"); - displayHash("/ASSEMBLYRESOURCE"); displayHash("/BASE"); displayHash("/DEBUG"); - displayHash("/DEF"); displayHash("/DEFAULTLIB"); displayHash("/DELAY"); - displayHash("/DELAYLOAD"); displayHash("/DLL"); displayHash("/DRIVER"); - displayHash("/ENTRY"); displayHash("/EXETYPE"); displayHash("/EXPORT"); - displayHash("/FIXED"); displayHash("/FORCE"); displayHash("/HEAP"); - displayHash("/IDLOUT"); displayHash("/IGNORE"); displayHash("/IGNOREIDL"); displayHash("/IMPLIB"); - displayHash("/INCLUDE"); displayHash("/INCREMENTAL"); displayHash("/LARGEADDRESSAWARE"); - displayHash("/LIBPATH"); displayHash("/LTCG"); displayHash("/MACHINE"); - displayHash("/MAP"); displayHash("/MAPINFO"); displayHash("/MERGE"); - displayHash("/MIDL"); displayHash("/NOASSEMBLY"); displayHash("/NODEFAULTLIB"); - displayHash("/NOENTRY"); displayHash("/NOLOGO"); displayHash("/OPT"); - displayHash("/ORDER"); displayHash("/OUT"); displayHash("/PDB"); - displayHash("/PDBSTRIPPED"); displayHash("/RELEASE"); displayHash("/SECTION"); - displayHash("/STACK"); displayHash("/STUB"); displayHash("/SUBSYSTEM"); - displayHash("/SWAPRUN"); displayHash("/TLBID"); displayHash("/TLBOUT"); - displayHash("/TSAWARE"); displayHash("/VERBOSE"); displayHash("/VERSION"); - displayHash("/VXD"); displayHash("/WS "); displayHash("/libpath"); - -#endif -#ifdef USE_DISPLAY_HASH - // Sub options - displayHash("UNLOAD"); displayHash("NOBIND"); displayHash("no"); displayHash("NOSTATUS"); displayHash("STATUS"); - displayHash("AM33"); displayHash("ARM"); displayHash("CEE"); displayHash("EBC"); displayHash("IA64"); displayHash("X86"); displayHash("X64"); displayHash("M32R"); - displayHash("MIPS"); displayHash("MIPS16"); displayHash("MIPSFPU"); displayHash("MIPSFPU16"); displayHash("MIPSR41XX"); displayHash("PPC"); - displayHash("SH3"); displayHash("SH3DSP"); displayHash("SH4"); displayHash("SH5"); displayHash("THUMB"); displayHash("TRICORE"); displayHash("EXPORTS"); - displayHash("LINES"); displayHash("REF"); displayHash("NOREF"); displayHash("ICF"); displayHash("WIN98"); displayHash("NOWIN98"); - displayHash("CONSOLE"); displayHash("EFI_APPLICATION"); displayHash("EFI_BOOT_SERVICE_DRIVER"); displayHash("EFI_ROM"); displayHash("EFI_RUNTIME_DRIVER"); displayHash("NATIVE"); - displayHash("POSIX"); displayHash("WINDOWS"); displayHash("WINDOWSCE"); displayHash("NET"); displayHash("CD"); displayHash("NO"); -#endif - bool found = true; - switch (elfHash(option)) { - case 0x6b21972: // /DEFAULTLIB:library - case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386] - case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA] - case 0x3dc3455: // /IGNORE:number,number,number,number ### NOTE: This one is undocumented, but it is even used by Microsoft. - // In recent versions of the Microsoft linker they have disabled this undocumented feature. - case 0x0034bc4: // /VXD - AdditionalOptions += option; - break; - case 0x3360dbe: // /ALIGN[:number] - SectionAlignment = QString(option+7).toLongLong(); - break; - case 0x1485c34: // /ALLOWBIND[:NO] - if(*(option+10) == ':' && (*(option+11) == 'n' || *(option+11) == 'N')) - PreventDllBinding = _False; - else - PreventDllBinding = _True; - break; - case 0x312011e: // /ALLOWISOLATION[:NO] - if(*(option+15) == ':' && (*(option+16) == 'n' || *(option+16) == 'N')) - AllowIsolation = _False; - else - AllowIsolation = _True; - break; - case 0x679c075: // /ASSEMBLYMODULE:filename - AddModuleNamesToAssembly += option+15; - break; - case 0x75f35f7: // /ASSEMBLYDEBUG[:DISABLE] - if(*(option+14) == ':' && (*(option+15) == 'D')) - AssemblyDebug = _False; - else - AssemblyDebug = _True; - break; - case 0x43294a5: // /ASSEMBLYLINKRESOURCE:filename - AssemblyLinkResource += option+22; - break; - case 0x062d065: // /ASSEMBLYRESOURCE:filename - EmbedManagedResourceFile += option+18; - break; - case 0x0336675: // /BASE:{address | @filename,key} - // Do we need to do a manual lookup when '@filename,key'? - // Seems BaseAddress only can contain the location... - // We don't use it in Qt, so keep it simple for now - BaseAddress = option+6; - break; - case 0x63bf065: // /CLRIMAGETYPE:{IJW|PURE|SAFE} - if(*(option+14) == 'I') - CLRImageType = "ForceIJWImage"; - else if(*(option+14) == 'P') - CLRImageType = "ForcePureILImage"; - else if(*(option+14) == 'S') - CLRImageType = "ForceSafeILImage"; - break; - case 0x5f2a6a2: // /CLRSUPPORTLASTERROR{:NO | SYSTEMDLL} - if(*(option+20) == ':') { - if(*(option+21) == 'N') { - CLRSupportLastError = "Disabled"; - } else if(*(option+21) == 'S') { - CLRSupportLastError = "SystemDlls"; - } - } else { - CLRSupportLastError = "Enabled"; - } - break; - case 0xc7984f5: // /CLRTHREADATTRIBUTE:{STA|MTA|NONE} - if(*(option+20) == 'N') - CLRThreadAttribute = "DefaultThreadingAttribute"; - else if(*(option+20) == 'M') - CLRThreadAttribute = "MTAThreadingAttribute"; - else if(*(option+20) == 'S') - CLRThreadAttribute = "STAThreadingAttribute"; - break; - case 0xa8c637b: // /CLRUNMANAGEDCODECHECK[:NO] - if(*(option+23) == 'N') - CLRUnmanagedCodeCheck = _False; - else - CLRUnmanagedCodeCheck = _True; - break; - case 0x3389797: // /DEBUG - GenerateDebugInformation = _True; - break; - case 0x0033896: // /DEF:filename - ModuleDefinitionFile = option+5; - break; - case 0x338a069: // /DELAY:{UNLOAD | NOBIND} - if(*(option+7) == 'U') - SupportNobindOfDelayLoadedDLL = _True; - else if(*(option+7) == 'N') - SupportUnloadOfDelayLoadedDLL = _True; - break; - case 0x06f4bf4: // /DELAYLOAD:dllname - DelayLoadDLLs += option+11; - break; - case 0x06d451e: // /DELAYSIGN[:NO] - if(*(option+10) == ':' && (*(option+11) == 'n' || *(option+11) == 'N')) - DelaySign = _False; - else - DelaySign = _True; - break; - case 0x003390c: // /DLL - LinkDLL = _True; - break; - case 0x396ea92: // /DRIVER[:UPONLY | :WDM] - if((*(option+7) == ':') && (*(option+8) == 'U')) - Driver = "UpOnly"; - else if((*(option+7) == ':') && (*(option+8) == 'W')) - Driver = "WDM"; - else - Driver = "Driver"; - break; - case 0x2ee8415: // /DYNAMICBASE[:NO] - if(*(option+12) == ':' && (*(option+13) == 'n' || *(option+13) == 'N')) - RandomizedBaseAddress = _False; - else - RandomizedBaseAddress = _True; - break; - case 0x33a3979: // /ENTRY:function - EntryPointSymbol = option+7; - break; - case 0x4504334: // /ERRORREPORT:[ NONE | PROMPT | QUEUE | SEND ] - if(*(option+12) == ':' ) { - if(*(option+13) == 'N') - LinkErrorReporting = "NoErrorReport"; - else if(*(option+13) == 'P') - LinkErrorReporting = "PromptImmediately"; - else if(*(option+13) == 'Q') - LinkErrorReporting = "QueueForNextLogin"; - else if(*(option+13) == 'S') - LinkErrorReporting = "SendErrorReport"; - } - break; - case 0x33aec94: // /FIXED[:NO] - if(*(option+6) == ':' && (*(option+7) == 'n' || *(option+7) == 'N')) - FixedBaseAddress = _False; - else - FixedBaseAddress = _True; - break; - case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED] - if(*(option+6) == ':' && *(option+7) == 'M' ) - ForceFileOutput = "MultiplyDefinedSymbolOnly"; - else if(*(option+6) == ':' && *(option+7) == 'U' ) - ForceFileOutput = "UndefinedSymbolOnly"; - else - ForceFileOutput = "Enabled"; - break; - case 0x96d4e4e: // /FUNCTIONPADMIN[:space] - if(*(option+15) == ':') { - if(*(option+16) == '5') - CreateHotPatchableImage = "X86Image"; - else if(*(option+16) == '6') - CreateHotPatchableImage = "X64Image"; - else if((*(option+16) == '1') && (*(option+17) == '6')) - CreateHotPatchableImage = "ItaniumImage"; - } else { - CreateHotPatchableImage = "Enabled"; - } - break; - case 0x033c960: // /HEAP:reserve[,commit] - { - QStringList both = QString(option+6).split(","); - HeapReserveSize = both[0].toLongLong(); - if(both.count() == 2) - HeapCommitSize = both[1].toLongLong(); - } - break; - case 0x3d91494: // /IDLOUT:[path\]filename - MergedIDLBaseFileName = option+8; - break; - case 0x345a04c: // /IGNOREIDL - IgnoreEmbeddedIDL = _True; - break; - case 0x3e250e2: // /IMPLIB:filename - ImportLibrary = option+8; - break; - case 0xe281ab5: // /INCLUDE:symbol - ForceSymbolReferences += option+9; - break; - case 0xb28103c: // /INCREMENTAL[:no] - if(*(option+12) == ':' && - (*(option+13) == 'n' || *(option+13) == 'N')) - LinkIncremental = _False; - else - LinkIncremental = _True; - break; - case 0x07f1ab2: // /KEYCONTAINER:name - KeyContainer = option+14; - break; - case 0xfadaf35: // /KEYFILE:filename - KeyFile = option+9; - break; - case 0x26e4675: // /LARGEADDRESSAWARE[:no] - if(*(option+18) == ':' && - *(option+19) == 'n') - LargeAddressAware = _False; - else - LargeAddressAware = _True; - break; - case 0x2f96bc8: // /libpath:dir - case 0x0d745c8: // /LIBPATH:dir - AdditionalLibraryDirectories += option+9; - break; - case 0x0341877: // /LTCG[:NOSTATUS|:STATUS] - config->WholeProgramOptimization = _True; - LinkTimeCodeGeneration = "UseLinkTimeCodeGeneration"; - if(*(option+5) == ':') { - const char* str = option+6; - if (*str == 'S') - LinkStatus = _True; - else if (*str == 'N') - LinkStatus = _False; -#ifndef Q_OS_WIN - else if (strncasecmp(str, "pginstrument", 12)) - LinkTimeCodeGeneration = "PGInstrument"; - else if (strncasecmp(str, "pgoptimize", 10)) - LinkTimeCodeGeneration = "PGOptimization"; - else if (strncasecmp(str, "pgupdate", 8 )) - LinkTimeCodeGeneration = "PGUpdate"; -#else - - else if (_stricmp(str, "pginstrument")) - LinkTimeCodeGeneration = "PGInstrument"; - else if (_stricmp(str, "pgoptimize")) - LinkTimeCodeGeneration = "PGOptimization"; - else if (_stricmp(str, "pgupdate")) - LinkTimeCodeGeneration = "PGUpdate"; -#endif - } - break; - case 0x379ED25: - case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE} - switch (elfHash(option+9)) { - case 0x0005bb6: // X86 - TargetMachine = "MachineX86"; - break; - case 0x0005b94: // X64 - TargetMachine = "MachineX64"; - break; - case 0x000466d: // ARM - TargetMachine = "MachineARM"; - break; - case 0x0004963: // EBC - TargetMachine = "MachineEBC"; - break; - case 0x004d494: // IA64 - TargetMachine = "MachineIA64"; - break; - case 0x0051e53: // MIPS - TargetMachine = "MachineMIPS"; - break; - case 0x51e5646: // MIPS16 - TargetMachine = "MachineMIPS16"; - break; - case 0x1e57b05: // MIPSFPU - TargetMachine = "MachineMIPSFPU"; - break; - case 0x57b09a6: // MIPSFPU16 - TargetMachine = "MachineMIPSFPU16"; - break; - case 0x00057b4: // SH4 - TargetMachine = "MachineSH4"; - break; - case 0x058da12: // THUMB - TargetMachine = "MachineTHUMB"; - break; - // put the others in AdditionalOptions... - case 0x0046063: // AM33 - case 0x0004795: // CEE - case 0x0050672: // M32R - case 0x5852738: // MIPSR41XX - case 0x0005543: // PPC - case 0x00057b3: // SH3 - case 0x57b7980: // SH3DSP - case 0x00057b5: // SH5 - case 0x96d8435: // TRICORE - default: - AdditionalOptions += option; - break; - } - break; - case 0x62d9e94: // /MANIFEST[:NO] - if ((*(option+9) == ':' && (*(option+10) == 'N' || *(option+10) == 'n'))) - GenerateManifest = _False; - else - GenerateManifest = _True; - break; - case 0x8b64559: // /MANIFESTDEPENDENCY:manifest_dependency - AdditionalManifestDependencies += option+20; - break; - case 0xe9e8195: // /MANIFESTFILE:filename - ManifestFile = option+14; - break; - case 0x9e9fb83: // /MANIFESTUAC http://msdn.microsoft.com/en-us/library/bb384691%28VS.100%29.aspx - if ((*(option+12) == ':' && (*(option+13) == 'N' || *(option+13) == 'n'))) - EnableUAC = _False; - else if((*(option+12) == ':' && (*(option+13) == 'l' || *(option+14) == 'e'))) { // level - if(*(option+20) == 'a') - UACExecutionLevel = "AsInvoker"; - else if(*(option+20) == 'h') - UACExecutionLevel = "HighestAvailable"; - else if(*(option+20) == 'r') - UACExecutionLevel = "RequireAdministrator"; - } else if((*(option+12) == ':' && (*(option+13) == 'u' || *(option+14) == 'i'))) { // uiAccess - if(*(option+22) == 't') - UACUIAccess = _True; - else - UACUIAccess = _False; - } else if((*(option+12) == ':' && (*(option+13) == 'f' || *(option+14) == 'r'))) { // fragment - AdditionalOptions += option; - }else - EnableUAC = _True; - break; - case 0x0034160: // /MAP[:filename] - GenerateMapFile = _True; - MapFileName = option+5; - break; - case 0x164e1ef: // /MAPINFO:{EXPORTS} - if(*(option+9) == 'E') - MapExports = _True; - break; - case 0x341a6b5: // /MERGE:from=to - MergeSections = option+7; - break; - case 0x0341d8c: // /MIDL:@file - MidlCommandFile = option+7; - break; - case 0x84e2679: // /NOASSEMBLY - TurnOffAssemblyGeneration = _True; - break; - case 0x2b21942: // /NODEFAULTLIB[:library] - if(*(option+13) == '\0') - IgnoreAllDefaultLibraries = _True; - else - IgnoreSpecificDefaultLibraries += option+14; - break; - case 0x33a3a39: // /NOENTRY - NoEntryPoint = _True; - break; - case 0x434138f: // /NOLOGO - SuppressStartupBanner = _True; - break; - case 0xc841054: // /NXCOMPAT[:NO] - if ((*(option+9) == ':' && (*(option+10) == 'N' || *(option+10) == 'n'))) - DataExecutionPrevention = _False; - else - DataExecutionPrevention = _True; - break; - case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98} - { - char third = *(option+7); - switch (third) { - case 'F': // REF - if(*(option+5) == 'R') { - OptimizeReferences = _True; - } else { // ICF[=iterations] - EnableCOMDATFolding = _True; - // [=iterations] case is not documented - } - break; - case 'R': // NOREF - OptimizeReferences = _False; - break; - case 'I': // NOICF - EnableCOMDATFolding = _False; - break; - default: - found = false; - } - } - break; - case 0x34468a2: // /ORDER:@filename - FunctionOrder = option+8; - break; - case 0x00344a4: // /OUT:filename - OutputFile = option+5; - break; - case 0x0034482: // /PDB:filename - ProgramDatabaseFile = option+5; - break; - case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name - StripPrivateSymbols = option+13; - break; - case 0x00344b4: // /PGD:filename - ProfileGuidedDatabase = option+5; - break; - case 0x573af45: // /PROFILE - Profile = _True; - break; - case 0x6a09535: // /RELEASE - SetChecksum = _True; - break; - case 0x75AA4D8: // /SAFESEH:{NO} - { - if(*(option+8) == ':' && *(option+9) == 'N') - ImageHasSafeExceptionHandlers = _False; - else - ImageHasSafeExceptionHandlers = _True; - } - break; - case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] - SpecifySectionAttributes = option+9; - break; - case 0x348857b: // /STACK:reserve[,commit] - { - QStringList both = QString(option+7).split(","); - StackReserveSize = both[0].toLongLong(); - if(both.count() == 2) - StackCommitSize = both[1].toLongLong(); - } - break; - case 0x0348992: // /STUB:filename - MSDOSStubFileName = option+6; - break; - case 0x9B3C00D: - case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]] - { - // Split up in subsystem, and version number - QStringList both = QString(option+11).split(","); - switch (elfHash(both[0].toLatin1())) { - case 0x8438445: // CONSOLE - SubSystem = "Console"; - break; - case 0xbe29493: // WINDOWS - SubSystem = "Windows"; - break; - case 0x5268ea5: // NATIVE - SubSystem = "Native"; - break; - case 0x240949e: // EFI_APPLICATION - SubSystem = "EFI Application"; - break; - case 0xe617652: // EFI_BOOT_SERVICE_DRIVER - SubSystem = "EFI Boot Service Driver"; - break; - case 0x9af477d: // EFI_ROM - SubSystem = "EFI ROM"; - break; - case 0xd34df42: // EFI_RUNTIME_DRIVER - SubSystem = "EFI Runtime"; - break; - case 0x2949c95: // WINDOWSCE - SubSystem = "WindowsCE"; - break; - case 0x05547e8: // POSIX - SubSystem = "POSIX"; - break; - // The following are undocumented, so add them to AdditionalOptions - case 0x4B69795: // windowsce - AdditionalOptions += option; - break; - default: - found = false; - } - } - break; - case 0x8b654de: // /SWAPRUN:{NET | CD} - if(*(option+9) == 'N') - SwapRunFromNet = _True; - else if(*(option+9) == 'C') - SwapRunFromCD = _True; - else - found = false; - break; - case 0x34906d4: // /TLBID:id - TypeLibraryResourceID = QString(option+7).toLongLong(); - break; - case 0x4907494: // /TLBOUT:[path\]filename - TypeLibraryFile = option+8; - break; - case 0x976b525: // /TSAWARE[:NO] - if(*(option+8) == ':') - TerminalServerAware = _False; - else - TerminalServerAware = _True; - break; - case 0xaa67735: // /VERBOSE[:ICF |:LIB |:REF |:SAFESEH] - if(*(option+9) == ':') { - if (*(option+10) == 'I') { - ShowProgress = "LinkVerboseICF"; - } else if ( *(option+10) == 'L') { - ShowProgress = "LinkVerboseLib"; - } else if ( *(option+10) == 'R') { - ShowProgress = "LinkVerboseREF"; - } else if ( *(option+10) == 'S') { - ShowProgress = "LinkVerboseSAFESEH"; - } else if ( *(option+10) == 'C') { - ShowProgress = "LinkVerboseCLR"; - } - } else { - ShowProgress = "LinkVerbose"; - } - break; - case 0xaa77f7e: // /VERSION:major[.minor] - Version = option+9; - break; - case 0x0034c50: // /WS[:NO] - if(*(option+3) == ':') - TreatLinkerWarningAsErrors = _False; - else - TreatLinkerWarningAsErrors = _True; - break; - default: - AdditionalOptions += option; - break; - } - if(!found) { - warn_msg(WarnLogic, "Could not parse Linker options: %s, added as AdditionalOption", option); - AdditionalOptions += option; - } - return found; -} - -// VCMIDLTool ------------------------------------------------------- -VCXMIDLTool::VCXMIDLTool() - : ApplicationConfigurationMode(unset), - ErrorCheckAllocations(unset), - ErrorCheckBounds(unset), - ErrorCheckEnumRange(unset), - ErrorCheckRefPointers(unset), - ErrorCheckStubData(unset), - GenerateStublessProxies(unset), - GenerateTypeLibrary(unset), - IgnoreStandardIncludePath(unset), - LocaleID(-1), - MkTypLibCompatible(unset), - SuppressCompilerWarnings(unset), - SuppressStartupBanner(unset), - ValidateAllParameters(unset), - WarnAsError(unset) -{ -} - -bool VCXMIDLTool::parseOption(const char* option) -{ -#ifdef USE_DISPLAY_HASH - displayHash("/D name[=def]"); displayHash("/I directory-list"); displayHash("/Oi"); - displayHash("/Oic"); displayHash("/Oicf"); displayHash("/Oif"); displayHash("/Os"); - displayHash("/U name"); displayHash("/WX"); displayHash("/W{0|1|2|3|4}"); - displayHash("/Zp {N}"); displayHash("/Zs"); displayHash("/acf filename"); - displayHash("/align {N}"); displayHash("/app_config"); displayHash("/c_ext"); - displayHash("/char ascii7"); displayHash("/char signed"); displayHash("/char unsigned"); - displayHash("/client none"); displayHash("/client stub"); displayHash("/confirm"); - displayHash("/cpp_cmd cmd_line"); displayHash("/cpp_opt options"); - displayHash("/cstub filename"); displayHash("/dlldata filename"); displayHash("/env win32"); - displayHash("/env win64"); displayHash("/error all"); displayHash("/error allocation"); - displayHash("/error bounds_check"); displayHash("/error enum"); displayHash("/error none"); - displayHash("/error ref"); displayHash("/error stub_data"); displayHash("/h filename"); - displayHash("/header filename"); displayHash("/iid filename"); displayHash("/lcid"); - displayHash("/mktyplib203"); displayHash("/ms_ext"); displayHash("/ms_union"); - displayHash("/msc_ver "); displayHash("/newtlb"); displayHash("/no_cpp"); - displayHash("/no_def_idir"); displayHash("/no_default_epv"); displayHash("/no_format_opt"); - displayHash("/no_warn"); displayHash("/nocpp"); displayHash("/nologo"); displayHash("/notlb"); - displayHash("/o filename"); displayHash("/oldnames"); displayHash("/oldtlb"); - displayHash("/osf"); displayHash("/out directory"); displayHash("/pack {N}"); - displayHash("/prefix all"); displayHash("/prefix client"); displayHash("/prefix server"); - displayHash("/prefix switch"); displayHash("/protocol all"); displayHash("/protocol dce"); - displayHash("/protocol ndr64"); displayHash("/proxy filename"); displayHash("/robust"); - displayHash("/rpcss"); displayHash("/savePP"); displayHash("/server none"); - displayHash("/server stub"); displayHash("/sstub filename"); displayHash("/syntax_check"); - displayHash("/target {system}"); displayHash("/tlb filename"); displayHash("/use_epv"); - displayHash("/win32"); displayHash("/win64"); -#endif - bool found = true; - int offset = 0; - switch(elfHash(option)) { - case 0x0000334: // /D name[=def] - PreprocessorDefinitions += option+3; - break; - case 0x0000339: // /I directory-list - AdditionalIncludeDirectories += option+3; - break; - case 0x0345f96: // /Oicf - case 0x00345f6: // /Oif - GenerateStublessProxies = _True; - break; - case 0x0000345: // /U name - UndefinePreprocessorDefinitions += option+3; - break; - case 0x00034c8: // /WX - WarnAsError = _True; - break; - case 0x3582fde: // /align {N} - offset = 3; // Fallthrough - case 0x0003510: // /Zp {N} - switch (*(option+offset+4)) { - case '1': - StructMemberAlignment = (*(option+offset+5) == '\0') ? "1" : "16"; - break; - case '2': - StructMemberAlignment = "2"; - break; - case '4': - StructMemberAlignment = "4"; - break; - case '8': - StructMemberAlignment = "8"; - break; - default: - found = false; - } - break; - case 0x5b1cb97: // /app_config - ApplicationConfigurationMode = _True; - break; - case 0x0359e82: // /char {ascii7|signed|unsigned} - switch(*(option+6)) { - case 'a': - DefaultCharType = "Ascii"; - break; - case 's': - DefaultCharType = "Signed"; - break; - case 'u': - DefaultCharType = "Unsigned"; - break; - default: - found = false; - } - break; - case 0x5a2fc64: // /client {none|stub} - if(*(option+8) == 's') - GenerateClientFiles = "Stub"; - else - GenerateClientFiles = "None"; - break; - case 0xa766524: // /cpp_opt options - CPreprocessOptions += option+9; - break; - case 0x35aabb2: // /cstub filename - ClientStubFile = option+7; - break; - case 0xb32abf1: // /dlldata filename - DLLDataFileName = option + 9; - break; - case 0x0035c56: // /env {win32|ia64|x64} - if(*(option+7) == 'w' && *(option+10) == '3') - TargetEnvironment = "Win32"; - else if(*(option+7) == 'i') - TargetEnvironment = "Itanium"; - else if(*(option+7) == 'x') - TargetEnvironment = "X64"; - else - AdditionalOptions += option; - break; - case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data} - EnableErrorChecks = midlEnableCustom; - switch (*(option+7)) { - case '\0': - EnableErrorChecks = "EnableCustom"; - break; - case 'a': - if(*(option+10) == '\0') - EnableErrorChecks = "All"; - else - ErrorCheckAllocations = _True; - break; - case 'b': - ErrorCheckBounds = _True; - break; - case 'e': - ErrorCheckEnumRange = _True; - break; - case 'n': - EnableErrorChecks = "None"; - break; - case 'r': - ErrorCheckRefPointers = _True; - break; - case 's': - ErrorCheckStubData = _True; - break; - default: - found = false; - } - break; - case 0x5eb7af2: // /header filename - offset = 5; - case 0x0000358: // /h filename - HeaderFileName = option + offset + 3; - break; - case 0x0035ff4: // /iid filename - InterfaceIdentifierFileName = option+5; - break; - case 0x64b7933: // /mktyplib203 - MkTypLibCompatible = _True; - break; - case 0x64ceb12: // /newtlb - TypeLibFormat = "NewFormat"; - break; - case 0x8e0b0a2: // /no_def_idir - IgnoreStandardIncludePath = _True; - break; - case 0x65635ef: // /nologo - SuppressStartupBanner = _True; - break; - case 0x695e9f4: // /no_robust - ValidateAllParameters = _False; - break; - case 0x3656b22: // /notlb - GenerateTypeLibrary = _True; - break; - case 0x556dbee: // /no_warn - SuppressCompilerWarnings = _True; - break; - case 0x000035f: // /o filename - RedirectOutputAndErrors = option+3; - break; - case 0x662bb12: // /oldtlb - TypeLibFormat = "OldFormat"; - break; - case 0x00366c4: // /out directory - OutputDirectory = option+5; - break; - case 0x36796f9: // /proxy filename - ProxyFileName = option+7; - break; - case 0x6959c94: // /robust - ValidateAllParameters = _True; - break; - case 0x69c9cf2: // /server {none|stub} - if(*(option+8) == 's') - GenerateServerFiles = "Stub"; - else - GenerateServerFiles = "None"; - break; - case 0x36aabb2: // /sstub filename - ServerStubFile = option+7; - break; - case 0x0036b22: // /tlb filename - TypeLibraryName = option+5; - break; - case 0x36e0162: // /win32 - TargetEnvironment = "Win32"; - break; - case 0x36e0194: // /win64 - TargetEnvironment = "Itanium"; - break; - case 0x0003459: // /Oi - case 0x00345f3: // /Oic - case 0x0003463: // /Os - case 0x0003513: // /Zs - case 0x0035796: // /acf filename - case 0x3595cf4: // /c_ext - case 0xa64d3dd: // /confirm - case 0xa765b64: // /cpp_cmd cmd_line - case 0x03629f4: // /lcid - case 0x6495cc4: // /ms_ext - case 0x96c7a1e: // /ms_union - case 0x4996fa2: // /msc_ver - case 0x6555a40: // /no_cpp - case 0xf64d6a6: // /no_default_epv - case 0x6dd9384: // /no_format_opt - case 0x3655a70: // /nocpp - case 0x2b455a3: // /oldnames - case 0x0036696: // /osf - case 0x036679b: // /pack {N} - case 0x678bd38: // /prefix {all|client|server|switch} - case 0x96b702c: // /protocol {all|dce|ndr64} - case 0x3696aa3: // /rpcss - case 0x698ca60: // /savePP - case 0xce9b12b: // /syntax_check - case 0xc9b5f16: // /use_epv - AdditionalOptions += option; - break; - default: - // /W{0|1|2|3|4} case - if(*(option+1) == 'W') { - switch (*(option+2)) { - case '0': - WarningLevel = "0"; - break; - case '1': - WarningLevel = "1"; - break; - case '2': - WarningLevel = "2"; - break; - case '3': - WarningLevel = "3"; - break; - case '4': - WarningLevel = "4"; - break; - default: - found = false; - } - } - break; - } - if(!found) - warn_msg(WarnLogic, "Could not parse MIDL option: %s", option); - return true; -} - -// VCLibrarianTool -------------------------------------------------- -VCXLibrarianTool::VCXLibrarianTool() - : IgnoreAllDefaultLibraries(unset), - LinkTimeCodeGeneration(unset), - SuppressStartupBanner(_True), - TreatLibWarningAsErrors(unset), - Verbose(unset) -{ -} - -// VCCustomBuildTool ------------------------------------------------ -VCXCustomBuildTool::VCXCustomBuildTool() -{ - ToolName = "VCXCustomBuildTool"; -} - -// VCResourceCompilerTool ------------------------------------------- -VCXResourceCompilerTool::VCXResourceCompilerTool() - : IgnoreStandardIncludePath(unset), - NullTerminateStrings(unset), - ShowProgress(unset), - SuppressStartupBanner(unset) -{ - PreprocessorDefinitions = QStringList("NDEBUG"); -} - -// VCXDeploymentTool -------------------------------------------- -VCXDeploymentTool::VCXDeploymentTool() -{ - DeploymentTag = "DeploymentTool"; - RemoteDirectory = ""; -} - -// VCXPostBuildEventTool --------------------------------------------- -VCXPostBuildEventTool::VCXPostBuildEventTool() -{ - EventName = "PostBuildEvent"; -} - -// VCXPreBuildEventTool ---------------------------------------------- -VCXPreBuildEventTool::VCXPreBuildEventTool() -{ - EventName = "PreBuildEvent"; -} - -// VCXPreLinkEventTool ----------------------------------------------- -VCXPreLinkEventTool::VCXPreLinkEventTool() -{ - EventName = "PreLinkEvent"; -} - -// VCConfiguration -------------------------------------------------- - -VCXConfiguration::VCXConfiguration() - : ATLMinimizesCRunTimeLibraryUsage(unset), - BuildBrowserInformation(unset), - RegisterOutput(unset), - WholeProgramOptimization(unset) -{ - compiler.config = this; - linker.config = this; - idl.config = this; -} - -// VCXFilter --------------------------------------------------------- -VCXFilter::VCXFilter() - : ParseFiles(unset), - Config(0) -{ - useCustomBuildTool = false; - useCompilerTool = false; -} - -void VCXFilter::addFile(const QString& filename) -{ - Files += VCXFilterFile(filename); -} - -void VCXFilter::addFile(const VCXFilterFile& fileInfo) -{ - Files += VCXFilterFile(fileInfo); -} - -void VCXFilter::addFiles(const QStringList& fileList) -{ - for (int i = 0; i < fileList.count(); ++i) - addFile(fileList.at(i)); -} - -void VCXFilter::modifyPCHstage(QString str) -{ - bool autogenSourceFile = Project->autogenPrecompCPP; - bool pchThroughSourceFile = !Project->precompCPP.isEmpty(); - bool isCFile = false; - for (QStringList::Iterator it = Option::c_ext.begin(); it != Option::c_ext.end(); ++it) { - if (str.endsWith(*it)) { - isCFile = true; - break; - } - } - bool isHFile = str.endsWith(".h") && (str == Project->precompH); - bool isCPPFile = pchThroughSourceFile && (str == Project->precompCPP); - - if(!isCFile && !isHFile && !isCPPFile) - return; - - if(isHFile && pchThroughSourceFile) { - if (autogenSourceFile) { - useCustomBuildTool = true; - QString toFile(Project->precompCPP); - CustomBuildTool.Description = "Generating precompiled header source file '" + toFile + "' ..."; - CustomBuildTool.Outputs += toFile; - - QStringList lines; - CustomBuildTool.CommandLine += - "echo /*-------------------------------------------------------------------- >" + toFile; - lines << "* Precompiled header source file used by Visual Studio.NET to generate"; - lines << "* the .pch file."; - lines << "*"; - lines << "* Due to issues with the dependencies checker within the IDE, it"; - lines << "* sometimes fails to recompile the PCH file, if we force the IDE to"; - lines << "* create the PCH file directly from the header file."; - lines << "*"; - lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was"; - lines << "* specified, and is used as the common stdafx.cpp. The file is only"; - lines << "* generated when creating .vcxproj project files, and is not used for"; - lines << "* command line compilations by nmake."; - lines << "*"; - lines << "* WARNING: All changes made in this file will be lost."; - lines << "--------------------------------------------------------------------*/"; - lines << "#include \"" + Project->precompHFilename + "\""; - foreach(QString line, lines) - CustomBuildTool.CommandLine += "echo " + line + ">>" + toFile; - } - return; - } - - useCompilerTool = true; - // Setup PCH options - CompilerTool.PrecompiledHeader = (isCFile ? "NotUsing" : "Create" ); - CompilerTool.PrecompiledHeaderFile = (isCPPFile ? QString("$(INHERIT)") : QString("$(NOINHERIT)")); - CompilerTool.ForcedIncludeFiles = QStringList("$(NOINHERIT)"); -} - -bool VCXFilter::addExtraCompiler(const VCXFilterFile &info) -{ - const QStringList &extraCompilers = Project->extraCompilerSources.value(info.file); - if (extraCompilers.isEmpty()) - return false; - - QString inFile = info.file; - - // is the extracompiler rule on a file with a built in compiler? - const QStringList &objectMappedFile = Project->extraCompilerOutputs[inFile]; - bool hasBuiltIn = false; - if (!objectMappedFile.isEmpty()) { - hasBuiltIn = Project->hasBuiltinCompiler(objectMappedFile.at(0)); -// qDebug("*** Extra compiler file has object mapped file '%s' => '%s'", qPrintable(inFile), qPrintable(objectMappedFile.join(" "))); - } - - CustomBuildTool.AdditionalDependencies.clear(); - CustomBuildTool.CommandLine.clear(); - CustomBuildTool.Description.clear(); - CustomBuildTool.Outputs.clear(); - CustomBuildTool.ToolPath.clear(); - CustomBuildTool.ToolName = QLatin1String(_VCCustomBuildTool); - - for (int x = 0; x < extraCompilers.count(); ++x) { - const QString &extraCompilerName = extraCompilers.at(x); - - if (!Project->verifyExtraCompiler(extraCompilerName, inFile) && !hasBuiltIn) - continue; - - // All information about the extra compiler - QString tmp_out = Project->project->first(extraCompilerName + ".output"); - QString tmp_cmd = Project->project->variables()[extraCompilerName + ".commands"].join(" "); - QString tmp_cmd_name = Project->project->variables()[extraCompilerName + ".name"].join(" "); - QStringList tmp_dep = Project->project->variables()[extraCompilerName + ".depends"]; - QString tmp_dep_cmd = Project->project->variables()[extraCompilerName + ".depend_command"].join(" "); - QStringList vars = Project->project->variables()[extraCompilerName + ".variables"]; - QStringList configs = Project->project->variables()[extraCompilerName + ".CONFIG"]; - bool combined = configs.indexOf("combine") != -1; - - QString cmd, cmd_name, out; - QStringList deps, inputs; - // Variabel replacement of output name - out = Option::fixPathToTargetOS( - Project->replaceExtraCompilerVariables(tmp_out, inFile, QString()), - false); - - // If file has built-in compiler, we've swapped the input and output of - // the command, as we in Visual Studio cannot have a Custom Buildstep on - // a file which uses a built-in compiler. We would in this case only get - // the result from the extra compiler. If 'hasBuiltIn' is true, we know - // that we're actually on the _output_file_ of the result, and we - // therefore swap inFile and out below, since the extra-compiler still - // must see it as the original way. If the result also has a built-in - // compiler, too bad.. - if (hasBuiltIn) { - out = inFile; - inFile = objectMappedFile.at(0); - } - - // Dependency for the output - if(!tmp_dep.isEmpty()) - deps = tmp_dep; - if(!tmp_dep_cmd.isEmpty()) { - // Execute dependency command, and add every line as a dep - char buff[256]; - QString dep_cmd = Project->replaceExtraCompilerVariables(tmp_dep_cmd, Option::fixPathToLocalOS(inFile, true, false), out); - if(Project->canExecute(dep_cmd)) { - if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) { - QString indeps; - while(!feof(proc)) { - int read_in = (int)fread(buff, 1, 255, proc); - if(!read_in) - break; - indeps += QByteArray(buff, read_in); - } - QT_PCLOSE(proc); - if(!indeps.isEmpty()) { - QStringList extradeps = indeps.split(QLatin1Char('\n')); - for (int i = 0; i < extradeps.count(); ++i) { - QString dd = extradeps.at(i).simplified(); - if (!dd.isEmpty()) - deps += Project->fileFixify(dd); - } - } - } - } - } - for (int i = 0; i < deps.count(); ++i) - deps[i] = Option::fixPathToTargetOS( - Project->replaceExtraCompilerVariables(deps.at(i), inFile, out), - false).trimmed(); - // Command for file - if (combined) { - // Add dependencies for each file - QStringList tmp_in = Project->project->variables()[extraCompilerName + ".input"]; - for (int a = 0; a < tmp_in.count(); ++a) { - const QStringList &files = Project->project->variables()[tmp_in.at(a)]; - for (int b = 0; b < files.count(); ++b) { - deps += Project->findDependencies(files.at(b)); - inputs += Option::fixPathToTargetOS(files.at(b), false); - } - } - deps += inputs; // input files themselves too.. - - // Replace variables for command w/all input files - // ### join gives path issues with directories containing spaces! - cmd = Project->replaceExtraCompilerVariables(tmp_cmd, - inputs.join(" "), - out); - } else { - deps += inFile; // input file itself too.. - cmd = Project->replaceExtraCompilerVariables(tmp_cmd, - inFile, - out); - } - // Name for command - if(!tmp_cmd_name.isEmpty()) { - cmd_name = Project->replaceExtraCompilerVariables(tmp_cmd_name, inFile, out); - } else { - int space = cmd.indexOf(' '); - if(space != -1) - cmd_name = cmd.left(space); - else - cmd_name = cmd; - if((cmd_name[0] == '\'' || cmd_name[0] == '"') && - cmd_name[0] == cmd_name[cmd_name.length()-1]) - cmd_name = cmd_name.mid(1,cmd_name.length()-2); - } - - // Fixify paths - for (int i = 0; i < deps.count(); ++i) - deps[i] = Option::fixPathToTargetOS(deps[i], false); - - - // Output in info.additionalFile ----------- - if (!CustomBuildTool.Description.isEmpty()) - CustomBuildTool.Description += " & "; - CustomBuildTool.Description += cmd_name; - CustomBuildTool.CommandLine += cmd.trimmed().split("\n", QString::SkipEmptyParts); - int space = cmd.indexOf(' '); - QFileInfo finf(cmd.left(space)); - if (CustomBuildTool.ToolPath.isEmpty()) - CustomBuildTool.ToolPath += Option::fixPathToTargetOS(finf.path()); - CustomBuildTool.Outputs += out; - - deps += CustomBuildTool.AdditionalDependencies; - deps += cmd.left(cmd.indexOf(' ')); - // Make sure that all deps are only once - QMap uniqDeps; - for (int c = 0; c < deps.count(); ++c) { - QString aDep = deps.at(c).trimmed(); - if (!aDep.isEmpty()) - uniqDeps[aDep] = false; - } - CustomBuildTool.AdditionalDependencies = uniqDeps.keys(); - } - - // Ensure that none of the output files are also dependencies. Or else, the custom buildstep - // will be rebuild every time, even if nothing has changed. - foreach(QString output, CustomBuildTool.Outputs) { - CustomBuildTool.AdditionalDependencies.removeAll(output); - } - - useCustomBuildTool = !CustomBuildTool.CommandLine.isEmpty(); - return useCustomBuildTool; -} - -// VCXProjectSingleConfig -------------------------------------------- -VCXFilter nullVCXFilter; -VCXFilter& VCXProjectSingleConfig::filterForExtraCompiler(const QString &compilerName) -{ - for (int i = 0; i < ExtraCompilersFiles.count(); ++i) - if (ExtraCompilersFiles.at(i).Name == compilerName) - return ExtraCompilersFiles[i]; - return nullVCXFilter; -} - // Tree file generation --------------------------------------------- -void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &tool, const QString &filter) { +void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter) { if (children.size()) { // Filter @@ -2181,7 +343,7 @@ void XTreeNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString // Flat file generation --------------------------------------------- -void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCXProject &tool, const QString &filter) { +void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &/*tagName*/, VCProject &tool, const QString &filter) { if (children.size()) { ChildrenMapFlat::ConstIterator it = children.constBegin(); ChildrenMapFlat::ConstIterator end = children.constEnd(); @@ -2195,7 +357,7 @@ void XFlatNode::generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString } } -void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) +void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) { xml.setIndentString(" "); @@ -2262,10 +424,10 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) << valueTag(tool.Configuration.IntermediateDirectory); } - if ( !tool.Configuration.TargetName.isEmpty() ) { + if ( !tool.Configuration.PrimaryOutput.isEmpty() ) { xml<< tag("TargetName") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTag(tool.Configuration.TargetName); + << valueTag(tool.Configuration.PrimaryOutput); } if ( tool.Configuration.linker.IgnoreImportLibrary != unset) { @@ -2274,31 +436,32 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) << valueTagT(tool.Configuration.linker.IgnoreImportLibrary); } - if ( tool.Configuration.linker.LinkIncremental != unset) { + if ( tool.Configuration.linker.LinkIncremental != linkIncrementalDefault) { + const triState ts = (tool.Configuration.linker.LinkIncremental == linkIncrementalYes ? _True : _False); xml<< tag("LinkIncremental") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.linker.LinkIncremental); + << valueTagT(ts); } - if ( tool.Configuration.preBuild.UseInBuild != unset ) + if ( tool.Configuration.preBuild.ExcludedFromBuild != unset ) { xml<< tag("PreBuildEventUseInBuild") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.preBuild.UseInBuild); + << valueTagT(!tool.Configuration.preBuild.ExcludedFromBuild); } - if ( tool.Configuration.preLink.UseInBuild != unset ) + if ( tool.Configuration.preLink.ExcludedFromBuild != unset ) { xml<< tag("PreLinkEventUseInBuild") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.preLink.UseInBuild); + << valueTagT(!tool.Configuration.preLink.ExcludedFromBuild); } - if ( tool.Configuration.postBuild.UseInBuild != unset ) + if ( tool.Configuration.postBuild.ExcludedFromBuild != unset ) { xml<< tag("PostBuildEventUseInBuild") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Configuration.Name)) - << valueTagT(tool.Configuration.postBuild.UseInBuild); + << valueTagT(!tool.Configuration.postBuild.ExcludedFromBuild); } xml << closetag(); @@ -2318,15 +481,15 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) write(xml, tool.Configuration.resource); // Post build event - if ( tool.Configuration.postBuild.UseInBuild != unset ) + if ( tool.Configuration.postBuild.ExcludedFromBuild != unset ) write(xml, tool.Configuration.postBuild); // Pre build event - if ( tool.Configuration.preBuild.UseInBuild != unset ) + if ( tool.Configuration.preBuild.ExcludedFromBuild != unset ) write(xml, tool.Configuration.preBuild); // Pre link event - if ( tool.Configuration.preLink.UseInBuild != unset ) + if ( tool.Configuration.preLink.ExcludedFromBuild != unset ) write(xml, tool.Configuration.preLink); xml << closetag(); @@ -2346,7 +509,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) xmlFilter << tag("ItemGroup"); - VCXProject tempProj; + VCProject tempProj; tempProj.SingleProjects += tool; addFilters(tempProj, xmlFilter, "Form Files"); @@ -2377,7 +540,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProjectSingleConfig &tool) << closetag(); } -void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) +void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) { if (tool.SingleProjects.count() == 0) { warn_msg(WarnLogic, "Generator: .NET: no single project in merge project, no output"); @@ -2452,10 +615,10 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) << valueTag(tool.SingleProjects.at(i).Configuration.IntermediateDirectory); } - if ( !tool.SingleProjects.at(i).Configuration.TargetName.isEmpty() ) { + if ( !tool.SingleProjects.at(i).Configuration.PrimaryOutput.isEmpty() ) { xml << tag("TargetName") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTag(tool.SingleProjects.at(i).Configuration.TargetName); + << valueTag(tool.SingleProjects.at(i).Configuration.PrimaryOutput); } if ( tool.SingleProjects.at(i).Configuration.linker.IgnoreImportLibrary != unset) { @@ -2465,30 +628,31 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) } if ( tool.SingleProjects.at(i).Configuration.linker.LinkIncremental != unset) { + const triState ts = (tool.SingleProjects.at(i).Configuration.linker.LinkIncremental == linkIncrementalYes ? _True : _False); xml << tag("LinkIncremental") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTagT(tool.SingleProjects.at(i).Configuration.linker.LinkIncremental); + << valueTagT(ts); } - if ( tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild != unset ) + if ( tool.SingleProjects.at(i).Configuration.preBuild.ExcludedFromBuild != unset ) { xml << tag("PreBuildEventUseInBuild") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTagT(tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild); + << valueTagT(!tool.SingleProjects.at(i).Configuration.preBuild.ExcludedFromBuild); } - if ( tool.SingleProjects.at(i).Configuration.preLink.UseInBuild != unset ) + if ( tool.SingleProjects.at(i).Configuration.preLink.ExcludedFromBuild != unset ) { xml << tag("PreLinkEventUseInBuild") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTagT(tool.SingleProjects.at(i).Configuration.preLink.UseInBuild); + << valueTagT(!tool.SingleProjects.at(i).Configuration.preLink.ExcludedFromBuild); } - if ( tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild != unset ) + if ( tool.SingleProjects.at(i).Configuration.postBuild.ExcludedFromBuild != unset ) { xml << tag("PostBuildEventUseInBuild") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.SingleProjects.at(i).Configuration.Name)) - << valueTagT(tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild); + << valueTagT(!tool.SingleProjects.at(i).Configuration.postBuild.ExcludedFromBuild); } } xml << closetag(); @@ -2510,15 +674,15 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) write(xml, tool.SingleProjects.at(i).Configuration.resource); // Post build event - if ( tool.SingleProjects.at(i).Configuration.postBuild.UseInBuild != unset ) + if ( tool.SingleProjects.at(i).Configuration.postBuild.ExcludedFromBuild != unset ) write(xml, tool.SingleProjects.at(i).Configuration.postBuild); // Pre build event - if ( tool.SingleProjects.at(i).Configuration.preBuild.UseInBuild != unset ) + if ( tool.SingleProjects.at(i).Configuration.preBuild.ExcludedFromBuild != unset ) write(xml, tool.SingleProjects.at(i).Configuration.preBuild); // Pre link event - if ( tool.SingleProjects.at(i).Configuration.preLink.UseInBuild != unset ) + if ( tool.SingleProjects.at(i).Configuration.preLink.ExcludedFromBuild != unset ) write(xml, tool.SingleProjects.at(i).Configuration.preLink); xml << closetag(); @@ -2568,83 +732,570 @@ void VCXProjectWriter::write(XmlOutput &xml, VCXProject &tool) << closetag(); } -void VCXProjectWriter::write(XmlOutput &xml, const VCXCLCompilerTool &tool) +static inline QString toString(asmListingOption option) +{ + switch (option) { + case asmListingAsmMachine: + return "AssemblyAndMachineCode"; + case asmListingAsmMachineSrc: + return "All"; + case asmListingAsmSrc: + return "AssemblyAndSourceCode"; + case asmListingAssemblyOnly: + return "AssemblyCode"; + } + return QString(); +} + +static inline QString toString(basicRuntimeCheckOption option) +{ + switch (option) { + case runtimeBasicCheckNone: + return ""; + case runtimeCheckStackFrame: + return "StackFrameRuntimeCheck"; + case runtimeCheckUninitVariables: + return "UninitializedLocalUsageCheck"; + case runtimeBasicCheckAll: + return "EnableFastChecks"; + } + return QString(); +} + +static inline QString toString(callingConventionOption option) +{ + switch (option) { + case callConventionCDecl: + return "Cdecl"; + case callConventionFastCall: + return "FastCall"; + case callConventionStdCall: + return "StdCall"; + } + return QString(); +} + +static inline QString toString(CompileAsOptions option) +{ + switch (option) { + case compileAsC: + return "CompileAsC"; + case compileAsCPlusPlus: + return "CompileAsCpp"; + } + return QString(); +} + +static inline QString toString(compileAsManagedOptions option) +{ + switch (option) { + case managedAssembly: + return "true"; + case managedAssemblyPure: + return "Safe"; + case managedAssemblyOldSyntax: + return "OldSyntax"; + } + return QString(); +} + +static inline QString toString(debugOption option) +{ + switch (option) { + case debugOldStyleInfo: + return "OldStyle"; + case debugEditAndContinue: + return "EditAndContinue"; + case debugEnabled: + return "ProgramDatabase"; + } + return QString(); +} + +static inline QString toString(enhancedInstructionSetOption option) +{ + switch (option) { + case archSSE: + return "StreamingSIMDExtensions"; + case archSSE2: + return "StreamingSIMDExtensions2"; + } + return QString(); +} + +static inline QString toString(exceptionHandling option) +{ + switch (option) { + case ehNone: + return "false"; + case ehNoSEH: + return "Sync"; + case ehSEH: + return "Async"; + } + return QString(); +} + +static inline QString toString(favorSizeOrSpeedOption option) +{ + switch (option) { + case favorSize: + return "Size"; + case favorSpeed: + return "Speed"; + } + return QString(); +} + +static inline QString toString(floatingPointModel option) +{ + switch (option) { + case floatingPointFast: + return "Fast"; + case floatingPointPrecise: + return "Precise"; + case floatingPointStrict: + return "Strict"; + } + return QString(); +} + +static inline QString toString(inlineExpansionOption option) +{ + switch (option) { + case expandDisable: + return "Disabled"; + case expandOnlyInline: + return "OnlyExplicitInline"; + case expandAnySuitable: + return "AnySuitable"; + } + return QString(); +} + +static inline QString toString(optimizeOption option) +{ + switch (option) { + case optimizeMinSpace: + return "MinSpace"; + case optimizeMaxSpeed: + return "MaxSpeed"; + } + return QString(); +} + +static inline QString toString(pchOption option) +{ + switch (option) { + case pchNone: + return "NotUsing"; + case pchCreateUsingSpecific: + return "Create"; + case pchUseUsingSpecific: + return "Use"; + } + return QString(); +} + +static inline QString toString(runtimeLibraryOption option) +{ + switch (option) { + case rtMultiThreaded: + return "MultiThreaded"; + case rtMultiThreadedDLL: + return "MultiThreadedDLL"; + case rtMultiThreadedDebug: + return "MultiThreadedDebug"; + case rtMultiThreadedDebugDLL: + return "MultiThreadedDebugDLL"; + } + return QString(); +} + +static inline QString toString(structMemberAlignOption option) +{ + switch (option) { + case alignSingleByte: + return "1Byte"; + case alignTwoBytes: + return "2Bytes"; + case alignFourBytes: + return "4Bytes"; + case alignEightBytes: + return "8Bytes"; + case alignSixteenBytes: + return "16Bytes"; + } + return QString(); +} + +static inline QString toString(warningLevelOption option) +{ + switch (option) { + case warningLevel_0: + return "TurnOffAllWarnings"; + case warningLevel_1: + return "Level1"; + case warningLevel_2: + return "Level2"; + case warningLevel_3: + return "Level3"; + case warningLevel_4: + return "Level4"; + } + return QString(); +} + +static inline QString toString(optLinkTimeCodeGenType option) +{ + switch (option) { + case optLTCGEnabled: + return "UseLinkTimeCodeGeneration"; + case optLTCGInstrument: + return "PGInstrument"; + case optLTCGOptimize: + return "PGOptimization"; + case optLTCGUpdate: + return "PGUpdate"; + } + return QString(); +} + +static inline QString toString(subSystemOption option) +{ + switch (option) { + case subSystemConsole: + return "Console"; + case subSystemWindows: + return "Windows"; + case optLTCGOptimize: + return "PGOptimization"; + case optLTCGUpdate: + return "PGUpdate"; + } + return QString(); +} + +static inline QString toString(machineTypeOption option) +{ + switch (option) { + case machineX86: + return "MachineX86"; + case machineX64: + return "MachineX64"; + } + return QString(); +} + +static inline QString toString(midlCharOption option) +{ + switch (option) { + case midlCharUnsigned: + return "Unsigned"; + case midlCharSigned: + return "Signed"; + case midlCharAscii7: + return "Ascii"; + } + return QString(); +} + +static inline QString toString(midlErrorCheckOption option) +{ + switch (option) { + case midlDisableAll: + return "None"; + case midlEnableAll: + return "All"; + } + return QString(); +} + +static inline QString toString(midlStructMemberAlignOption option) +{ + switch (option) { + case midlAlignSingleByte: + return "1"; + case midlAlignTwoBytes: + return "2"; + case midlAlignFourBytes: + return "4"; + case midlAlignEightBytes: + return "8"; + case midlAlignSixteenBytes: + return "16"; + } + return QString(); +} + +static inline QString toString(midlTargetEnvironment option) +{ + switch (option) { + case midlTargetWin32: + return "Win32"; + case midlTargetWin64: + return "X64"; + } + return QString(); +} + +static inline QString toString(midlWarningLevelOption option) +{ + switch (option) { + case midlWarningLevel_0: + return "0"; + case midlWarningLevel_1: + return "1"; + case midlWarningLevel_2: + return "2"; + case midlWarningLevel_3: + return "3"; + case midlWarningLevel_4: + return "4"; + } + return QString(); +} + +static inline QString toString(enumResourceLangID option) +{ + if (option == 0) + return QString(); + else + return QString::number(qlonglong(option)); +} + +static inline QString toString(charSet option) +{ + switch (option) { + case charSetNotSet: + return "NotSet"; + case charSetUnicode: + return "Unicode"; + case charSetMBCS: + return "MultiByte"; + } + return QString(); +} + +static inline QString toString(ConfigurationTypes option) +{ + switch (option) { + case typeApplication: + return "Application"; + case typeDynamicLibrary: + return "DynamicLibrary"; + case typeStaticLibrary: + return "StaticLibrary"; + } + return QString(); +} + +static inline QString toString(useOfATL option) +{ + switch (option) { + case useATLStatic: + return "Static"; + case useATLDynamic: + return "Dynamic"; + } + return QString(); +} + +static inline QString toString(useOfMfc option) +{ + switch (option) { + case useMfcStatic: + return "Static"; + case useMfcDynamic: + return "Dynamic"; + } + return QString(); +} + +static inline triState toTriState(browseInfoOption option) +{ + switch (option) + { + case brInfoNone: + return _False; + case brAllInfo: + case brNoLocalSymbols: + return _True; + } + return unset; +} + +static inline triState toTriState(preprocessOption option) +{ + switch (option) + { + case preprocessNo: + return _False; + case preprocessNoLineNumbers: + case preprocessYes: + return _True; + } + return unset; +} + +static inline triState toTriState(optFoldingType option) +{ + switch (option) + { + case optNoFolding: + return _False; + case optFolding: + return _True; + } + return unset; +} + +static inline triState toTriState(addressAwarenessType option) +{ + switch (option) + { + case addrAwareDefault: + return unset; + case addrAwareNoLarge: + return _False; + case addrAwareLarge: + return _True; + } + return unset; +} + +static inline triState toTriState(linkIncrementalType option) +{ + switch (option) + { + case linkIncrementalDefault: + return unset; + case linkIncrementalNo: + return _False; + case linkIncrementalYes: + return _True; + } + return unset; +} + +static inline triState toTriState(linkProgressOption option) +{ + switch (option) + { + case linkProgressNotSet: + return unset; + case linkProgressAll: + case linkProgressLibs: + return _True; + } + return unset; +} + +static inline triState toTriState(optRefType option) +{ + switch (option) + { + case optReferencesDefault: + return unset; + case optNoReferences: + return _False; + case optReferences: + return _True; + } + return unset; +} + +static inline triState toTriState(termSvrAwarenessType option) +{ + switch (option) + { + case termSvrAwareDefault: + return unset; + case termSvrAwareNo: + return _False; + case termSvrAwareYes: + return _True; + } + return unset; +} + +void VCXProjectWriter::write(XmlOutput &xml, const VCCLCompilerTool &tool) { xml << tag(_CLCompile) << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") << attrTagX(_AdditionalUsingDirectories, tool.AdditionalUsingDirectories, ";") - << attrTagS(_AlwaysAppend, tool.AlwaysAppend) +//unused << attrTagS(_AlwaysAppend, tool.AlwaysAppend) << attrTagS(_AssemblerListingLocation, tool.AssemblerListingLocation) - << attrTagS(_AssemblerOutput, tool.AssemblerOutput) - << attrTagS(_BasicRuntimeChecks, tool.BasicRuntimeChecks) - << attrTagT(_BrowseInformation, tool.BrowseInformation) + << attrTagS(_AssemblerOutput, toString(tool.AssemblerOutput)) + << attrTagS(_BasicRuntimeChecks, toString(tool.BasicRuntimeChecks)) + << attrTagT(_BrowseInformation, toTriState(tool.BrowseInformation)) << attrTagS(_BrowseInformationFile, tool.BrowseInformationFile) << attrTagT(_BufferSecurityCheck, tool.BufferSecurityCheck) - << attrTagS(_CallingConvention, tool.CallingConvention) - << attrTagS(_CompileAs, tool.CompileAs) - << attrTagS(_CompileAsManaged, tool.CompileAsManaged) + << attrTagS(_CallingConvention, toString(tool.CallingConvention)) + << attrTagS(_CompileAs, toString(tool.CompileAs)) + << attrTagS(_CompileAsManaged, toString(tool.CompileAsManaged)) << attrTagT(_CreateHotpatchableImage, tool.CreateHotpatchableImage) - << attrTagS(_DebugInformationFormat, tool.DebugInformationFormat) + << attrTagS(_DebugInformationFormat, toString(tool.DebugInformationFormat)) << attrTagT(_DisableLanguageExtensions, tool.DisableLanguageExtensions) << attrTagX(_DisableSpecificWarnings, tool.DisableSpecificWarnings, ";") - << attrTagS(_EnableEnhancedInstructionSet, tool.EnableEnhancedInstructionSet) + << attrTagS(_EnableEnhancedInstructionSet, toString(tool.EnableEnhancedInstructionSet)) << attrTagT(_EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations) << attrTagT(_EnablePREfast, tool.EnablePREfast) << attrTagS(_ErrorReporting, tool.ErrorReporting) - << attrTagS(_ExceptionHandling, tool.ExceptionHandling) + << attrTagS(_ExceptionHandling, toString(tool.ExceptionHandling)) << attrTagT(_ExpandAttributedSource, tool.ExpandAttributedSource) - << attrTagS(_FavorSizeOrSpeed, tool.FavorSizeOrSpeed) + << attrTagS(_FavorSizeOrSpeed, toString(tool.FavorSizeOrSpeed)) << attrTagT(_FloatingPointExceptions, tool.FloatingPointExceptions) - << attrTagS(_FloatingPointModel, tool.FloatingPointModel) + << attrTagS(_FloatingPointModel, toString(tool.FloatingPointModel)) << attrTagT(_ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope) << attrTagX(_ForcedIncludeFiles, tool.ForcedIncludeFiles, ";") << attrTagX(_ForcedUsingFiles, tool.ForcedUsingFiles, ";") - << attrTagT(_FunctionLevelLinking, tool.FunctionLevelLinking) + << attrTagT(_FunctionLevelLinking, tool.EnableFunctionLevelLinking) << attrTagT(_GenerateXMLDocumentationFiles, tool.GenerateXMLDocumentationFiles) << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrTagS(_InlineFunctionExpansion, tool.InlineFunctionExpansion) - << attrTagT(_IntrinsicFunctions, tool.IntrinsicFunctions) + << attrTagS(_InlineFunctionExpansion, toString(tool.InlineFunctionExpansion)) + << attrTagT(_IntrinsicFunctions, tool.EnableIntrinsicFunctions) << attrTagT(_MinimalRebuild, tool.MinimalRebuild) << attrTagT(_MultiProcessorCompilation, tool.MultiProcessorCompilation) - << attrTagS(_ObjectFileName, tool.ObjectFileName) - << attrTagX(_ObjectFiles, tool.ObjectFiles, ";") + << attrTagS(_ObjectFileName, tool.ObjectFile) +//unused << attrTagX(_ObjectFiles, tool.ObjectFiles, ";") << attrTagT(_OmitDefaultLibName, tool.OmitDefaultLibName) << attrTagT(_OmitFramePointers, tool.OmitFramePointers) - << attrTagT(_OpenMPSupport, tool.OpenMPSupport) - << attrTagS(_Optimization, tool.Optimization) - << attrTagS(_PrecompiledHeader, tool.PrecompiledHeader) + << attrTagT(_OpenMPSupport, tool.OpenMP) + << attrTagS(_Optimization, toString(tool.Optimization)) + << attrTagS(_PrecompiledHeader, toString(tool.UsePrecompiledHeader)) << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile) - << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderOutputFile) - << attrTagT(_PreprocessKeepComments, tool.PreprocessKeepComments) + << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderFile) + << attrTagT(_PreprocessKeepComments, tool.KeepComments) << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") << attrTagS(_PreprocessOutputPath, tool.PreprocessOutputPath) << attrTagT(_PreprocessSuppressLineNumbers, tool.PreprocessSuppressLineNumbers) - << attrTagT(_PreprocessToFile, tool.PreprocessToFile) + << attrTagT(_PreprocessToFile, toTriState(tool.GeneratePreprocessedFile)) << attrTagS(_ProgramDataBaseFileName, tool.ProgramDataBaseFileName) - << attrTagS(_ProcessorNumber, tool.ProcessorNumber) - << attrTagS(_RuntimeLibrary, tool.RuntimeLibrary) + << attrTagS(_ProcessorNumber, tool.MultiProcessorCompilationProcessorCount) + << attrTagS(_RuntimeLibrary, toString(tool.RuntimeLibrary)) << attrTagT(_RuntimeTypeInfo, tool.RuntimeTypeInfo) << attrTagT(_ShowIncludes, tool.ShowIncludes) << attrTagT(_SmallerTypeCheck, tool.SmallerTypeCheck) << attrTagT(_StringPooling, tool.StringPooling) - << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment) + << attrTagS(_StructMemberAlignment, toString(tool.StructMemberAlignment)) << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TreatSpecificWarningsAsErrors, tool.TreatSpecificWarningsAsErrors) - << attrTagT(_TreatWarningAsError, tool.TreatWarningAsError) +//unused << attrTagS(_TreatSpecificWarningsAsErrors, tool.TreatSpecificWarningsAsErrors) + << attrTagT(_TreatWarningAsError, tool.WarnAsError) << attrTagT(_TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType) << attrTagT(_UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions) << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";") - << attrTagT(_UseFullPaths, tool.UseFullPaths) + << attrTagT(_UseFullPaths, tool.DisplayFullPaths) << attrTagT(_UseUnicodeForAssemblerListing, tool.UseUnicodeForAssemblerListing) - << attrTagS(_WarningLevel, tool.WarningLevel) + << attrTagS(_WarningLevel, toString(tool.WarningLevel)) << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization) << attrTagS(_XMLDocumentationFileName, tool.XMLDocumentationFileName) << closetag(_CLCompile); } -void VCXProjectWriter::write(XmlOutput &xml, const VCXLinkerTool &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCLinkerTool &tool) { xml << tag(_Link) @@ -2660,18 +1311,15 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXLinkerTool &tool) << attrTagS(_CLRImageType, tool.CLRImageType) << attrTagS(_CLRSupportLastError, tool.CLRSupportLastError) << attrTagS(_CLRThreadAttribute, tool.CLRThreadAttribute) - << attrTagS(_CLRUnmanagedCodeCheck, tool.CLRUnmanagedCodeCheck) - << attrTagS(_CreateHotPatchableImage, tool.CreateHotPatchableImage) + << attrTagT(_CLRUnmanagedCodeCheck, tool.CLRUnmanagedCodeCheck) +//unused << attrTagS(_CreateHotPatchableImage, tool.CreateHotPatchableImage) << attrTagT(_DataExecutionPrevention, tool.DataExecutionPrevention) << attrTagX(_DelayLoadDLLs, tool.DelayLoadDLLs, ";") << attrTagT(_DelaySign, tool.DelaySign) - << attrTagS(_Driver, tool.Driver) - << attrTagX(_EmbedManagedResourceFile, tool.EmbedManagedResourceFile, ";") - << attrTagT(_EnableCOMDATFolding, tool.EnableCOMDATFolding) + << attrTagS(_EmbedManagedResourceFile, tool.LinkToManagedResourceFile) + << attrTagT(_EnableCOMDATFolding, toTriState(tool.EnableCOMDATFolding)) << attrTagT(_EnableUAC, tool.EnableUAC) << attrTagS(_EntryPointSymbol, tool.EntryPointSymbol) - << attrTagT(_FixedBaseAddress, tool.FixedBaseAddress) - << attrTagS(_ForceFileOutput, tool.ForceFileOutput) << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";") << attrTagS(_FunctionOrder, tool.FunctionOrder) << attrTagT(_GenerateDebugInformation, tool.GenerateDebugInformation) @@ -2682,17 +1330,16 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXLinkerTool &tool) << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) << attrTagT(_IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL) << attrTagT(_IgnoreImportLibrary, tool.IgnoreImportLibrary) - << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";") - << attrTagT(_ImageHasSafeExceptionHandlers, tool.ImageHasSafeExceptionHandlers) + << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreDefaultLibraryNames, ";") << attrTagS(_ImportLibrary, tool.ImportLibrary) << attrTagS(_KeyContainer, tool.KeyContainer) << attrTagS(_KeyFile, tool.KeyFile) - << attrTagT(_LargeAddressAware, tool.LargeAddressAware) - << attrTagT(_LinkDLL, tool.LinkDLL) + << attrTagT(_LargeAddressAware, toTriState(tool.LargeAddressAware)) + << attrTagT(_LinkDLL, (tool.config->ConfigurationType == typeDynamicLibrary ? _True : unset)) << attrTagS(_LinkErrorReporting, tool.LinkErrorReporting) - << attrTagT(_LinkIncremental, tool.LinkIncremental) - << attrTagT(_LinkStatus, tool.LinkStatus) - << attrTagS(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) + << attrTagT(_LinkIncremental, toTriState(tool.LinkIncremental)) + << attrTagT(_LinkStatus, toTriState(tool.ShowProgress)) + << attrTagS(_LinkTimeCodeGeneration, toString(tool.LinkTimeCodeGeneration)) << attrTagS(_ManifestFile, tool.ManifestFile) << attrTagT(_MapExports, tool.MapExports) << attrTagS(_MapFileName, tool.MapFileName) @@ -2700,32 +1347,27 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXLinkerTool &tool) << attrTagS(_MergeSections, tool.MergeSections) << attrTagS(_MidlCommandFile, tool.MidlCommandFile) << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) - << attrTagS(_MSDOSStubFileName, tool.MSDOSStubFileName) - << attrTagT(_NoEntryPoint, tool.NoEntryPoint) - << attrTagT(_OptimizeReferences, tool.OptimizeReferences) + << attrTagT(_NoEntryPoint, tool.ResourceOnlyDLL) + << attrTagT(_OptimizeReferences, toTriState(tool.OptimizeReferences)) << attrTagS(_OutputFile, tool.OutputFile) << attrTagT(_PreventDllBinding, tool.PreventDllBinding) - << attrTagS(_Profile, tool.Profile) - << attrTagS(_ProfileGuidedDatabase, tool.ProfileGuidedDatabase) << attrTagS(_ProgramDatabaseFile, tool.ProgramDatabaseFile) << attrTagT(_RandomizedBaseAddress, tool.RandomizedBaseAddress) << attrTagT(_RegisterOutput, tool.RegisterOutput) << attrTagL(_SectionAlignment, tool.SectionAlignment, /*ifNot*/ -1) << attrTagT(_SetChecksum, tool.SetChecksum) - << attrTagS(_ShowProgress, tool.ShowProgress) - << attrTagS(_SpecifySectionAttributes, tool.SpecifySectionAttributes) - << attrTagS(_StackCommitSize, tool.StackCommitSize) - << attrTagS(_StackReserveSize, tool.StackReserveSize) + << attrTagL(_StackCommitSize, tool.StackCommitSize, /*ifNot*/ -1) + << attrTagL(_StackReserveSize, tool.StackReserveSize, /*ifNot*/ -1) << attrTagS(_StripPrivateSymbols, tool.StripPrivateSymbols) - << attrTagS(_SubSystem, tool.SubSystem) - << attrTagT(_SupportNobindOfDelayLoadedDLL, tool.SupportNobindOfDelayLoadedDLL) + << attrTagS(_SubSystem, toString(tool.SubSystem)) +// << attrTagT(_SupportNobindOfDelayLoadedDLL, tool.SupportNobindOfDelayLoadedDLL) << attrTagT(_SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL) << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) << attrTagT(_SwapRunFromCD, tool.SwapRunFromCD) << attrTagT(_SwapRunFromNet, tool.SwapRunFromNet) - << attrTagS(_TargetMachine, tool.TargetMachine) - << attrTagT(_TerminalServerAware, tool.TerminalServerAware) - << attrTagT(_TreatLinkerWarningAsErrors, tool.TreatLinkerWarningAsErrors) + << attrTagS(_TargetMachine, toString(tool.TargetMachine)) + << attrTagT(_TerminalServerAware, toTriState(tool.TerminalServerAware)) + << attrTagT(_TreatLinkerWarningAsErrors, tool.TreatWarningsAsErrors) << attrTagT(_TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration) << attrTagS(_TypeLibraryFile, tool.TypeLibraryFile) << attrTagL(_TypeLibraryResourceID, tool.TypeLibraryResourceID, /*ifNot*/ 0) @@ -2735,7 +1377,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXLinkerTool &tool) << closetag(_Link); } -void VCXProjectWriter::write(XmlOutput &xml, const VCXMIDLTool &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCMIDLTool &tool) { xml << tag(_Midl) @@ -2743,10 +1385,10 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXMIDLTool &tool) << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") << attrTagT(_ApplicationConfigurationMode, tool.ApplicationConfigurationMode) << attrTagS(_ClientStubFile, tool.ClientStubFile) - << attrTagS(_CPreprocessOptions, tool.CPreprocessOptions) - << attrTagS(_DefaultCharType, tool.DefaultCharType) + << attrTagX(_CPreprocessOptions, tool.CPreprocessOptions, " ") + << attrTagS(_DefaultCharType, toString(tool.DefaultCharType)) << attrTagS(_DLLDataFileName, tool.DLLDataFileName) - << attrTagS(_EnableErrorChecks, tool.EnableErrorChecks) + << attrTagS(_EnableErrorChecks, toString(tool.EnableErrorChecks)) << attrTagT(_ErrorCheckAllocations, tool.ErrorCheckAllocations) << attrTagT(_ErrorCheckBounds, tool.ErrorCheckBounds) << attrTagT(_ErrorCheckEnumRange, tool.ErrorCheckEnumRange) @@ -2766,20 +1408,20 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXMIDLTool &tool) << attrTagS(_ProxyFileName, tool.ProxyFileName) << attrTagS(_RedirectOutputAndErrors, tool.RedirectOutputAndErrors) << attrTagS(_ServerStubFile, tool.ServerStubFile) - << attrTagS(_StructMemberAlignment, tool.StructMemberAlignment) + << attrTagS(_StructMemberAlignment, toString(tool.StructMemberAlignment)) << attrTagT(_SuppressCompilerWarnings, tool.SuppressCompilerWarnings) << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TargetEnvironment, tool.TargetEnvironment) + << attrTagS(_TargetEnvironment, toString(tool.TargetEnvironment)) << attrTagS(_TypeLibFormat, tool.TypeLibFormat) << attrTagS(_TypeLibraryName, tool.TypeLibraryName) << attrTagX(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions, ";") << attrTagT(_ValidateAllParameters, tool.ValidateAllParameters) << attrTagT(_WarnAsError, tool.WarnAsError) - << attrTagS(_WarningLevel, tool.WarningLevel) + << attrTagS(_WarningLevel, toString(tool.WarningLevel)) << closetag(_Midl); } -void VCXProjectWriter::write(XmlOutput &xml, const VCXCustomBuildTool &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCCustomBuildTool &tool) { // The code below offers two ways to split custom build step commands. // Normally the $$escape_expand(\n\t) is used in a project file, which is correctly translated @@ -2807,80 +1449,82 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXCustomBuildTool &tool) cmds += cmdl; } + const QString &configName = tool.config->Name; + if ( !tool.AdditionalDependencies.isEmpty() ) { xml << tag("AdditionalInputs") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(configName)) << valueTagDefX(tool.AdditionalDependencies, "AdditionalInputs", ";"); } if( !cmds.isEmpty() ) { xml << tag("Command") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(configName)) << valueTag(cmds); } if ( !tool.Description.isEmpty() ) { xml << tag("Message") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(configName)) << valueTag(tool.Description); } if ( !tool.Outputs.isEmpty() ) { xml << tag("Outputs") - << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.ConfigName)) + << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(configName)) << valueTagDefX(tool.Outputs, "Outputs", ";"); } } -void VCXProjectWriter::write(XmlOutput &xml, const VCXLibrarianTool &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCLibrarianTool &tool) { xml << tag(_Link) << attrTagX(_AdditionalDependencies, tool.AdditionalDependencies, ";") << attrTagX(_AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories, ";") << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") - << attrTagS(_DisplayLibrary, tool.DisplayLibrary) - << attrTagS(_ErrorReporting, tool.ErrorReporting) +//unused << attrTagS(_DisplayLibrary, tool.DisplayLibrary) +//unused << attrTagS(_ErrorReporting, tool.ErrorReporting) << attrTagX(_ExportNamedFunctions, tool.ExportNamedFunctions, ";") << attrTagX(_ForceSymbolReferences, tool.ForceSymbolReferences, ";") << attrTagT(_IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries) - << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreSpecificDefaultLibraries, ";") - << attrTagT(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) + << attrTagX(_IgnoreSpecificDefaultLibraries, tool.IgnoreDefaultLibraryNames, ";") +//unused << attrTagT(_LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration) << attrTagS(_ModuleDefinitionFile, tool.ModuleDefinitionFile) - << attrTagS(_Name, tool.Name) +//unused << attrTagS(_Name, tool.Name) << attrTagS(_OutputFile, tool.OutputFile) - << attrTagX(_RemoveObjects, tool.RemoveObjects, ";") - << attrTagS(_SubSystem, tool.SubSystem) +//unused << attrTagX(_RemoveObjects, tool.RemoveObjects, ";") +//unused << attrTagS(_SubSystem, tool.SubSystem) << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TargetMachine, tool.TargetMachine) - << attrTagT(_TreatLibWarningAsErrors, tool.TreatLibWarningAsErrors) - << attrTagT(_Verbose, tool.Verbose) +//unused << attrTagS(_TargetMachine, tool.TargetMachine) +//unused << attrTagT(_TreatLibWarningAsErrors, tool.TreatLibWarningAsErrors) +//unused << attrTagT(_Verbose, tool.Verbose) << closetag(_Link); } -void VCXProjectWriter::write(XmlOutput &xml, const VCXResourceCompilerTool &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCResourceCompilerTool &tool) { xml << tag(_ResourceCompile) << attrTagX(_AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories, ";") - << attrTagS(_AdditionalOptions, tool.AdditionalOptions) - << attrTagS(_Culture, tool.Culture) + << attrTagX(_AdditionalOptions, tool.AdditionalOptions, " ") + << attrTagS(_Culture, toString(tool.Culture)) << attrTagT(_IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath) - << attrTagT(_NullTerminateStrings, tool.NullTerminateStrings) +//unused << attrTagT(_NullTerminateStrings, tool.NullTerminateStrings) << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") << attrTagS(_ResourceOutputFileName, tool.ResourceOutputFileName) - << attrTagT(_ShowProgress, tool.ShowProgress) + << attrTagT(_ShowProgress, toTriState(tool.ShowProgress)) << attrTagT(_SuppressStartupBanner, tool.SuppressStartupBanner) - << attrTagS(_TrackerLogDirectory, tool.TrackerLogDirectory) - << attrTagS(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) +//unused << attrTagS(_TrackerLogDirectory, tool.TrackerLogDirectory) +//unused << attrTagS(_UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions) << closetag(_ResourceCompile); } -void VCXProjectWriter::write(XmlOutput &xml, const VCXEventTool &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCEventTool &tool) { xml << tag(tool.EventName) @@ -2896,7 +1540,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCDeploymentTool &tool) // SmartDevice deployment not supported in VS 2010 } -void VCXProjectWriter::write(XmlOutput &xml, const VCXConfiguration &tool) +void VCXProjectWriter::write(XmlOutput &xml, const VCConfiguration &tool) { xml << tag("PropertyGroup") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(tool.Name)) @@ -2904,16 +1548,16 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCXConfiguration &tool) << attrTagS(_OutputDirectory, tool.OutputDirectory) << attrTagT(_ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage) << attrTagT(_BuildBrowserInformation, tool.BuildBrowserInformation) - << attrTagS(_CharacterSet, tool.CharacterSet) - << attrTagS(_ConfigurationType, tool.ConfigurationType) + << attrTagS(_CharacterSet, toString(tool.CharacterSet)) + << attrTagS(_ConfigurationType, toString(tool.ConfigurationType)) << attrTagS(_DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean) << attrTagS(_ImportLibrary, tool.ImportLibrary) << attrTagS(_IntermediateDirectory, tool.IntermediateDirectory) << attrTagS(_PrimaryOutput, tool.PrimaryOutput) << attrTagS(_ProgramDatabase, tool.ProgramDatabase) << attrTagT(_RegisterOutput, tool.RegisterOutput) - << attrTagS(_UseOfATL, tool.UseOfATL) - << attrTagS(_UseOfMfc, tool.UseOfMfc) + << attrTagS(_UseOfATL, toString(tool.UseOfATL)) + << attrTagS(_UseOfMfc, toString(tool.UseOfMfc)) << attrTagT(_WholeProgramOptimization, tool.WholeProgramOptimization) << closetag(); } @@ -2925,13 +1569,13 @@ void VCXProjectWriter::write(XmlOutput &xml, VCFilter &tool) // unused in this generator } -void VCXProjectWriter::addFilters(VCXProject &project, XmlOutput &xmlFilter, const QString &filtername) +void VCXProjectWriter::addFilters(VCProject &project, XmlOutput &xmlFilter, const QString &filtername) { bool added = false; for (int i = 0; i < project.SingleProjects.count(); ++i) { - VCXFilter filter; - const VCXProjectSingleConfig &singleCfg = project.SingleProjects.at(i); + VCFilter filter; + const VCProjectSingleConfig &singleCfg = project.SingleProjects.at(i); if (filtername == "Root Files") { filter = singleCfg.RootFiles; } else if (filtername == "Source Files") { @@ -2965,7 +1609,7 @@ void VCXProjectWriter::addFilters(VCXProject &project, XmlOutput &xmlFilter, con } // outputs a given filter for all existing configurations of a project -void VCXProjectWriter::outputFilter(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername) +void VCXProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername) { XNode *root; if (project.SingleProjects.at(0).flat_files) @@ -2977,8 +1621,8 @@ void VCXProjectWriter::outputFilter(VCXProject &project, XmlOutput &xml, XmlOutp triState parse; for (int i = 0; i < project.SingleProjects.count(); ++i) { - VCXFilter filter; - const VCXProjectSingleConfig &singleCfg = project.SingleProjects.at(i); + VCFilter filter; + const VCProjectSingleConfig &singleCfg = project.SingleProjects.at(i); if (filtername == "Root Files") { filter = singleCfg.RootFiles; } else if (filtername == "Source Files") { @@ -3020,16 +1664,16 @@ void VCXProjectWriter::outputFilter(VCXProject &project, XmlOutput &xml, XmlOutp } // Output all configurations (by filtername) for a file (by info) -// A filters config output is in VCXFilter.outputFileConfig() -void VCXProjectWriter::outputFileConfigs(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCXFilterFile &info, const QString &filtername) +// A filters config output is in VCFilter.outputFileConfig() +void VCXProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername) { // We need to check if the file has any custom build step. // If there is one then it has to be included with "CustomBuild Include" bool fileAdded = false; for (int i = 0; i < project.SingleProjects.count(); ++i) { - VCXFilter filter; - const VCXProjectSingleConfig &singleCfg = project.SingleProjects.at(i); + VCFilter filter; + const VCProjectSingleConfig &singleCfg = project.SingleProjects.at(i); if (filtername == "Root Files") { filter = singleCfg.RootFiles; } else if (filtername == "Source Files") { @@ -3136,26 +1780,26 @@ void VCXProjectWriter::outputFileConfigs(VCXProject &project, XmlOutput &xml, Xm xmlFilter << closetag(); } -bool VCXProjectWriter::outputFileConfig(VCXFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded) +bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded) { bool fileAdded = false; // Clearing each filter tool filter.useCustomBuildTool = false; filter.useCompilerTool = false; - filter.CustomBuildTool = VCXCustomBuildTool(); - filter.CompilerTool = VCXCLCompilerTool(); + filter.CustomBuildTool = VCCustomBuildTool(); + filter.CompilerTool = VCCLCompilerTool(); // Unset some default options filter.CompilerTool.BufferSecurityCheck = unset; - filter.CompilerTool.DebugInformationFormat = ""; - filter.CompilerTool.ExceptionHandling = ""; + filter.CompilerTool.DebugInformationFormat = debugUnknown; + filter.CompilerTool.ExceptionHandling = ehDefault; filter.CompilerTool.ProgramDataBaseFileName.clear(); - filter.CompilerTool.RuntimeLibrary = ""; + filter.CompilerTool.RuntimeLibrary = rtUnknown; filter.CompilerTool.config = filter.Config; bool inBuild = false; - VCXFilterFile info; + VCFilterFile info; for (int i = 0; i < filter.Files.count(); ++i) { if (filter.Files.at(i).file == filename) { info = filter.Files.at(i); @@ -3179,8 +1823,6 @@ bool VCXProjectWriter::outputFileConfig(VCXFilter &filter, XmlOutput &xml, XmlOu if (filter.useCustomBuildTool) { - filter.CustomBuildTool.ConfigName = (*filter.Config).Name; - if ( !fileAllreadyAdded ) { fileAdded = true; @@ -3290,11 +1932,11 @@ bool VCXProjectWriter::outputFileConfig(VCXFilter &filter, XmlOutput &xml, XmlOu << valueTag(filter.CompilerTool.PrecompiledHeaderFile); } - if ( !filter.CompilerTool.PrecompiledHeader.isEmpty() ) { + if ( filter.CompilerTool.UsePrecompiledHeader ) { xml << tag("PrecompiledHeader") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) - << valueTag(filter.CompilerTool.PrecompiledHeader); + << valueTag(toString(filter.CompilerTool.UsePrecompiledHeader)); } } } diff --git a/qmake/generators/win32/msbuild_objectmodel.h b/qmake/generators/win32/msbuild_objectmodel.h index af45330..498552e 100644 --- a/qmake/generators/win32/msbuild_objectmodel.h +++ b/qmake/generators/win32/msbuild_objectmodel.h @@ -54,519 +54,24 @@ QT_BEGIN_NAMESPACE - -class VCXConfiguration; -class VCXProject; - -class VCXCLCompilerTool : public VCToolBase -{ -public: - // Functions - VCXCLCompilerTool(); - virtual ~VCXCLCompilerTool(){} - bool parseOption(const char* option); - - // Variables - QStringList AdditionalIncludeDirectories; - QStringList AdditionalOptions; - QStringList AdditionalUsingDirectories; - QString AlwaysAppend; - QString AssemblerListingLocation; - QString AssemblerOutput; - QString BasicRuntimeChecks; - triState BrowseInformation; - QString BrowseInformationFile; - triState BufferSecurityCheck; - QString CallingConvention; - QString CompileAs; - QString CompileAsManaged; - triState CreateHotpatchableImage; - QString DebugInformationFormat; - triState DisableLanguageExtensions; - QStringList DisableSpecificWarnings; - QString EnableEnhancedInstructionSet; - triState EnableFiberSafeOptimizations; - triState EnablePREfast; - QString ErrorReporting; - QString ExceptionHandling; - triState ExpandAttributedSource; - QString FavorSizeOrSpeed; - triState FloatingPointExceptions; - QString FloatingPointModel; - triState ForceConformanceInForLoopScope; - QStringList ForcedIncludeFiles; - QStringList ForcedUsingFiles; - triState FunctionLevelLinking; - triState GenerateXMLDocumentationFiles; - triState IgnoreStandardIncludePath; - QString InlineFunctionExpansion; - triState IntrinsicFunctions; - triState MinimalRebuild; - triState MultiProcessorCompilation; - QString ObjectFileName; - QStringList ObjectFiles; - triState OmitDefaultLibName; - triState OmitFramePointers; - triState OpenMPSupport; - QString Optimization; - QString PrecompiledHeader; - QString PrecompiledHeaderFile; - QString PrecompiledHeaderOutputFile; - triState PreprocessKeepComments; - QStringList PreprocessorDefinitions; - QString PreprocessOutputPath; - triState PreprocessSuppressLineNumbers; - triState PreprocessToFile; - QString ProgramDataBaseFileName; - QString ProcessorNumber; - QString RuntimeLibrary; - triState RuntimeTypeInfo; - triState ShowIncludes; - triState SmallerTypeCheck; - triState StringPooling; - QString StructMemberAlignment; - triState SuppressStartupBanner; - QString TreatSpecificWarningsAsErrors; - triState TreatWarningAsError; - triState TreatWChar_tAsBuiltInType; - triState UndefineAllPreprocessorDefinitions; - QStringList UndefinePreprocessorDefinitions; - triState UseFullPaths; - triState UseUnicodeForAssemblerListing; - QString WarningLevel; - triState WholeProgramOptimization; - QString XMLDocumentationFileName; - - VCXConfiguration* config; -}; - -class VCXLinkerTool : public VCToolBase -{ -public: - // Functions - VCXLinkerTool(); - virtual ~VCXLinkerTool(){} - bool parseOption(const char* option); - - // Variables - QStringList AdditionalDependencies; - QStringList AdditionalLibraryDirectories; - QStringList AdditionalManifestDependencies; - QStringList AdditionalOptions; - QStringList AddModuleNamesToAssembly; - triState AllowIsolation; - triState AssemblyDebug; - QStringList AssemblyLinkResource; - QString BaseAddress; - QString CLRImageType; - QString CLRSupportLastError; - QString CLRThreadAttribute; - QString CLRUnmanagedCodeCheck; - QString CreateHotPatchableImage; - triState DataExecutionPrevention; - QStringList DelayLoadDLLs; - triState DelaySign; - QString Driver; - QStringList EmbedManagedResourceFile; - triState EnableCOMDATFolding; - triState EnableUAC; - QString EntryPointSymbol; - triState FixedBaseAddress; - QString ForceFileOutput; - QStringList ForceSymbolReferences; - QString FunctionOrder; - triState GenerateDebugInformation; - triState GenerateManifest; - triState GenerateMapFile; - qlonglong HeapCommitSize; - qlonglong HeapReserveSize; - triState IgnoreAllDefaultLibraries; - triState IgnoreEmbeddedIDL; - triState IgnoreImportLibrary; - QStringList IgnoreSpecificDefaultLibraries; - triState ImageHasSafeExceptionHandlers; - QString ImportLibrary; - QString KeyContainer; - QString KeyFile; - triState LargeAddressAware; - triState LinkDLL; - QString LinkErrorReporting; - triState LinkIncremental; - triState LinkStatus; - QString LinkTimeCodeGeneration; - QString ManifestFile; - triState MapExports; - QString MapFileName; - QString MergedIDLBaseFileName; - QString MergeSections; - QString MidlCommandFile; - QString ModuleDefinitionFile; - QString MSDOSStubFileName; - triState NoEntryPoint; - triState OptimizeReferences; - QString OutputFile; - triState PreventDllBinding; - QString Profile; - QString ProfileGuidedDatabase; - QString ProgramDatabaseFile; - triState RandomizedBaseAddress; - triState RegisterOutput; - qlonglong SectionAlignment; - triState SetChecksum; - QString ShowProgress; - QString SpecifySectionAttributes; - QString StackCommitSize; - QString StackReserveSize; - QString StripPrivateSymbols; - QString SubSystem; - triState SupportNobindOfDelayLoadedDLL; - triState SupportUnloadOfDelayLoadedDLL; - triState SuppressStartupBanner; - triState SwapRunFromCD; - triState SwapRunFromNet; - QString TargetMachine; - triState TerminalServerAware; - triState TreatLinkerWarningAsErrors; - triState TurnOffAssemblyGeneration; - QString TypeLibraryFile; - qlonglong TypeLibraryResourceID; - QString UACExecutionLevel; - triState UACUIAccess; - QString Version; - - - VCXConfiguration* config; -}; - -class VCXMIDLTool : public VCToolBase -{ -public: - // Functions - VCXMIDLTool(); - virtual ~VCXMIDLTool(){} - bool parseOption(const char* option); - - // Variables - QStringList AdditionalIncludeDirectories; - QStringList AdditionalOptions; - triState ApplicationConfigurationMode; - QString ClientStubFile; - QString CPreprocessOptions; - QString DefaultCharType; - QString DLLDataFileName; - QString EnableErrorChecks; - triState ErrorCheckAllocations; - triState ErrorCheckBounds; - triState ErrorCheckEnumRange; - triState ErrorCheckRefPointers; - triState ErrorCheckStubData; - QString GenerateClientFiles; - QString GenerateServerFiles; - triState GenerateStublessProxies; - triState GenerateTypeLibrary; - QString HeaderFileName; - triState IgnoreStandardIncludePath; - QString InterfaceIdentifierFileName; - qlonglong LocaleID; - triState MkTypLibCompatible; - QString OutputDirectory; - QStringList PreprocessorDefinitions; - QString ProxyFileName; - QString RedirectOutputAndErrors; - QString ServerStubFile; - QString StructMemberAlignment; - triState SuppressCompilerWarnings; - triState SuppressStartupBanner; - QString TargetEnvironment; - QString TypeLibFormat; - QString TypeLibraryName; - QStringList UndefinePreprocessorDefinitions; - triState ValidateAllParameters; - triState WarnAsError; - QString WarningLevel; - - VCXConfiguration* config; -}; - -class VCXLibrarianTool : public VCToolBase -{ -public: - // Functions - VCXLibrarianTool(); - virtual ~VCXLibrarianTool(){} - bool parseOption(const char*){ return false; }; - - // Variables - QStringList AdditionalDependencies; - QStringList AdditionalLibraryDirectories; - QStringList AdditionalOptions; - QString DisplayLibrary; - QString ErrorReporting; - QStringList ExportNamedFunctions; - QStringList ForceSymbolReferences; - triState IgnoreAllDefaultLibraries; - QStringList IgnoreSpecificDefaultLibraries; - triState LinkTimeCodeGeneration; - QString ModuleDefinitionFile; - QString Name; - QString OutputFile; - QStringList RemoveObjects; - QString SubSystem; - triState SuppressStartupBanner; - QString TargetMachine; - triState TreatLibWarningAsErrors; - triState Verbose; - -}; - -class VCXCustomBuildTool : public VCToolBase -{ -public: - // Functions - VCXCustomBuildTool(); - virtual ~VCXCustomBuildTool(){} - bool parseOption(const char*){ return false; }; - - // Variables - QStringList AdditionalDependencies; - QStringList CommandLine; - QString Description; - QStringList Outputs; - QString ToolName; - QString ToolPath; - QString ConfigName; -}; - -class VCXResourceCompilerTool : public VCToolBase -{ -public: - // Functions - VCXResourceCompilerTool(); - virtual ~VCXResourceCompilerTool(){} - bool parseOption(const char*){ return false; }; - - // Variables - QStringList AdditionalIncludeDirectories; - QString AdditionalOptions; - QString Culture; - triState IgnoreStandardIncludePath; - triState NullTerminateStrings; - QStringList PreprocessorDefinitions; - QString ResourceOutputFileName; - triState ShowProgress; - triState SuppressStartupBanner; - QString TrackerLogDirectory; - QString UndefinePreprocessorDefinitions; -}; - -class VCXDeploymentTool -{ -public: - // Functions - VCXDeploymentTool(); - virtual ~VCXDeploymentTool() {} - - // Variables - QString DeploymentTag; - QString RemoteDirectory; - QString AdditionalFiles; -}; - -class VCXEventTool : public VCToolBase -{ -protected: - // Functions - VCXEventTool() : UseInBuild(unset){}; - virtual ~VCXEventTool(){} - bool parseOption(const char*){ return false; }; - -public: - // Variables - QString CommandLine; - QString Description; - triState UseInBuild; - QString EventName; - QString ToolPath; -}; - -class VCXPostBuildEventTool : public VCXEventTool -{ -public: - VCXPostBuildEventTool(); - ~VCXPostBuildEventTool(){} -}; - -class VCXPreBuildEventTool : public VCXEventTool -{ -public: - VCXPreBuildEventTool(); - ~VCXPreBuildEventTool(){} -}; - -class VCXPreLinkEventTool : public VCXEventTool -{ -public: - VCXPreLinkEventTool(); - ~VCXPreLinkEventTool(){} -}; - -class VCXConfiguration -{ -public: - // Functions - VCXConfiguration(); - ~VCXConfiguration(){} - - // Variables - triState ATLMinimizesCRunTimeLibraryUsage; - triState BuildBrowserInformation; - QString CharacterSet; - QString ConfigurationType; - QString DeleteExtensionsOnClean; - QString ImportLibrary; - QString IntermediateDirectory; - QString Name; - QString ConfigurationName; - QString OutputDirectory; - QString PrimaryOutput; - QString ProgramDatabase; - triState RegisterOutput; - QString TargetName; - QString UseOfATL; - QString UseOfMfc; - triState WholeProgramOptimization; - - // XML sub-parts - VCXCLCompilerTool compiler; - VCXLibrarianTool librarian; - VCXLinkerTool linker; - VCXMIDLTool idl; - VCXResourceCompilerTool resource; - VCXCustomBuildTool custom; - VCXDeploymentTool deployment; // Not likely to be supported: http://msdn.microsoft.com/en-us/library/sa69he4t.aspx - VCXPostBuildEventTool postBuild; - VCXPreBuildEventTool preBuild; - VCXPreLinkEventTool preLink; -}; - -struct VCXFilterFile -{ - VCXFilterFile() - { excludeFromBuild = false; } - VCXFilterFile(const QString &filename, bool exclude = false ) - { file = filename; excludeFromBuild = exclude; } - VCXFilterFile(const QString &filename, const QString &additional, bool exclude = false ) - { file = filename; excludeFromBuild = exclude; additionalFile = additional; } - bool operator==(const VCXFilterFile &other){ - return file == other.file - && additionalFile == other.additionalFile - && excludeFromBuild == other.excludeFromBuild; - } - - bool excludeFromBuild; - QString file; - QString additionalFile; // For tools like MOC -}; - -class VcxprojGenerator; -class VCXFilter -{ -public: - // Functions - VCXFilter(); - ~VCXFilter(){}; - - void addFile(const QString& filename); // equal - void addFile(const VCXFilterFile& fileInfo);// equal - void addFiles(const QStringList& fileList);// equal - bool addExtraCompiler(const VCXFilterFile &info); //equal - void modifyPCHstage(QString str); //almost equal -> file comment .vcxproj, PrecompiledHeader property - - // Variables - QString Name; - QString Filter; - QString Guid; - triState ParseFiles; - VcxprojGenerator* Project; - VCXConfiguration* Config; - QList Files; - - customBuildCheck CustomBuild; - - bool useCustomBuildTool; - VCXCustomBuildTool CustomBuildTool; - - bool useCompilerTool; - VCXCLCompilerTool CompilerTool; -}; - -typedef QList VCXFilterList; -class VCXProjectSingleConfig -{ -public: - enum FilterTypes { - None, - Source, - Header, - Generated, - LexYacc, - Translation, - Resources, - Extras - }; - // Functions - VCXProjectSingleConfig(){}; - ~VCXProjectSingleConfig(){} - - // Variables - QString Name; - QString Version; - QString ProjectGUID; - QString Keyword; - QString SccProjectName; - QString SccLocalPath; - QString PlatformName; - - // XML sub-parts - VCXConfiguration Configuration; - VCXFilter RootFiles; - VCXFilter SourceFiles; - VCXFilter HeaderFiles; - VCXFilter GeneratedFiles; - VCXFilter LexYaccFiles; - VCXFilter TranslationFiles; - VCXFilter FormFiles; - VCXFilter ResourceFiles; - VCXFilterList ExtraCompilersFiles; - - bool flat_files; - - // Accessor for extracompilers - VCXFilter &filterForExtraCompiler(const QString &compilerName); - // ### this function is the same as in VCProjectSingleConfig ----> DIE DIE DIE -}; - - - // Tree & Flat view of files -------------------------------------------------- -class VCXFilter; class XNode { public: virtual ~XNode() { } - void addElement(const VCXFilterFile &file) { + void addElement(const VCFilterFile &file) { addElement(file.file, file); } - virtual void addElement(const QString &filepath, const VCXFilterFile &allInfo) = 0; + virtual void addElement(const QString &filepath, const VCFilterFile &allInfo) = 0; virtual void removeElements()= 0; - virtual void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &tool, const QString &filter) = 0; + virtual void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter) = 0; virtual bool hasElements() = 0; }; class XTreeNode : public XNode { typedef QMap ChildrenMap; - VCXFilterFile info; + VCFilterFile info; ChildrenMap children; public: @@ -582,7 +87,7 @@ public: return Uindex; } - void addElement(const QString &filepath, const VCXFilterFile &allInfo){ + void addElement(const QString &filepath, const VCFilterFile &allInfo){ QString newNodeName(filepath); int index = pathIndex(filepath); @@ -609,7 +114,7 @@ public: children.clear(); } - void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &tool, const QString &filter); + void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &tool, const QString &filter); bool hasElements() { return children.size() != 0; } @@ -617,7 +122,7 @@ public: class XFlatNode : public XNode { - typedef QMap ChildrenMapFlat; + typedef QMap ChildrenMapFlat; ChildrenMapFlat children; public: @@ -633,7 +138,7 @@ public: return Uindex; } - void addElement(const QString &filepath, const VCXFilterFile &allInfo){ + void addElement(const QString &filepath, const VCFilterFile &allInfo){ QString newKey(filepath); int index = pathIndex(filepath); @@ -649,55 +154,34 @@ public: children.clear(); } - void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCXProject &proj, const QString &filter); + void generateXML(XmlOutput &xml, XmlOutput &xmlFilter, const QString &tagName, VCProject &proj, const QString &filter); bool hasElements() { return children.size() != 0; } }; -// ---------------------------------------------------------------------------- - -class VCXProject -{ -public: - // Variables - QString Name; - QString Version; - QString ProjectGUID; - QString Keyword; - QString SccProjectName; - QString SccLocalPath; - QString PlatformName; - - // Single projects - QList SingleProjects; - - // List of all extracompilers - QStringList ExtraCompilers; -}; class VCXProjectWriter : public VCProjectWriter { public: - // ### replace the X classes with the standard names! - void write(XmlOutput &, VCXProjectSingleConfig &); - void write(XmlOutput &, VCXProject &); + void write(XmlOutput &, VCProjectSingleConfig &); + void write(XmlOutput &, VCProject &); - void write(XmlOutput &, const VCXCLCompilerTool &); - void write(XmlOutput &, const VCXLinkerTool &); - void write(XmlOutput &, const VCXMIDLTool &); - void write(XmlOutput &, const VCXCustomBuildTool &); - void write(XmlOutput &, const VCXLibrarianTool &); - void write(XmlOutput &, const VCXResourceCompilerTool &); - void write(XmlOutput &, const VCXEventTool &); + void write(XmlOutput &, const VCCLCompilerTool &); + void write(XmlOutput &, const VCLinkerTool &); + void write(XmlOutput &, const VCMIDLTool &); + void write(XmlOutput &, const VCCustomBuildTool &); + void write(XmlOutput &, const VCLibrarianTool &); + void write(XmlOutput &, const VCResourceCompilerTool &); + void write(XmlOutput &, const VCEventTool &); void write(XmlOutput &, const VCDeploymentTool &); - void write(XmlOutput &, const VCXConfiguration &); + void write(XmlOutput &, const VCConfiguration &); void write(XmlOutput &, VCFilter &); private: - static void addFilters(VCXProject &project, XmlOutput &xmlFilter, const QString &filterName); - static void outputFilter(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername); - static void outputFileConfigs(VCXProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCXFilterFile &info, const QString &filtername); - static bool outputFileConfig(VCXFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded); + static void addFilters(VCProject &project, XmlOutput &xmlFilter, const QString &filterName); + static void outputFilter(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filtername); + static void outputFileConfigs(VCProject &project, XmlOutput &xml, XmlOutput &xmlFilter, const VCFilterFile &info, const QString &filtername); + static bool outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOutput &xmlFilter, const QString &filename, const QString &filtername, bool fileAllreadyAdded); friend class XTreeNode; friend class XFlatNode; diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 1d18dc8..607de5d 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -280,6 +280,14 @@ inline XmlOutput::xml_output attrX(const char *name, const QStringList &v, const return attr(name, v.join(s)); } +triState operator!(const triState &rhs) +{ + if (rhs == unset) + return rhs; + triState lhs = (rhs == _True ? _False : _True); + return lhs; +} + // VCCLCompilerTool ------------------------------------------------- VCCLCompilerTool::VCCLCompilerTool() : AssemblerOutput(asmListingNone), @@ -305,12 +313,14 @@ VCCLCompilerTool::VCCLCompilerTool() FloatingPointExceptions(unset), ForceConformanceInForLoopScope(unset), GeneratePreprocessedFile(preprocessNo), + PreprocessSuppressLineNumbers(unset), GlobalOptimizations(unset), IgnoreStandardIncludePath(unset), ImproveFloatingPointConsistency(unset), InlineFunctionExpansion(expandDefault), KeepComments(unset), MinimalRebuild(unset), + OmitDefaultLibName(unset), OmitFramePointers(unset), OpenMP(unset), Optimization(optimizeCustom), @@ -328,11 +338,17 @@ VCCLCompilerTool::VCCLCompilerTool() TurnOffAssemblyGeneration(unset), UndefineAllPreprocessorDefinitions(unset), UsePrecompiledHeader(pchNone), + UseUnicodeForAssemblerListing(unset), WarnAsError(unset), WarningLevel(warningLevel_0), WholeProgramOptimization(unset), CompileForArchitecture(archUnknown), - InterworkCalls(unset) + InterworkCalls(unset), + EnablePREfast(unset), + DisplayFullPaths(unset), + MultiProcessorCompilation(unset), + GenerateXMLDocumentationFiles(unset), + CreateHotpatchableImage(unset) { } @@ -381,6 +397,10 @@ bool VCCLCompilerTool::parseOption(const char* option) switch (first) { case '?': case 'h': + if(second == 'o' && third == 't' && fourth == 'p') { + CreateHotpatchableImage = _True; + break; + } qWarning("Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info"); found = false; break; @@ -406,7 +426,7 @@ bool VCCLCompilerTool::parseOption(const char* option) break; case 'E': if(second == 'H') { - QString opt(option); + QByteArray opt(option + 2); if (opt.contains('a') && !opt.contains('s') && !opt.contains('c')) ExceptionHandling = ehSEH; else if (!opt.contains('a') && opt.contains("s-") && opt.contains("c-")) @@ -425,6 +445,8 @@ bool VCCLCompilerTool::parseOption(const char* option) AdditionalOptions += option; } break; + } else if (second == 'P') { + PreprocessSuppressLineNumbers = _True; } GeneratePreprocessedFile = preprocessYes; break; @@ -441,16 +463,24 @@ bool VCCLCompilerTool::parseOption(const char* option) AssemblerOutput = asmListingAsmMachineSrc; } else if(third == 's') { AssemblerOutput = asmListingAsmSrc; + } else if (third == 'u') { + UseUnicodeForAssemblerListing = _True; } else { AssemblerOutput = asmListingAssemblyOnly; } break; + case 'C': + DisplayFullPaths = _True; + break; case 'a': AssemblerListingLocation = option+3; break; case 'I': ForcedIncludeFiles += option+3; break; + case 'i': + PreprocessOutputPath += option+3; + break; case 'R': BrowseInformation = brAllInfo; BrowseInformationFile = option+3; @@ -522,6 +552,8 @@ bool VCCLCompilerTool::parseOption(const char* option) break; case 'S': BufferSecurityCheck = _True; + if(third == '-') + BufferSecurityCheck = _False; break; case 'T': EnableFiberSafeOptimizations = _True; @@ -599,10 +631,14 @@ bool VCCLCompilerTool::parseOption(const char* option) RuntimeLibrary = rtMultiThreadedDebug; break; } else if (second == 'P') { - if (config->CompilerVersion >= NET2005) + if (config->CompilerVersion >= NET2005) { AdditionalOptions += option; - else + } else if (config->CompilerVersion >= NET2010) { + MultiProcessorCompilation = _True; + MultiProcessorCompilationProcessorCount = option+3; + } else { warn_msg(WarnLogic, "/MP option is not supported in Visual C++ < 2005, ignoring."); + } break; } found = false; break; @@ -779,7 +815,12 @@ bool VCCLCompilerTool::parseOption(const char* option) break; case 'p': if(third == '6' && fourth == '4') { - Detect64BitPortabilityProblems = _True; + if (config->CompilerVersion >= NET2010) { + // Deprecated for VS2010 but can be used under Additional Options. + AdditionalOptions += option; + } else { + Detect64BitPortabilityProblems = _True; + } break; } // Fallthrough @@ -831,7 +872,7 @@ bool VCCLCompilerTool::parseOption(const char* option) DebugInformationFormat = debugEnabled; break; case 'l': - DebugInformationFormat = debugEditAndContinue; + OmitDefaultLibName = _True; break; case 'a': DisableLanguageExtensions = _True; @@ -895,6 +936,9 @@ bool VCCLCompilerTool::parseOption(const char* option) break; } } + } else if (second == 'n' && third == 'a' && fourth == 'l') { + EnablePREfast = _True; + break; } found = false; break; @@ -953,10 +997,34 @@ bool VCCLCompilerTool::parseOption(const char* option) } break; case 'd': - if(second != 'r') { - found = false; break; + if (second == 'r') { + CompileAsManaged = managedAssembly; + break; + } else if (second != 'o' && third == 'c') { + GenerateXMLDocumentationFiles = _True; + XMLDocumentationFileName += option+4; + break; } - CompileAsManaged = managedAssembly; + found = false; + break; + case 'e': + if (second == 'r' && third == 'r' && fourth == 'o') { + if (option[12] == ':') { + if ( option[13] == 'n') { + ErrorReporting = "None"; + } else if (option[13] == 'p') { + ErrorReporting = "Prompt"; + } else if (option[13] == 'q') { + ErrorReporting = "Queue"; + } else if (option[13] == 's') { + ErrorReporting = "Send"; + } else { + found = false; + } + break; + } + } + found = false; break; case 'f': if(second == 'p' && third == ':') { @@ -1039,7 +1107,8 @@ bool VCCLCompilerTool::parseOption(const char* option) // VCLinkerTool ----------------------------------------------------- VCLinkerTool::VCLinkerTool() - : EnableCOMDATFolding(optFoldingDefault), + : DataExecutionPrevention(unset), + EnableCOMDATFolding(optFoldingDefault), GenerateDebugInformation(unset), GenerateMapFile(unset), HeapCommitSize(-1), @@ -1055,6 +1124,7 @@ VCLinkerTool::VCLinkerTool() MapLines(unset), OptimizeForWindows98(optWin98Default), OptimizeReferences(optReferencesDefault), + RandomizedBaseAddress(unset), RegisterOutput(unset), ResourceOnlyDLL(unset), SetChecksum(unset), @@ -1068,8 +1138,18 @@ VCLinkerTool::VCLinkerTool() SwapRunFromNet(unset), TargetMachine(machineNotSet), TerminalServerAware(termSvrAwareDefault), + TreatWarningsAsErrors(unset), TurnOffAssemblyGeneration(unset), - TypeLibraryResourceID(0) + TypeLibraryResourceID(0), + GenerateManifest(unset), + EnableUAC(unset), + UACUIAccess(unset), + SectionAlignment(-1), + PreventDllBinding(unset), + AllowIsolation(unset), + AssemblyDebug(unset), + CLRUnmanagedCodeCheck(unset), + DelaySign(unset) { } @@ -1142,26 +1222,57 @@ bool VCLinkerTool::parseOption(const char* option) displayHash("POSIX"); displayHash("WINDOWS"); displayHash("WINDOWSCE"); displayHash("NET"); displayHash("CD"); displayHash("NO"); #endif bool found = true; - switch (elfHash(option)) { - case 0x3360dbe: // /ALIGN[:number] - case 0x1485c34: // /ALLOWBIND[:NO] + const uint optionHash = elfHash(option); + if (config->CompilerVersion < NET2010) { + switch (optionHash) { + case 0x3360dbe: // /ALIGN[:number] + case 0x1485c34: // /ALLOWBIND[:NO] + case 0x33aec94: // /FIXED[:NO] + case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] + case 0x0348992: // /STUB:filename + AdditionalOptions += option; + return true; + } + } + + switch (optionHash) { case 0x6b21972: // /DEFAULTLIB:library case 0x396ea92: // /DRIVER[:UPONLY | :WDM] case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386] case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA] - case 0x33aec94: // /FIXED[:NO] case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED] case 0x3dc3455: // /IGNORE:number,number,number,number ### NOTE: This one is undocumented, but it is even used by Microsoft. // In recent versions of the Microsoft linker they have disabled this undocumented feature. - case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] - case 0x0348992: // /STUB:filename case 0x0034bc4: // /VXD - case 0x0034c50: // /WS AdditionalOptions += option; break; + case 0x3360dbe: // /ALIGN[:number] + SectionAlignment = QString(option+7).toLongLong(); + break; + case 0x1485c34: // /ALLOWBIND[:NO] + if(*(option+10) == ':' && (*(option+11) == 'n' || *(option+11) == 'N')) + PreventDllBinding = _False; + else + PreventDllBinding = _True; + break; + case 0x312011e: // /ALLOWISOLATION[:NO] + if(*(option+15) == ':' && (*(option+16) == 'n' || *(option+16) == 'N')) + AllowIsolation = _False; + else + AllowIsolation = _True; + break; case 0x679c075: // /ASSEMBLYMODULE:filename AddModuleNamesToAssembly += option+15; break; + case 0x75f35f7: // /ASSEMBLYDEBUG[:DISABLE] + if(*(option+14) == ':' && (*(option+15) == 'D')) + AssemblyDebug = _False; + else + AssemblyDebug = _True; + break; + case 0x43294a5: // /ASSEMBLYLINKRESOURCE:filename + AssemblyLinkResource += option+22; + break; case 0x062d065: // /ASSEMBLYRESOURCE:filename LinkToManagedResourceFile = option+18; break; @@ -1171,6 +1282,71 @@ bool VCLinkerTool::parseOption(const char* option) // We don't use it in Qt, so keep it simple for now BaseAddress = option+6; break; + case 0x63bf065: // /CLRIMAGETYPE:{IJW|PURE|SAFE} + if(*(option+14) == 'I') + CLRImageType = "ForceIJWImage"; + else if(*(option+14) == 'P') + CLRImageType = "ForcePureILImage"; + else if(*(option+14) == 'S') + CLRImageType = "ForceSafeILImage"; + break; + case 0x5f2a6a2: // /CLRSUPPORTLASTERROR{:NO | SYSTEMDLL} + if(*(option+20) == ':') { + if(*(option+21) == 'N') { + CLRSupportLastError = "Disabled"; + } else if(*(option+21) == 'S') { + CLRSupportLastError = "SystemDlls"; + } + } else { + CLRSupportLastError = "Enabled"; + } + break; + case 0xc7984f5: // /CLRTHREADATTRIBUTE:{STA|MTA|NONE} + if(*(option+20) == 'N') + CLRThreadAttribute = "DefaultThreadingAttribute"; + else if(*(option+20) == 'M') + CLRThreadAttribute = "MTAThreadingAttribute"; + else if(*(option+20) == 'S') + CLRThreadAttribute = "STAThreadingAttribute"; + break; + case 0xa8c637b: // /CLRUNMANAGEDCODECHECK[:NO] + if(*(option+23) == 'N') + CLRUnmanagedCodeCheck = _False; + else + CLRUnmanagedCodeCheck = _True; + break; + case 0x62d9e94: // /MANIFEST[:NO] + if ((*(option+9) == ':' && (*(option+10) == 'N' || *(option+10) == 'n'))) + GenerateManifest = _False; + else + GenerateManifest = _True; + break; + case 0x8b64559: // /MANIFESTDEPENDENCY:manifest_dependency + AdditionalManifestDependencies += option+20; + break; + case 0xe9e8195: // /MANIFESTFILE:filename + ManifestFile = option+14; + break; + case 0x9e9fb83: // /MANIFESTUAC http://msdn.microsoft.com/en-us/library/bb384691%28VS.100%29.aspx + if ((*(option+12) == ':' && (*(option+13) == 'N' || *(option+13) == 'n'))) + EnableUAC = _False; + else if((*(option+12) == ':' && (*(option+13) == 'l' || *(option+14) == 'e'))) { // level + if(*(option+20) == 'a') + UACExecutionLevel = "AsInvoker"; + else if(*(option+20) == 'h') + UACExecutionLevel = "HighestAvailable"; + else if(*(option+20) == 'r') + UACExecutionLevel = "RequireAdministrator"; + } else if((*(option+12) == ':' && (*(option+13) == 'u' || *(option+14) == 'i'))) { // uiAccess + if(*(option+22) == 't') + UACUIAccess = _True; + else + UACUIAccess = _False; + } else if((*(option+12) == ':' && (*(option+13) == 'f' || *(option+14) == 'r'))) { // fragment + AdditionalOptions += option; + }else + EnableUAC = _True; + break; case 0x3389797: // /DEBUG GenerateDebugInformation = _True; break; @@ -1185,12 +1361,36 @@ bool VCLinkerTool::parseOption(const char* option) case 0x06f4bf4: // /DELAYLOAD:dllname DelayLoadDLLs += option+11; break; + case 0x06d451e: // /DELAYSIGN[:NO] + if(*(option+10) == ':' && (*(option+11) == 'n' || *(option+11) == 'N')) + DelaySign = _False; + else + DelaySign = _True; + break; case 0x003390c: // /DLL // This option is not used for vcproj files break; + case 0x2ee8415: // /DYNAMICBASE[:NO] + if(*(option+12) == ':' && (*(option+13) == 'n' || *(option+13) == 'N')) + RandomizedBaseAddress = _False; + else + RandomizedBaseAddress = _True; + break; case 0x33a3979: // /ENTRY:function EntryPointSymbol = option+7; break; + case 0x4504334: // /ERRORREPORT:[ NONE | PROMPT | QUEUE | SEND ] + if(*(option+12) == ':' ) { + if(*(option+13) == 'N') + LinkErrorReporting = "NoErrorReport"; + else if(*(option+13) == 'P') + LinkErrorReporting = "PromptImmediately"; + else if(*(option+13) == 'Q') + LinkErrorReporting = "QueueForNextLogin"; + else if(*(option+13) == 'S') + LinkErrorReporting = "SendErrorReport"; + } + break; case 0x033c960: // /HEAP:reserve[,commit] { QStringList both = QString(option+6).split(","); @@ -1218,6 +1418,12 @@ bool VCLinkerTool::parseOption(const char* option) else LinkIncremental = linkIncrementalYes; break; + case 0x07f1ab2: // /KEYCONTAINER:name + KeyContainer = option+14; + break; + case 0xfadaf35: // /KEYFILE:filename + KeyFile = option+9; + break; case 0x26e4675: // /LARGEADDRESSAWARE[:no] if(*(option+18) == ':' && *(option+19) == 'n') @@ -1322,6 +1528,12 @@ bool VCLinkerTool::parseOption(const char* option) case 0x434138f: // /NOLOGO SuppressStartupBanner = _True; break; + case 0xc841054: // /NXCOMPAT[:NO] + if ((*(option+9) == ':' && (*(option+10) == 'N' || *(option+10) == 'n'))) + DataExecutionPrevention = _False; + else + DataExecutionPrevention = _True; + break; case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98} { char third = *(option+7); @@ -1399,7 +1611,7 @@ bool VCLinkerTool::parseOption(const char* option) case 0x5268ea5: // NATIVE case 0x05547e8: // POSIX case 0x2949c95: // WINDOWSCE - case 0x4B69795: // windowsce + case 0x4B69795: // windowsce AdditionalOptions += option; break; default: @@ -1438,6 +1650,16 @@ bool VCLinkerTool::parseOption(const char* option) case 0xaa77f7e: // /VERSION:major[.minor] Version = option+9; break; + case 0x0034c50: // /WS[:NO] + if (config->CompilerVersion >= NET2010) { + if(*(option+3) == ':') + TreatWarningsAsErrors = _False; + else + TreatWarningsAsErrors = _True; + } else { + AdditionalOptions += option; + } + break; default: AdditionalOptions += option; break; @@ -1467,7 +1689,11 @@ VCMIDLTool::VCMIDLTool() TargetEnvironment(midlTargetNotSet), ValidateParameters(unset), WarnAsError(unset), - WarningLevel(midlWarningLevel_0) + WarningLevel(midlWarningLevel_0), + ApplicationConfigurationMode(unset), + ValidateAllParameters(unset), + SuppressCompilerWarnings(unset), + LocaleID(-1) { } @@ -1503,7 +1729,25 @@ bool VCMIDLTool::parseOption(const char* option) #endif bool found = true; int offset = 0; - switch(elfHash(option)) { + + const uint optionHash = elfHash(option); + + if (config->CompilerVersion < NET2010) { + switch (optionHash) { + case 0x5b1cb97: // /app_config + case 0x5a2fc64: // /client {none|stub} + case 0x35aabb2: // /cstub filename + case 0x64ceb12: // /newtlb + case 0x556dbee: // /no_warn + case 0x662bb12: // /oldtlb + case 0x69c9cf2: // /server {none|stub} + case 0x36aabb2: // /sstub filename + AdditionalOptions += option; + return true; + } + } + + switch(optionHash) { case 0x0000334: // /D name[=def] PreprocessorDefinitions += option+3; break; @@ -1540,6 +1784,9 @@ bool VCMIDLTool::parseOption(const char* option) found = false; } break; + case 0x5b1cb97: // /app_config + ApplicationConfigurationMode = _True; + break; case 0x0359e82: // /char {ascii7|signed|unsigned} switch(*(option+6)) { case 'a': @@ -1555,9 +1802,18 @@ bool VCMIDLTool::parseOption(const char* option) found = false; } break; + case 0x5a2fc64: // /client {none|stub} + if(*(option+8) == 's') + GenerateClientFiles = "Stub"; + else + GenerateClientFiles = "None"; + break; case 0xa766524: // /cpp_opt options CPreprocessOptions += option+9; break; + case 0x35aabb2: // /cstub filename + ClientStubFile = option+7; + break; case 0xb32abf1: // /dlldata filename DLLDataFileName = option + 9; break; @@ -1603,18 +1859,30 @@ bool VCMIDLTool::parseOption(const char* option) case 0x64b7933: // /mktyplib203 MkTypLibCompatible = _True; break; + case 0x64ceb12: // /newtlb + TypeLibFormat = "NewFormat"; + break; case 0x8e0b0a2: // /no_def_idir IgnoreStandardIncludePath = _True; break; case 0x65635ef: // /nologo SuppressStartupBanner = _True; break; + case 0x695e9f4: // /no_robust + ValidateAllParameters = _False; + break; case 0x3656b22: // /notlb GenerateTypeLibrary = _True; break; + case 0x556dbee: // /no_warn + SuppressCompilerWarnings = _True; + break; case 0x000035f: // /o filename RedirectOutputAndErrors = option+3; break; + case 0x662bb12: // /oldtlb + TypeLibFormat = "OldFormat"; + break; case 0x00366c4: // /out directory OutputDirectory = option+5; break; @@ -1630,6 +1898,15 @@ bool VCMIDLTool::parseOption(const char* option) else TargetEnvironment = midlTargetWin32; break; + case 0x69c9cf2: // /server {none|stub} + if(*(option+8) == 's') + GenerateServerFiles = "Stub"; + else + GenerateServerFiles = "None"; + break; + case 0x36aabb2: // /sstub filename + ServerStubFile = option+7; + break; case 0x0036b22: // /tlb filename TypeLibraryName = option+5; break; @@ -1644,32 +1921,24 @@ bool VCMIDLTool::parseOption(const char* option) case 0x0003463: // /Os case 0x0003513: // /Zs case 0x0035796: // /acf filename - case 0x5b1cb97: // /app_config case 0x3595cf4: // /c_ext - case 0x5a2fc64: // /client {none|stub} case 0xa64d3dd: // /confirm case 0xa765b64: // /cpp_cmd cmd_line - case 0x35aabb2: // /cstub filename case 0x03629f4: // /lcid case 0x6495cc4: // /ms_ext case 0x96c7a1e: // /ms_union case 0x4996fa2: // /msc_ver - case 0x64ceb12: // /newtlb case 0x6555a40: // /no_cpp case 0xf64d6a6: // /no_default_epv case 0x6dd9384: // /no_format_opt - case 0x556dbee: // /no_warn case 0x3655a70: // /nocpp case 0x2b455a3: // /oldnames - case 0x662bb12: // /oldtlb case 0x0036696: // /osf case 0x036679b: // /pack {N} case 0x678bd38: // /prefix {all|client|server|switch} case 0x96b702c: // /protocol {all|dce|ndr64} case 0x3696aa3: // /rpcss case 0x698ca60: // /savePP - case 0x69c9cf2: // /server {none|stub} - case 0x36aabb2: // /sstub filename case 0xce9b12b: // /syntax_check case 0xc9b5f16: // /use_epv AdditionalOptions += option; @@ -1721,7 +1990,8 @@ VCCustomBuildTool::VCCustomBuildTool() VCResourceCompilerTool::VCResourceCompilerTool() : Culture(rcUseDefault), IgnoreStandardIncludePath(unset), - ShowProgress(linkProgressNotSet) + ShowProgress(linkProgressNotSet), + SuppressStartupBanner(unset) { PreprocessorDefinitions = QStringList("NDEBUG"); } @@ -1734,22 +2004,31 @@ VCDeploymentTool::VCDeploymentTool() RemoteDirectory = ""; } +VCEventTool::VCEventTool(const QString &eventName) + : ExcludedFromBuild(unset) +{ + EventName = eventName; + ToolName = "VC"; + ToolName += eventName; + ToolName += "Tool"; +} + // VCPostBuildEventTool --------------------------------------------- VCPostBuildEventTool::VCPostBuildEventTool() + : VCEventTool("PostBuildEvent") { - ToolName = "VCPostBuildEventTool"; } // VCPreBuildEventTool ---------------------------------------------- VCPreBuildEventTool::VCPreBuildEventTool() + : VCEventTool("PreBuildEvent") { - ToolName = "VCPreBuildEventTool"; } // VCPreLinkEventTool ----------------------------------------------- VCPreLinkEventTool::VCPreLinkEventTool() + : VCEventTool("PreLinkEvent") { - ToolName = "VCPreLinkEventTool"; } // VCConfiguration -------------------------------------------------- @@ -1767,6 +2046,7 @@ VCConfiguration::VCConfiguration() compiler.config = this; linker.config = this; idl.config = this; + custom.config = this; } // VCFilter --------------------------------------------------------- @@ -1830,7 +2110,9 @@ void VCFilter::modifyPCHstage(QString str) lines << "*"; lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was"; lines << "* specified, and is used as the common stdafx.cpp. The file is only"; - lines << "* generated when creating .vcproj project files, and is not used for"; + lines << "* generated when creating "; + lines << (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj"); + lines << " project files, and is not used for"; lines << "* command line compilations by nmake."; lines << "*"; lines << "* WARNING: All changes made in this file will be lost."; diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index bb692b1..85c7a5c 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -86,6 +86,9 @@ enum triState { _False = 0, _True = 1 }; + +triState operator!(const triState &rhs); + enum addressAwarenessType { addrAwareDefault, addrAwareNoLarge, @@ -520,6 +523,7 @@ public: QStringList ForcedIncludeFiles; QStringList ForcedUsingFiles; preprocessOption GeneratePreprocessedFile; + triState PreprocessSuppressLineNumbers; triState GlobalOptimizations; triState IgnoreStandardIncludePath; triState ImproveFloatingPointConsistency; @@ -527,6 +531,7 @@ public: triState KeepComments; triState MinimalRebuild; QString ObjectFile; + triState OmitDefaultLibName; triState OmitFramePointers; triState OpenMP; optimizeOption Optimization; @@ -549,11 +554,24 @@ public: triState UndefineAllPreprocessorDefinitions; QStringList UndefinePreprocessorDefinitions; pchOption UsePrecompiledHeader; + triState UseUnicodeForAssemblerListing; triState WarnAsError; warningLevelOption WarningLevel; triState WholeProgramOptimization; useOfArchitecture CompileForArchitecture; triState InterworkCalls; + + // VS2010 + triState EnablePREfast; + triState DisplayFullPaths; + triState MultiProcessorCompilation; + QString MultiProcessorCompilationProcessorCount; + triState GenerateXMLDocumentationFiles; + QString XMLDocumentationFileName; + QString ErrorReporting; + triState CreateHotpatchableImage; + QString PreprocessOutputPath; + VCConfiguration* config; }; @@ -571,6 +589,7 @@ public: QStringList AdditionalOptions; QStringList AddModuleNamesToAssembly; QString BaseAddress; + triState DataExecutionPrevention; QStringList DelayLoadDLLs; optFoldingType EnableCOMDATFolding; QString EntryPointSymbol; @@ -601,6 +620,7 @@ public: optRefType OptimizeReferences; QString OutputFile; QString ProgramDatabaseFile; + triState RandomizedBaseAddress; triState RegisterOutput; triState ResourceOnlyDLL; triState SetChecksum; @@ -615,10 +635,33 @@ public: triState SwapRunFromNet; machineTypeOption TargetMachine; termSvrAwarenessType TerminalServerAware; + triState TreatWarningsAsErrors; triState TurnOffAssemblyGeneration; QString TypeLibraryFile; qlonglong TypeLibraryResourceID; QString Version; + + // VS2010 + triState GenerateManifest; + QStringList AdditionalManifestDependencies; + QString ManifestFile; + triState EnableUAC; + QString UACExecutionLevel; + triState UACUIAccess; + qlonglong SectionAlignment; + triState PreventDllBinding; + triState AllowIsolation; + triState AssemblyDebug; + QStringList AssemblyLinkResource; + QString CLRImageType; + QString CLRSupportLastError; + QString CLRThreadAttribute; + triState CLRUnmanagedCodeCheck; + triState DelaySign; + QString KeyContainer; + QString KeyFile; + QString LinkErrorReporting; + VCConfiguration* config; }; @@ -661,6 +704,18 @@ public: triState ValidateParameters; triState WarnAsError; midlWarningLevelOption WarningLevel; + + // VS 2010 + triState ApplicationConfigurationMode; + QString GenerateClientFiles; + QString ClientStubFile; + QString TypeLibFormat; + triState ValidateAllParameters; + triState SuppressCompilerWarnings; + QString GenerateServerFiles; + QString ServerStubFile; + qlonglong LocaleID; + VCConfiguration* config; }; @@ -700,6 +755,8 @@ public: QStringList Outputs; QString ToolName; QString ToolPath; + + VCConfiguration* config; }; class VCResourceCompilerTool : public VCToolBase @@ -720,6 +777,7 @@ public: QString ResourceOutputFileName; linkProgressOption ShowProgress; QString ToolPath; + triState SuppressStartupBanner; }; class VCDeploymentTool @@ -740,15 +798,16 @@ class VCEventTool : public VCToolBase { protected: // Functions - VCEventTool() : ExcludedFromBuild(unset){}; + VCEventTool(const QString &eventName); virtual ~VCEventTool(){} - bool parseOption(const char*){ return false; }; + bool parseOption(const char*){ return false; } public: // Variables QString CommandLine; QString Description; triState ExcludedFromBuild; + QString EventName; QString ToolName; QString ToolPath; }; @@ -791,7 +850,8 @@ public: QString DeleteExtensionsOnClean; QString ImportLibrary; QString IntermediateDirectory; - QString Name; + QString Name; // "ConfigurationName|PlatformName" + QString ConfigurationName; QString OutputDirectory; QString PrimaryOutput; QString ProgramDatabase; diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index b95e9cf..f282deb 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -63,7 +63,6 @@ QT_BEGIN_NAMESPACE VcxprojGenerator::VcxprojGenerator() : VcprojGenerator() { - projectWriter = new VCXProjectWriter; } VCProjectWriter *VcxprojGenerator::createProjectWriter() @@ -120,7 +119,7 @@ void VcxprojGenerator::initProject() vcxProject.Keyword = project->first("VCPROJ_KEYWORD"); vcxProject.PlatformName = vcxProject.Configuration.idl.TargetEnvironment; - if (vcxProject.Configuration.idl.TargetEnvironment.isEmpty()) + if (vcxProject.Configuration.idl.TargetEnvironment == midlTargetNotSet) vcxProject.PlatformName = "Win32"; // These are not used by Qt, but may be used by customers vcxProject.SccProjectName = project->first("SCCPROJECTNAME"); @@ -134,7 +133,7 @@ void VcxprojGenerator::initConfiguration() // Initialize XML sub elements // - Do this first since main configuration elements may need // - to know of certain compiler/linker options - VCXConfiguration &conf = vcxProject.Configuration; + VCConfiguration &conf = vcxProject.Configuration; initCompilerTool(); @@ -154,14 +153,14 @@ void VcxprojGenerator::initConfiguration() QString temp = project->first("BuildBrowserInformation"); switch (projectTarget) { case SharedLib: - conf.ConfigurationType = "DynamicLibrary"; + conf.ConfigurationType = typeDynamicLibrary; break; case StaticLib: - conf.ConfigurationType = "StaticLibrary"; + conf.ConfigurationType = typeStaticLibrary; break; case Application: default: - conf.ConfigurationType = "Application"; + conf.ConfigurationType = typeApplication; break; } @@ -174,35 +173,19 @@ void VcxprojGenerator::initConfiguration() conf.OutputDirectory += '\\'; // The target name could have been changed. - conf.TargetName = project->first("TARGET"); - if ( !conf.TargetName.isEmpty() && !project->first("TARGET_VERSION_EXT").isEmpty() && project->isActiveConfig("shared")) - conf.TargetName.append(project->first("TARGET_VERSION_EXT")); + conf.PrimaryOutput = project->first("TARGET"); + if ( !conf.PrimaryOutput.isEmpty() && !project->first("TARGET_VERSION_EXT").isEmpty() && project->isActiveConfig("shared")) + conf.PrimaryOutput.append(project->first("TARGET_VERSION_EXT")); conf.Name = project->values("BUILD_NAME").join(" "); if (conf.Name.isEmpty()) conf.Name = isDebug ? "Debug" : "Release"; conf.ConfigurationName = conf.Name; - conf.Name += (conf.idl.TargetEnvironment == "Win64" ? "|Win64" : "|Win32"); + conf.Name += (conf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32"); conf.ATLMinimizesCRunTimeLibraryUsage = (project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True); conf.BuildBrowserInformation = triState(temp.isEmpty() ? (short)unset : temp.toShort()); temp = project->first("CharacterSet"); - if (!temp.isEmpty()) - { - switch (charSet(temp.toShort())) { - - case charSetMBCS: - conf.CharacterSet = "MultiByte"; - break; - case charSetUnicode: - conf.CharacterSet = "Unicode"; - break; - case charSetNotSet: - default: - conf.CharacterSet = "NotSet"; - break; - } - conf.CharacterSet = charSet(temp.isEmpty() ? (short)charSetNotSet : temp.toShort()); - } + conf.CharacterSet = charSet(temp.isEmpty() ? (short)charSetNotSet : temp.toShort()); conf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); conf.ImportLibrary = conf.linker.ImportLibrary; conf.IntermediateDirectory = project->first("OBJECTS_DIR"); @@ -211,38 +194,10 @@ void VcxprojGenerator::initConfiguration() conf.WholeProgramOptimization = conf.compiler.WholeProgramOptimization; temp = project->first("UseOfATL"); if(!temp.isEmpty()) - { - switch (useOfATL(temp.toShort())) { - - case useATLStatic: - conf.UseOfATL = "Static"; - break; - case useATLDynamic: - conf.UseOfATL = "Dynamic"; - break; - case useATLNotSet: - default: - conf.UseOfATL = "false"; - break; - } - } + conf.UseOfATL = useOfATL(temp.toShort()); temp = project->first("UseOfMfc"); if(!temp.isEmpty()) - { - switch (useOfMfc(temp.toShort())) { - - case useMfcStatic: - conf.UseOfMfc = "Static"; - break; - case useMfcDynamic: - conf.UseOfMfc = "Dynamic"; - break; - case useMfcStdWin: - default: - conf.UseOfMfc = "false"; - break; - } - } + conf.UseOfMfc = useOfMfc(temp.toShort()); // Configuration does not need parameters from // these sub XML items; @@ -265,18 +220,18 @@ void VcxprojGenerator::initCompilerTool() if(placement.isEmpty()) placement = ".\\"; - VCXConfiguration &conf = vcxProject.Configuration; + VCConfiguration &conf = vcxProject.Configuration; conf.compiler.AssemblerListingLocation = placement ; conf.compiler.ProgramDataBaseFileName = ".\\" ; - conf.compiler.ObjectFileName = placement ; - conf.compiler.ExceptionHandling = "false"; + conf.compiler.ObjectFile = placement ; + conf.compiler.ExceptionHandling = ehNone; // PCH if (usePCH) { - conf.compiler.PrecompiledHeader = "Use"; - conf.compiler.PrecompiledHeaderOutputFile = "$(IntDir)\\" + precompPch; - conf.compiler.PrecompiledHeaderFile = project->first("PRECOMPILED_HEADER"); + conf.compiler.UsePrecompiledHeader = pchUseUsingSpecific; + conf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch; + conf.compiler.PrecompiledHeaderThrough = project->first("PRECOMPILED_HEADER"); conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER"); - conf.compiler.PreprocessToFile = _False; + conf.compiler.GeneratePreprocessedFile = preprocessNo; conf.compiler.PreprocessSuppressLineNumbers = _False; } @@ -295,7 +250,7 @@ void VcxprojGenerator::initCompilerTool() void VcxprojGenerator::initLinkerTool() { findLibraries(); // Need to add the highest version of the libs - VCXConfiguration &conf = vcxProject.Configuration; + VCConfiguration &conf = vcxProject.Configuration; conf.linker.parseOptions(project->values("MSVCPROJ_LFLAGS")); foreach(QString libs, project->values("MSVCPROJ_LIBS")) { @@ -334,7 +289,7 @@ void VcxprojGenerator::initLinkerTool() void VcxprojGenerator::initResourceTool() { - VCXConfiguration &conf = vcxProject.Configuration; + VCConfiguration &conf = vcxProject.Configuration; conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions; // We need to add _DEBUG for the debug version of the project, since the normal compiler defines @@ -349,12 +304,12 @@ void VcxprojGenerator::initResourceTool() void VcxprojGenerator::initPostBuildEventTools() { - VCXConfiguration &conf = vcxProject.Configuration; + VCConfiguration &conf = vcxProject.Configuration; if(!project->values("QMAKE_POST_LINK").isEmpty()) { QString cmdline = var("QMAKE_POST_LINK"); conf.postBuild.CommandLine = cmdline; conf.postBuild.Description = cmdline; - conf.postBuild.UseInBuild = _True; + conf.postBuild.ExcludedFromBuild = _False; } if(!project->values("MSVCPROJ_COPY_DLL").isEmpty()) { @@ -362,18 +317,18 @@ void VcxprojGenerator::initPostBuildEventTools() conf.postBuild.CommandLine += " && "; conf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC"); conf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL"); - conf.postBuild.UseInBuild = _True; + conf.postBuild.ExcludedFromBuild = _False; } } void VcxprojGenerator::initPreLinkEventTools() { - VCXConfiguration &conf = vcxProject.Configuration; + VCConfiguration &conf = vcxProject.Configuration; if(!project->values("QMAKE_PRE_LINK").isEmpty()) { QString cmdline = var("QMAKE_PRE_LINK"); conf.preLink.Description = cmdline; conf.preLink.CommandLine = cmdline; - conf.preLink.UseInBuild = _True; + conf.preLink.ExcludedFromBuild = _False; } } @@ -548,7 +503,7 @@ void VcxprojGenerator::initExtraCompilerOutputs() extracompilerName = (*it); // Create an extra compiler filter and add the files - VCXFilter extraCompile; + VCFilter extraCompile; extraCompile.Name = extracompilerName; extraCompile.ParseFiles = _False; extraCompile.Filter = ""; @@ -626,9 +581,9 @@ bool VcxprojGenerator::writeProjectMakefile() } debug_msg(1, "Generator: MSVC.NET: Writing project file"); - VCXProject mergedProject; + VCProject mergedProject; for (int i = 0; i < mergedProjects.count(); ++i) { - VCXProjectSingleConfig *singleProject = &(mergedProjects.at(i)->vcxProject); + VCProjectSingleConfig *singleProject = &(mergedProjects.at(i)->vcxProject); mergedProject.SingleProjects += *singleProject; for (int j = 0; j < singleProject->ExtraCompilersFiles.count(); ++j) { const QString &compilerName = singleProject->ExtraCompilersFiles.at(j).Name; diff --git a/qmake/generators/win32/msvc_vcxproj.h b/qmake/generators/win32/msvc_vcxproj.h index bc79c0b..16e02b1 100644 --- a/qmake/generators/win32/msvc_vcxproj.h +++ b/qmake/generators/win32/msvc_vcxproj.h @@ -56,7 +56,6 @@ class VcxprojGenerator : public VcprojGenerator public: VcxprojGenerator(); ~VcxprojGenerator(); - VCXProjectWriter *projectWriter; // ### remove, once we've killed the VCX classes protected: virtual VCProjectWriter *createProjectWriter(); @@ -83,13 +82,13 @@ protected: void initExtraCompilerOutputs(); // Used for single project - VCXProjectSingleConfig vcxProject; + VCProjectSingleConfig vcxProject; // Holds all configurations for glue (merged) project QList mergedProjects; private: - friend class VCXFilter; + friend class VCFilter; }; -- cgit v0.12 From 2f531e4280fc74d1cbad09a79d8504c7d0a90f4c Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 5 Aug 2010 18:40:13 +0200 Subject: qmake: remove duplicated code from VcxprojGenerator Rubber-stamped-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 36 ++- qmake/generators/win32/msvc_vcxproj.cpp | 557 -------------------------------- qmake/generators/win32/msvc_vcxproj.h | 30 -- 3 files changed, 28 insertions(+), 595 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 55d50c0..449dcb0 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -873,9 +873,27 @@ void VcprojGenerator::initConfiguration() break; } + if (conf.CompilerVersion >= NET2010) { + conf.OutputDirectory = project->first("DESTDIR"); + + if(conf.OutputDirectory.isEmpty()) + conf.OutputDirectory = ".\\"; + + if(!conf.OutputDirectory.endsWith("\\")) + conf.OutputDirectory += '\\'; + + // The target name could have been changed. + conf.PrimaryOutput = project->first("TARGET"); + if ( !conf.PrimaryOutput.isEmpty() && !project->first("TARGET_VERSION_EXT").isEmpty() && project->isActiveConfig("shared")) + conf.PrimaryOutput.append(project->first("TARGET_VERSION_EXT")); + } else { + conf.PrimaryOutput = project->first("PrimaryOutput"); + } + conf.Name = project->values("BUILD_NAME").join(" "); if (conf.Name.isEmpty()) conf.Name = isDebug ? "Debug" : "Release"; + conf.ConfigurationName = conf.Name; if (project->isEmpty("CE_SDK") || project->isEmpty("CE_ARCH")) { conf.Name += (conf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32"); } else { @@ -889,7 +907,6 @@ void VcprojGenerator::initConfiguration() conf.ImportLibrary = conf.linker.ImportLibrary; conf.IntermediateDirectory = project->first("OBJECTS_DIR"); conf.OutputDirectory = "."; - conf.PrimaryOutput = project->first("PrimaryOutput"); conf.WholeProgramOptimization = conf.compiler.WholeProgramOptimization; temp = project->first("UseOfATL"); if(!temp.isEmpty()) @@ -933,13 +950,16 @@ void VcprojGenerator::initCompilerTool() conf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch; conf.compiler.PrecompiledHeaderThrough = project->first("PRECOMPILED_HEADER"); conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER"); - // Minimal build option triggers an Internal Compiler Error - // when used in conjunction with /FI and /Yu, so remove it - // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. - project->values("QMAKE_CFLAGS_DEBUG").removeAll("-Gm"); - project->values("QMAKE_CFLAGS_DEBUG").removeAll("/Gm"); - project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("-Gm"); - project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("/Gm"); + + if (conf.CompilerVersion <= NET2003) { + // Minimal build option triggers an Internal Compiler Error + // when used in conjunction with /FI and /Yu, so remove it + // ### work-around for a VS 2003 bug. Move to some prf file or remove completely. + project->values("QMAKE_CFLAGS_DEBUG").removeAll("-Gm"); + project->values("QMAKE_CFLAGS_DEBUG").removeAll("/Gm"); + project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("-Gm"); + project->values("QMAKE_CXXFLAGS_DEBUG").removeAll("/Gm"); + } } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); diff --git a/qmake/generators/win32/msvc_vcxproj.cpp b/qmake/generators/win32/msvc_vcxproj.cpp index f282deb..7ba0c65 100644 --- a/qmake/generators/win32/msvc_vcxproj.cpp +++ b/qmake/generators/win32/msvc_vcxproj.cpp @@ -70,562 +70,5 @@ VCProjectWriter *VcxprojGenerator::createProjectWriter() return new VCXProjectWriter; } -bool VcxprojGenerator::writeMakefile(QTextStream &t) -{ - initProject(); // Fills the whole project with proper data - - // Generate solution file - if(project->first("TEMPLATE") == "vcsubdirs") { - if (!project->isActiveConfig("build_pass")) { - debug_msg(1, "Generator: MSVC.NET: Writing solution file"); - writeSubDirs(t); - } else { - debug_msg(1, "Generator: MSVC.NET: Not writing solution file for build_pass configs"); - } - return true; - } else - // Generate single configuration project file - if (project->first("TEMPLATE") == "vcapp" || - project->first("TEMPLATE") == "vclib") { - if(!project->isActiveConfig("build_pass")) { - debug_msg(1, "Generator: MSVC.NET: Writing single configuration project file"); - XmlOutput xmlOut(t); - projectWriter->write(xmlOut, vcxProject); - } - return true; - } - return project->isActiveConfig("build_pass"); -} - - -void VcxprojGenerator::initProject() -{ - // Initialize XML sub elements - // - Do this first since project elements may need - // - to know of certain configuration options - initConfiguration(); - initRootFiles(); - initSourceFiles(); - initHeaderFiles(); - initGeneratedFiles(); - initLexYaccFiles(); - initTranslationFiles(); - initFormFiles(); - initResourceFiles(); - initExtraCompilerOutputs(); - - // Own elements ----------------------------- - vcxProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); - - vcxProject.Keyword = project->first("VCPROJ_KEYWORD"); - vcxProject.PlatformName = vcxProject.Configuration.idl.TargetEnvironment; - if (vcxProject.Configuration.idl.TargetEnvironment == midlTargetNotSet) - vcxProject.PlatformName = "Win32"; - // These are not used by Qt, but may be used by customers - vcxProject.SccProjectName = project->first("SCCPROJECTNAME"); - vcxProject.SccLocalPath = project->first("SCCLOCALPATH"); - vcxProject.flat_files = project->isActiveConfig("flat"); -} - - -void VcxprojGenerator::initConfiguration() -{ - // Initialize XML sub elements - // - Do this first since main configuration elements may need - // - to know of certain compiler/linker options - VCConfiguration &conf = vcxProject.Configuration; - - initCompilerTool(); - - // Only on configuration per build - bool isDebug = project->isActiveConfig("debug"); - - if(projectTarget == StaticLib) - initLibrarianTool(); - else { - conf.linker.GenerateDebugInformation = isDebug ? _True : _False; - initLinkerTool(); - } - initResourceTool(); - initIDLTool(); - - // Own elements ----------------------------- - QString temp = project->first("BuildBrowserInformation"); - switch (projectTarget) { - case SharedLib: - conf.ConfigurationType = typeDynamicLibrary; - break; - case StaticLib: - conf.ConfigurationType = typeStaticLibrary; - break; - case Application: - default: - conf.ConfigurationType = typeApplication; - break; - } - - conf.OutputDirectory = project->first("DESTDIR"); - - if(conf.OutputDirectory.isEmpty()) - conf.OutputDirectory = ".\\"; - - if(!conf.OutputDirectory.endsWith("\\")) - conf.OutputDirectory += '\\'; - - // The target name could have been changed. - conf.PrimaryOutput = project->first("TARGET"); - if ( !conf.PrimaryOutput.isEmpty() && !project->first("TARGET_VERSION_EXT").isEmpty() && project->isActiveConfig("shared")) - conf.PrimaryOutput.append(project->first("TARGET_VERSION_EXT")); - - conf.Name = project->values("BUILD_NAME").join(" "); - if (conf.Name.isEmpty()) - conf.Name = isDebug ? "Debug" : "Release"; - conf.ConfigurationName = conf.Name; - conf.Name += (conf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32"); - conf.ATLMinimizesCRunTimeLibraryUsage = (project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True); - conf.BuildBrowserInformation = triState(temp.isEmpty() ? (short)unset : temp.toShort()); - temp = project->first("CharacterSet"); - conf.CharacterSet = charSet(temp.isEmpty() ? (short)charSetNotSet : temp.toShort()); - conf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); - conf.ImportLibrary = conf.linker.ImportLibrary; - conf.IntermediateDirectory = project->first("OBJECTS_DIR"); - //conf.OutputDirectory = "."; - conf.PrimaryOutput = project->first("PrimaryOutput"); - conf.WholeProgramOptimization = conf.compiler.WholeProgramOptimization; - temp = project->first("UseOfATL"); - if(!temp.isEmpty()) - conf.UseOfATL = useOfATL(temp.toShort()); - temp = project->first("UseOfMfc"); - if(!temp.isEmpty()) - conf.UseOfMfc = useOfMfc(temp.toShort()); - - // Configuration does not need parameters from - // these sub XML items; - initCustomBuildTool(); - initPreBuildEventTools(); - initPostBuildEventTools(); - initPreLinkEventTools(); - - // Set definite values in both configurations - if (isDebug) { - conf.compiler.PreprocessorDefinitions.removeAll("NDEBUG"); - } else { - conf.compiler.PreprocessorDefinitions += "NDEBUG"; - } -} - -void VcxprojGenerator::initCompilerTool() -{ - QString placement = project->first("OBJECTS_DIR"); - if(placement.isEmpty()) - placement = ".\\"; - - VCConfiguration &conf = vcxProject.Configuration; - conf.compiler.AssemblerListingLocation = placement ; - conf.compiler.ProgramDataBaseFileName = ".\\" ; - conf.compiler.ObjectFile = placement ; - conf.compiler.ExceptionHandling = ehNone; - // PCH - if (usePCH) { - conf.compiler.UsePrecompiledHeader = pchUseUsingSpecific; - conf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch; - conf.compiler.PrecompiledHeaderThrough = project->first("PRECOMPILED_HEADER"); - conf.compiler.ForcedIncludeFiles = project->values("PRECOMPILED_HEADER"); - conf.compiler.GeneratePreprocessedFile = preprocessNo; - conf.compiler.PreprocessSuppressLineNumbers = _False; - } - - conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); - - if (project->isActiveConfig("windows")) - conf.compiler.PreprocessorDefinitions += "_WINDOWS"; - else if (project->isActiveConfig("console")) - conf.compiler.PreprocessorDefinitions += "_CONSOLE"; - - conf.compiler.PreprocessorDefinitions += project->values("DEFINES"); - conf.compiler.PreprocessorDefinitions += project->values("PRL_EXPORT_DEFINES"); - conf.compiler.parseOptions(project->values("MSVCPROJ_INCPATH")); -} - -void VcxprojGenerator::initLinkerTool() -{ - findLibraries(); // Need to add the highest version of the libs - VCConfiguration &conf = vcxProject.Configuration; - conf.linker.parseOptions(project->values("MSVCPROJ_LFLAGS")); - - foreach(QString libs, project->values("MSVCPROJ_LIBS")) { - if (libs.left(9).toUpper() == "/LIBPATH:") { - QStringList l = QStringList(libs); - conf.linker.parseOptions(l); - } else { - conf.linker.AdditionalDependencies += libs; - } - } - - switch (projectTarget) { - case Application: - conf.linker.OutputFile = project->first("DESTDIR"); - break; - case SharedLib: - conf.linker.parseOptions(project->values("MSVCPROJ_LIBOPTIONS")); - conf.linker.OutputFile = project->first("DESTDIR"); - break; - case StaticLib: //unhandled - added to remove warnings.. - break; - } - - if(conf.linker.OutputFile.isEmpty()) - conf.linker.OutputFile = ".\\"; - - if(!conf.linker.OutputFile.endsWith("\\")) - conf.linker.OutputFile += '\\'; - - conf.linker.OutputFile += project->first("MSVCPROJ_TARGET"); - - if(project->isActiveConfig("dll")){ - conf.linker.parseOptions(project->values("QMAKE_LFLAGS_QT_DLL")); - } -} - -void VcxprojGenerator::initResourceTool() -{ - VCConfiguration &conf = vcxProject.Configuration; - conf.resource.PreprocessorDefinitions = conf.compiler.PreprocessorDefinitions; - - // We need to add _DEBUG for the debug version of the project, since the normal compiler defines - // do not contain it. (The compiler defines this symbol automatically, which is wy we don't need - // to add it for the compiler) However, the resource tool does not do this. - if(project->isActiveConfig("debug")) - conf.resource.PreprocessorDefinitions += "_DEBUG"; - if(project->isActiveConfig("staticlib")) - conf.resource.ResourceOutputFileName = project->first("DESTDIR") + "/$(InputName).res"; -} - - -void VcxprojGenerator::initPostBuildEventTools() -{ - VCConfiguration &conf = vcxProject.Configuration; - if(!project->values("QMAKE_POST_LINK").isEmpty()) { - QString cmdline = var("QMAKE_POST_LINK"); - conf.postBuild.CommandLine = cmdline; - conf.postBuild.Description = cmdline; - conf.postBuild.ExcludedFromBuild = _False; - } - - if(!project->values("MSVCPROJ_COPY_DLL").isEmpty()) { - if(!conf.postBuild.CommandLine.isEmpty()) - conf.postBuild.CommandLine += " && "; - conf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC"); - conf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL"); - conf.postBuild.ExcludedFromBuild = _False; - } -} - -void VcxprojGenerator::initPreLinkEventTools() -{ - VCConfiguration &conf = vcxProject.Configuration; - if(!project->values("QMAKE_PRE_LINK").isEmpty()) { - QString cmdline = var("QMAKE_PRE_LINK"); - conf.preLink.Description = cmdline; - conf.preLink.CommandLine = cmdline; - conf.preLink.ExcludedFromBuild = _False; - } -} - -void VcxprojGenerator::initRootFiles() -{ - vcxProject.RootFiles.addFiles(project->values("RC_FILE")); - vcxProject.RootFiles.Project = this; - vcxProject.RootFiles.Config = &(vcxProject.Configuration); - vcxProject.RootFiles.CustomBuild = none; -} - -void VcxprojGenerator::initSourceFiles() -{ - vcxProject.SourceFiles.Name = "Source Files"; - vcxProject.SourceFiles.Filter = "cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"; - vcxProject.SourceFiles.Guid = _GUIDSourceFiles; - - vcxProject.SourceFiles.addFiles(project->values("SOURCES")); - - vcxProject.SourceFiles.Project = this; - vcxProject.SourceFiles.Config = &(vcxProject.Configuration); - vcxProject.SourceFiles.CustomBuild = none; -} - -void VcxprojGenerator::initHeaderFiles() -{ - vcxProject.HeaderFiles.Name = "Header Files"; - vcxProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl;inc;xsd"; - vcxProject.HeaderFiles.Guid = _GUIDHeaderFiles; - - vcxProject.HeaderFiles.addFiles(project->values("HEADERS")); - if (usePCH) // Generated PCH cpp file - vcxProject.HeaderFiles.addFile(precompH); - - vcxProject.HeaderFiles.Project = this; - vcxProject.HeaderFiles.Config = &(vcxProject.Configuration); -} - -void VcxprojGenerator::initGeneratedFiles() -{ - vcxProject.GeneratedFiles.Name = "Generated Files"; - vcxProject.GeneratedFiles.Filter = "cpp;c;cxx;moc;h;def;odl;idl;res"; - vcxProject.GeneratedFiles.Guid = _GUIDGeneratedFiles; - - // ### These cannot have CustomBuild (mocSrc)!! - vcxProject.GeneratedFiles.addFiles(project->values("GENERATED_SOURCES")); - vcxProject.GeneratedFiles.addFiles(project->values("GENERATED_FILES")); - vcxProject.GeneratedFiles.addFiles(project->values("IDLSOURCES")); - vcxProject.GeneratedFiles.addFiles(project->values("RES_FILE")); - vcxProject.GeneratedFiles.addFiles(project->values("QMAKE_IMAGE_COLLECTION")); // compat - if(!extraCompilerOutputs.isEmpty()) - vcxProject.GeneratedFiles.addFiles(extraCompilerOutputs.keys()); - - vcxProject.GeneratedFiles.Project = this; - vcxProject.GeneratedFiles.Config = &(vcxProject.Configuration); -} - -void VcxprojGenerator::initLexYaccFiles() -{ - vcxProject.LexYaccFiles.Name = "Lex / Yacc Files"; - vcxProject.LexYaccFiles.ParseFiles = _False; - vcxProject.LexYaccFiles.Filter = "l;y"; - vcxProject.LexYaccFiles.Guid = _GUIDLexYaccFiles; - - vcxProject.LexYaccFiles.addFiles(project->values("LEXSOURCES")); - vcxProject.LexYaccFiles.addFiles(project->values("YACCSOURCES")); - - vcxProject.LexYaccFiles.Project = this; - vcxProject.LexYaccFiles.Config = &(vcxProject.Configuration); - vcxProject.LexYaccFiles.CustomBuild = lexyacc; -} - -void VcxprojGenerator::initTranslationFiles() -{ - vcxProject.TranslationFiles.Name = "Translation Files"; - vcxProject.TranslationFiles.ParseFiles = _False; - vcxProject.TranslationFiles.Filter = "ts;xlf"; - vcxProject.TranslationFiles.Guid = _GUIDTranslationFiles; - - vcxProject.TranslationFiles.addFiles(project->values("TRANSLATIONS")); - - vcxProject.TranslationFiles.Project = this; - vcxProject.TranslationFiles.Config = &(vcxProject.Configuration); - vcxProject.TranslationFiles.CustomBuild = none; -} - - -void VcxprojGenerator::initFormFiles() -{ - vcxProject.FormFiles.Name = "Form Files"; - vcxProject.FormFiles.ParseFiles = _False; - vcxProject.FormFiles.Filter = "ui"; - vcxProject.FormFiles.Guid = _GUIDFormFiles; - - vcxProject.FormFiles.addFiles(project->values("FORMS")); - vcxProject.FormFiles.addFiles(project->values("FORMS3")); - - vcxProject.FormFiles.Project = this; - vcxProject.FormFiles.Config = &(vcxProject.Configuration); - vcxProject.FormFiles.CustomBuild = none; -} - - -void VcxprojGenerator::initResourceFiles() -{ - vcxProject.ResourceFiles.Name = "Resource Files"; - vcxProject.ResourceFiles.ParseFiles = _False; - vcxProject.ResourceFiles.Filter = "qrc;*"; //"rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;ts;xlf;qrc"; - vcxProject.ResourceFiles.Guid = _GUIDResourceFiles; - - // Bad hack, please look away ------------------------------------- - QString rcc_dep_cmd = project->values("rcc.depend_command").join(" "); - if(!rcc_dep_cmd.isEmpty()) { - QStringList qrc_files = project->values("RESOURCES"); - QStringList deps; - if(!qrc_files.isEmpty()) { - for (int i = 0; i < qrc_files.count(); ++i) { - char buff[256]; - QString dep_cmd = replaceExtraCompilerVariables(rcc_dep_cmd, qrc_files.at(i),""); - - dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false); - if(canExecute(dep_cmd)) { - if(FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), "r")) { - QString indeps; - while(!feof(proc)) { - int read_in = (int)fread(buff, 1, 255, proc); - if(!read_in) - break; - indeps += QByteArray(buff, read_in); - } - QT_PCLOSE(proc); - if(!indeps.isEmpty()) - deps += fileFixify(indeps.replace('\n', ' ').simplified().split(' ')); - } - } - } - vcxProject.ResourceFiles.addFiles(deps); - } - } - // You may look again -------------------------------------------- - - vcxProject.ResourceFiles.addFiles(project->values("RESOURCES")); - vcxProject.ResourceFiles.addFiles(project->values("IMAGES")); - - vcxProject.ResourceFiles.Project = this; - vcxProject.ResourceFiles.Config = &(vcxProject.Configuration); - vcxProject.ResourceFiles.CustomBuild = none; -} - -void VcxprojGenerator::initExtraCompilerOutputs() -{ - QStringList otherFilters; - otherFilters << "FORMS" - << "FORMS3" - << "GENERATED_FILES" - << "GENERATED_SOURCES" - << "HEADERS" - << "IDLSOURCES" - << "IMAGES" - << "LEXSOURCES" - << "QMAKE_IMAGE_COLLECTION" - << "RC_FILE" - << "RESOURCES" - << "RES_FILE" - << "SOURCES" - << "TRANSLATIONS" - << "YACCSOURCES"; - const QStringList &quc = project->values("QMAKE_EXTRA_COMPILERS"); - for(QStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { - QString extracompilerName = project->first((*it) + ".name"); - if (extracompilerName.isEmpty()) - extracompilerName = (*it); - - // Create an extra compiler filter and add the files - VCFilter extraCompile; - extraCompile.Name = extracompilerName; - extraCompile.ParseFiles = _False; - extraCompile.Filter = ""; - extraCompile.Guid = QString(_GUIDExtraCompilerFiles) + "-" + (*it); - - // If the extra compiler has a variable_out set the output file - // is added to an other file list, and does not need its own.. - bool addOnInput = hasBuiltinCompiler(project->first((*it) + ".output")); - QString tmp_other_out = project->first((*it) + ".variable_out"); - if (!tmp_other_out.isEmpty() && !addOnInput) - continue; - - if (!addOnInput) { - QString tmp_out = project->first((*it) + ".output"); - if (project->values((*it) + ".CONFIG").indexOf("combine") != -1) { - // Combined output, only one file result - extraCompile.addFile( - Option::fixPathToTargetOS(replaceExtraCompilerVariables(tmp_out, QString(), QString()), false)); - } else { - // One output file per input - QStringList tmp_in = project->values(project->first((*it) + ".input")); - for (int i = 0; i < tmp_in.count(); ++i) { - const QString &filename = tmp_in.at(i); - if (extraCompilerSources.contains(filename)) - extraCompile.addFile( - Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, tmp_out, QString()), false)); - } - } - } else { - // In this case we the outputs have a built-in compiler, so we cannot add the custom - // build steps there. So, we turn it around and add it to the input files instead, - // provided that the input file variable is not handled already (those in otherFilters - // are handled, so we avoid them). - QStringList inputVars = project->values((*it) + ".input"); - foreach(QString inputVar, inputVars) { - if (!otherFilters.contains(inputVar)) { - QStringList tmp_in = project->values(inputVar); - for (int i = 0; i < tmp_in.count(); ++i) { - const QString &filename = tmp_in.at(i); - if (extraCompilerSources.contains(filename)) - extraCompile.addFile( - Option::fixPathToTargetOS(replaceExtraCompilerVariables(filename, QString(), QString()), false)); - } - } - } - } - extraCompile.Project = this; - extraCompile.Config = &(vcxProject.Configuration); - extraCompile.CustomBuild = none; - - vcxProject.ExtraCompilersFiles.append(extraCompile); - } -} - - - -bool VcxprojGenerator::writeProjectMakefile() -{ - usePlatformDir(); - QTextStream t(&Option::output); - - // Check if all requirements are fulfilled - if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) { - fprintf(stderr, "Project file not generated because all requirements not met:\n\t%s\n", - var("QMAKE_FAILED_REQUIREMENTS").toLatin1().constData()); - return true; - } - - // Generate project file - if(project->first("TEMPLATE") == "vcapp" || - project->first("TEMPLATE") == "vclib") { - if (!mergedProjects.count()) { - warn_msg(WarnLogic, "Generator: MSVC.NET: no single configuration created, cannot output project!"); - return false; - } - - debug_msg(1, "Generator: MSVC.NET: Writing project file"); - VCProject mergedProject; - for (int i = 0; i < mergedProjects.count(); ++i) { - VCProjectSingleConfig *singleProject = &(mergedProjects.at(i)->vcxProject); - mergedProject.SingleProjects += *singleProject; - for (int j = 0; j < singleProject->ExtraCompilersFiles.count(); ++j) { - const QString &compilerName = singleProject->ExtraCompilersFiles.at(j).Name; - if (!mergedProject.ExtraCompilers.contains(compilerName)) - mergedProject.ExtraCompilers += compilerName; - } - } - - if(mergedProjects.count() > 1 && - mergedProjects.at(0)->vcxProject.Name == - mergedProjects.at(1)->vcxProject.Name) - mergedProjects.at(0)->writePrlFile(); - mergedProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); - mergedProject.Version = mergedProjects.at(0)->vcxProject.Version; - mergedProject.ProjectGUID = project->isEmpty("QMAKE_UUID") ? getProjectUUID().toString().toUpper() : project->first("QMAKE_UUID"); - mergedProject.Keyword = project->first("VCPROJ_KEYWORD"); - mergedProject.SccProjectName = mergedProjects.at(0)->vcxProject.SccProjectName; - mergedProject.SccLocalPath = mergedProjects.at(0)->vcxProject.SccLocalPath; - mergedProject.PlatformName = mergedProjects.at(0)->vcxProject.PlatformName; - - XmlOutput xmlOut(t); - projectWriter->write(xmlOut, mergedProject); - return true; - } else if(project->first("TEMPLATE") == "vcsubdirs") { - return writeMakefile(t); - } - return false; -} - - - - -bool VcxprojGenerator::mergeBuildProject(MakefileGenerator *other) -{ - VcxprojGenerator *otherVC = static_cast(other); - if (!otherVC) { - warn_msg(WarnLogic, "VcxprojGenerator: Cannot merge other types of projects! (ignored)"); - return false; - } - mergedProjects += otherVC; - return true; -} - QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_vcxproj.h b/qmake/generators/win32/msvc_vcxproj.h index 16e02b1..45e6b95 100644 --- a/qmake/generators/win32/msvc_vcxproj.h +++ b/qmake/generators/win32/msvc_vcxproj.h @@ -50,42 +50,12 @@ QT_BEGIN_NAMESPACE class VcxprojGenerator : public VcprojGenerator { - bool writeMakefile(QTextStream &); - bool writeProjectMakefile(); - public: VcxprojGenerator(); ~VcxprojGenerator(); protected: virtual VCProjectWriter *createProjectWriter(); - virtual bool supportsMetaBuild() { return true; } - virtual bool supportsMergedBuilds() { return true; } - virtual bool mergeBuildProject(MakefileGenerator *other); - - virtual void initProject(); - - void initConfiguration(); - void initCompilerTool(); - void initLinkerTool(); - void initPreLinkEventTools(); - void initPostBuildEventTools(); - void initRootFiles(); - void initResourceTool(); - void initSourceFiles(); - void initHeaderFiles(); - void initGeneratedFiles(); - void initTranslationFiles(); - void initFormFiles(); - void initResourceFiles(); - void initLexYaccFiles(); - void initExtraCompilerOutputs(); - - // Used for single project - VCProjectSingleConfig vcxProject; - - // Holds all configurations for glue (merged) project - QList mergedProjects; private: friend class VCFilter; -- cgit v0.12 From e0c21e2b9020a0996e077ddffb1ea632923095e4 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Aug 2010 12:18:34 +0200 Subject: qmake: move .vcproj XML generation from data classes to VCProjectWriter Rubber-stamped-by: ossi --- qmake/generators/win32/msvc_objectmodel.cpp | 356 ++++++++++++++-------------- qmake/generators/win32/msvc_objectmodel.h | 36 ++- 2 files changed, 189 insertions(+), 203 deletions(-) diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 607de5d..6e1ee8d 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2300,58 +2300,6 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) return useCustomBuildTool; } -void VCFilter::outputFileConfig(XmlOutput &xml, const QString &filename) -{ - // Clearing each filter tool - useCustomBuildTool = false; - useCompilerTool = false; - CustomBuildTool = VCCustomBuildTool(); - CompilerTool = VCCLCompilerTool(); - - // Unset some default options - CompilerTool.BufferSecurityCheck = unset; - CompilerTool.DebugInformationFormat = debugUnknown; - CompilerTool.ExceptionHandling = ehDefault; - CompilerTool.GeneratePreprocessedFile = preprocessUnknown; - CompilerTool.Optimization = optimizeDefault; - CompilerTool.ProgramDataBaseFileName.clear(); - CompilerTool.RuntimeLibrary = rtUnknown; - CompilerTool.WarningLevel = warningLevelUnknown; - CompilerTool.config = Config; - - bool inBuild = false; - VCFilterFile info; - for (int i = 0; i < Files.count(); ++i) { - if (Files.at(i).file == filename) { - info = Files.at(i); - inBuild = true; - } - } - inBuild &= !info.excludeFromBuild; - - if (inBuild) { - addExtraCompiler(info); - if(Project->usePCH) - modifyPCHstage(info.file); - } else { - // Excluded files uses an empty compiler stage - if(info.excludeFromBuild) - useCompilerTool = true; - } - - // Actual XML output ---------------------------------- - if(useCustomBuildTool || useCompilerTool || !inBuild) { - xml << tag(_FileConfiguration) - << attr(_Name, (*Config).Name) - << (!inBuild ? attrS(_ExcludedFromBuild, "true") : noxml()); - if (useCustomBuildTool) - Project->projectWriter->write(xml, CustomBuildTool); - if (useCompilerTool) - Project->projectWriter->write(xml, CompilerTool); - xml << closetag(_FileConfiguration); - } -} - // VCProjectSingleConfig -------------------------------------------- VCFilter& VCProjectSingleConfig::filterForExtraCompiler(const QString &compilerName) { @@ -2386,127 +2334,19 @@ void TreeNode::generateXML(XmlOutput &xml, const QString &tagName, VCProject &to xml << closetag("Filter"); } else { // Leaf - tool.outputFileConfigs(xml, info, filter); + VCProjectWriter::outputFileConfigs(tool, xml, info, filter); } } - // Flat file generation --------------------------------------------- void FlatNode::generateXML(XmlOutput &xml, const QString &/*tagName*/, VCProject &tool, const QString &filter) { if (children.size()) { ChildrenMapFlat::ConstIterator it = children.constBegin(); ChildrenMapFlat::ConstIterator end = children.constEnd(); for (; it != end; ++it) { - tool.outputFileConfigs(xml, (*it), filter); - } - } -} - - -// VCProject -------------------------------------------------------- -// Output all configurations (by filtername) for a file (by info) -// A filters config output is in VCFilter.outputFileConfig() -void VCProject::outputFileConfigs(XmlOutput &xml, -// VCProjectSingleConfig::FilterTypes type - const VCFilterFile &info, - const QString &filtername) -{ - xml << tag(q_File) - << attrS(_RelativePath, Option::fixPathToLocalOS(info.file)); - for (int i = 0; i < SingleProjects.count(); ++i) { - VCFilter filter; - if (filtername == "RootFiles") { - filter = SingleProjects.at(i).RootFiles; - } else if (filtername == "Sources") { - filter = SingleProjects.at(i).SourceFiles; - } else if (filtername == "Headers") { - filter = SingleProjects.at(i).HeaderFiles; - } else if (filtername == "GeneratedFiles") { - filter = SingleProjects.at(i).GeneratedFiles; - } else if (filtername == "LexYaccFiles") { - filter = SingleProjects.at(i).LexYaccFiles; - } else if (filtername == "TranslationFiles") { - filter = SingleProjects.at(i).TranslationFiles; - } else if (filtername == "FormFiles") { - filter = SingleProjects.at(i).FormFiles; - } else if (filtername == "ResourceFiles") { - filter = SingleProjects.at(i).ResourceFiles; - } else { - // ExtraCompilers - filter = SingleProjects[i].filterForExtraCompiler(filtername); - } - - if (filter.Config) // only if the filter is not empty - filter.outputFileConfig(xml, info.file); - } - xml << closetag(q_File); -} - -// outputs a given filter for all existing configurations of a project -void VCProject::outputFilter(XmlOutput &xml, -// VCProjectSingleConfig::FilterTypes type - const QString &filtername) -{ - Node *root; - if (SingleProjects.at(0).flat_files) - root = new FlatNode; - else - root = new TreeNode; - - QString name, extfilter, guid; - triState parse; - - for (int i = 0; i < SingleProjects.count(); ++i) { - VCFilter filter; - if (filtername == "RootFiles") { - filter = SingleProjects.at(i).RootFiles; - } else if (filtername == "Sources") { - filter = SingleProjects.at(i).SourceFiles; - } else if (filtername == "Headers") { - filter = SingleProjects.at(i).HeaderFiles; - } else if (filtername == "GeneratedFiles") { - filter = SingleProjects.at(i).GeneratedFiles; - } else if (filtername == "LexYaccFiles") { - filter = SingleProjects.at(i).LexYaccFiles; - } else if (filtername == "TranslationFiles") { - filter = SingleProjects.at(i).TranslationFiles; - } else if (filtername == "FormFiles") { - filter = SingleProjects.at(i).FormFiles; - } else if (filtername == "ResourceFiles") { - filter = SingleProjects.at(i).ResourceFiles; - } else { - // ExtraCompilers - filter = SingleProjects[i].filterForExtraCompiler(filtername); + VCProjectWriter::outputFileConfigs(tool, xml, (*it), filter); } - - // Merge all files in this filter to root tree - for (int x = 0; x < filter.Files.count(); ++x) - root->addElement(filter.Files.at(x)); - - // Save filter setting from first filter. Next filters - // may differ but we cannot handle that. (ex. extfilter) - if (name.isEmpty()) { - name = filter.Name; - extfilter = filter.Filter; - parse = filter.ParseFiles; - guid = filter.Guid; - } - } - - if (!root->hasElements()) - return; - - // Actual XML output ---------------------------------- - if (!name.isEmpty()) { - xml << tag(_Filter) - << attrS(_Name, name) - << attrS(_Filter, extfilter) - << attrS(_UniqueIdentifier, guid) - << attrT(_ParseFiles, parse); } - root->generateXML(xml, "", *this, filtername); // output root tree - if (!name.isEmpty()) - xml << closetag(_Filter); } void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) @@ -2532,17 +2372,17 @@ void VCProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) // XML output functionality VCProject tempProj; tempProj.SingleProjects += tool; - tempProj.outputFilter(xml, "Sources"); - tempProj.outputFilter(xml, "Headers"); - tempProj.outputFilter(xml, "GeneratedFiles"); - tempProj.outputFilter(xml, "LexYaccFiles"); - tempProj.outputFilter(xml, "TranslationFiles"); - tempProj.outputFilter(xml, "FormFiles"); - tempProj.outputFilter(xml, "ResourceFiles"); + outputFilter(tempProj, xml, "Sources"); + outputFilter(tempProj, xml, "Headers"); + outputFilter(tempProj, xml, "GeneratedFiles"); + outputFilter(tempProj, xml, "LexYaccFiles"); + outputFilter(tempProj, xml, "TranslationFiles"); + outputFilter(tempProj, xml, "FormFiles"); + outputFilter(tempProj, xml, "ResourceFiles"); for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) { - tempProj.outputFilter(xml, tempProj.ExtraCompilers.at(x)); + outputFilter(tempProj, xml, tempProj.ExtraCompilers.at(x)); } - tempProj.outputFilter(xml, "RootFiles"); + outputFilter(tempProj, xml, "RootFiles"); xml << closetag(q_Files) << tag(_Globals) << data(); // No "/>" end tag @@ -2574,17 +2414,17 @@ void VCProjectWriter::write(XmlOutput &xml, VCProject &tool) write(xml, tool.SingleProjects.at(i).Configuration); xml << closetag(_Configurations) << tag(q_Files); - tool.outputFilter(xml, "Sources"); - tool.outputFilter(xml, "Headers"); - tool.outputFilter(xml, "GeneratedFiles"); - tool.outputFilter(xml, "LexYaccFiles"); - tool.outputFilter(xml, "TranslationFiles"); - tool.outputFilter(xml, "FormFiles"); - tool.outputFilter(xml, "ResourceFiles"); + outputFilter(tool, xml, "Sources"); + outputFilter(tool, xml, "Headers"); + outputFilter(tool, xml, "GeneratedFiles"); + outputFilter(tool, xml, "LexYaccFiles"); + outputFilter(tool, xml, "TranslationFiles"); + outputFilter(tool, xml, "FormFiles"); + outputFilter(tool, xml, "ResourceFiles"); for (int x = 0; x < tool.ExtraCompilers.count(); ++x) { - tool.outputFilter(xml, tool.ExtraCompilers.at(x)); + outputFilter(tool, xml, tool.ExtraCompilers.at(x)); } - tool.outputFilter(xml, "RootFiles"); + outputFilter(tool, xml, "RootFiles"); xml << closetag(q_Files) << tag(_Globals) << data(); // No "/>" end tag @@ -2907,11 +2747,165 @@ void VCProjectWriter::write(XmlOutput &xml, VCFilter &tool) xml << tag(q_File) << attrS(_RelativePath, Option::fixPathToLocalOS(info.file)) << data(); // In case no custom builds, to avoid "/>" endings - tool.outputFileConfig(xml, tool.Files.at(i).file); + outputFileConfig(tool, xml, tool.Files.at(i).file); xml << closetag(q_File); } if (!tool.Name.isEmpty()) xml << closetag(_Filter); } +// outputs a given filter for all existing configurations of a project +void VCProjectWriter::outputFilter(VCProject &project, XmlOutput &xml, const QString &filtername) +{ + Node *root; + if (project.SingleProjects.at(0).flat_files) + root = new FlatNode; + else + root = new TreeNode; + + QString name, extfilter, guid; + triState parse; + + for (int i = 0; i < project.SingleProjects.count(); ++i) { + VCFilter filter; + const VCProjectSingleConfig &projectSingleConfig = project.SingleProjects.at(i); + if (filtername == "RootFiles") { + filter = projectSingleConfig.RootFiles; + } else if (filtername == "Sources") { + filter = projectSingleConfig.SourceFiles; + } else if (filtername == "Headers") { + filter = projectSingleConfig.HeaderFiles; + } else if (filtername == "GeneratedFiles") { + filter = projectSingleConfig.GeneratedFiles; + } else if (filtername == "LexYaccFiles") { + filter = projectSingleConfig.LexYaccFiles; + } else if (filtername == "TranslationFiles") { + filter = projectSingleConfig.TranslationFiles; + } else if (filtername == "FormFiles") { + filter = projectSingleConfig.FormFiles; + } else if (filtername == "ResourceFiles") { + filter = projectSingleConfig.ResourceFiles; + } else { + // ExtraCompilers + filter = project.SingleProjects[i].filterForExtraCompiler(filtername); + } + + // Merge all files in this filter to root tree + for (int x = 0; x < filter.Files.count(); ++x) + root->addElement(filter.Files.at(x)); + + // Save filter setting from first filter. Next filters + // may differ but we cannot handle that. (ex. extfilter) + if (name.isEmpty()) { + name = filter.Name; + extfilter = filter.Filter; + parse = filter.ParseFiles; + guid = filter.Guid; + } + } + + if (!root->hasElements()) + return; + + // Actual XML output ---------------------------------- + if (!name.isEmpty()) { + xml << tag(_Filter) + << attrS(_Name, name) + << attrS(_Filter, extfilter) + << attrS(_UniqueIdentifier, guid) + << attrT(_ParseFiles, parse); + } + root->generateXML(xml, "", project, filtername); // output root tree + if (!name.isEmpty()) + xml << closetag(_Filter); +} + +// Output all configurations (by filtername) for a file (by info) +// A filters config output is in VCFilter.outputFileConfig() +void VCProjectWriter::outputFileConfigs(VCProject &project, XmlOutput &xml, const VCFilterFile &info, const QString &filtername) +{ + xml << tag(q_File) + << attrS(_RelativePath, Option::fixPathToLocalOS(info.file)); + for (int i = 0; i < project.SingleProjects.count(); ++i) { + VCFilter filter; + const VCProjectSingleConfig &projectSingleConfig = project.SingleProjects.at(i); + if (filtername == "RootFiles") { + filter = projectSingleConfig.RootFiles; + } else if (filtername == "Sources") { + filter = projectSingleConfig.SourceFiles; + } else if (filtername == "Headers") { + filter = projectSingleConfig.HeaderFiles; + } else if (filtername == "GeneratedFiles") { + filter = projectSingleConfig.GeneratedFiles; + } else if (filtername == "LexYaccFiles") { + filter = projectSingleConfig.LexYaccFiles; + } else if (filtername == "TranslationFiles") { + filter = projectSingleConfig.TranslationFiles; + } else if (filtername == "FormFiles") { + filter = projectSingleConfig.FormFiles; + } else if (filtername == "ResourceFiles") { + filter = projectSingleConfig.ResourceFiles; + } else { + // ExtraCompilers + filter = project.SingleProjects[i].filterForExtraCompiler(filtername); + } + + if (filter.Config) // only if the filter is not empty + outputFileConfig(filter, xml, info.file); + } + xml << closetag(q_File); +} + +void VCProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, const QString &filename) +{ + // Clearing each filter tool + filter.useCustomBuildTool = false; + filter.useCompilerTool = false; + filter.CustomBuildTool = VCCustomBuildTool(); + filter.CompilerTool = VCCLCompilerTool(); + + // Unset some default options + filter.CompilerTool.BufferSecurityCheck = unset; + filter.CompilerTool.DebugInformationFormat = debugUnknown; + filter.CompilerTool.ExceptionHandling = ehDefault; + filter.CompilerTool.GeneratePreprocessedFile = preprocessUnknown; + filter.CompilerTool.Optimization = optimizeDefault; + filter.CompilerTool.ProgramDataBaseFileName.clear(); + filter.CompilerTool.RuntimeLibrary = rtUnknown; + filter.CompilerTool.WarningLevel = warningLevelUnknown; + filter.CompilerTool.config = filter.Config; + + bool inBuild = false; + VCFilterFile info; + for (int i = 0; i < filter.Files.count(); ++i) { + if (filter.Files.at(i).file == filename) { + info = filter.Files.at(i); + inBuild = true; + } + } + inBuild &= !info.excludeFromBuild; + + if (inBuild) { + filter.addExtraCompiler(info); + if(filter.Project->usePCH) + filter.modifyPCHstage(info.file); + } else { + // Excluded files uses an empty compiler stage + if(info.excludeFromBuild) + filter.useCompilerTool = true; + } + + // Actual XML output ---------------------------------- + if (filter.useCustomBuildTool || filter.useCompilerTool || !inBuild) { + xml << tag(_FileConfiguration) + << attr(_Name, filter.Config->Name) + << (!inBuild ? attrS(_ExcludedFromBuild, "true") : noxml()); + if (filter.useCustomBuildTool) + filter.Project->projectWriter->write(xml, filter.CustomBuildTool); + if (filter.useCompilerTool) + filter.Project->projectWriter->write(xml, filter.CompilerTool); + xml << closetag(_FileConfiguration); + } +} + QT_END_NAMESPACE diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h index 85c7a5c..c70e897 100644 --- a/qmake/generators/win32/msvc_objectmodel.h +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -470,7 +470,7 @@ enum warningLevelOption { class VCToolBase { protected: // Functions - VCToolBase(){}; + VCToolBase(){} virtual ~VCToolBase(){} virtual bool parseOption(const char* option) = 0; public: @@ -725,7 +725,7 @@ public: // Functions VCLibrarianTool(); virtual ~VCLibrarianTool(){} - bool parseOption(const char*){ return false; }; + bool parseOption(const char*){ return false; } // Variables QStringList AdditionalDependencies; @@ -746,7 +746,7 @@ public: // Functions VCCustomBuildTool(); virtual ~VCCustomBuildTool(){} - bool parseOption(const char*){ return false; }; + bool parseOption(const char*){ return false; } // Variables QStringList AdditionalDependencies; @@ -765,7 +765,7 @@ public: // Functions VCResourceCompilerTool(); virtual ~VCResourceCompilerTool(){} - bool parseOption(const char*){ return false; }; + bool parseOption(const char*){ return false; } // Variables QStringList AdditionalIncludeDirectories; @@ -908,14 +908,13 @@ class VCFilter public: // Functions VCFilter(); - ~VCFilter(){}; + ~VCFilter(){} void addFile(const QString& filename); void addFile(const VCFilterFile& fileInfo); void addFiles(const QStringList& fileList); bool addExtraCompiler(const VCFilterFile &info); void modifyPCHstage(QString str); - void outputFileConfig(XmlOutput &xml, const QString &filename); // Variables QString Name; @@ -933,9 +932,6 @@ public: bool useCompilerTool; VCCLCompilerTool CompilerTool; - -private: - friend XmlOutput &operator<<(XmlOutput &xml, VCFilter &tool); }; typedef QList VCFilterList; @@ -953,7 +949,7 @@ public: Extras }; // Functions - VCProjectSingleConfig(){}; + VCProjectSingleConfig(){} ~VCProjectSingleConfig(){} // Variables @@ -983,8 +979,6 @@ public: VCFilter &filterForExtraCompiler(const QString &compilerName); }; - - // Tree & Flat view of files -------------------------------------------------- class VCFilter; class Node @@ -1110,16 +1104,6 @@ public: // List of all extracompilers QStringList ExtraCompilers; - - // Functions - void outputFilter(XmlOutput &xml, -// VCProjectSingleConfig::FilterTypes type, - const QString &filtername); - - void outputFileConfigs(XmlOutput &xml, -// VCProjectSingleConfig::FilterTypes type, - const VCFilterFile &info, - const QString &filtername); }; class VCProjectWriter @@ -1140,6 +1124,14 @@ public: virtual void write(XmlOutput &, const VCDeploymentTool &); virtual void write(XmlOutput &, const VCConfiguration &); virtual void write(XmlOutput &, VCFilter &); + +private: + static void outputFilter(VCProject &project, XmlOutput &xml, const QString &filtername); + static void outputFileConfigs(VCProject &project, XmlOutput &xml, const VCFilterFile &info, const QString &filtername); + static void outputFileConfig(VCFilter &filter, XmlOutput &xml, const QString &filename); + + friend class TreeNode; + friend class FlatNode; }; QT_END_NAMESPACE -- cgit v0.12 From 021e7a437f7666e156db5a91e4ff191aa441cc60 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 6 Aug 2010 14:24:15 +0200 Subject: qmake: repair .vcxproj generation Rubber-stamped-by: ossi --- qmake/generators/win32/msbuild_objectmodel.cpp | 13 +++++-------- qmake/generators/win32/msvc_objectmodel.cpp | 7 ++++--- qmake/generators/win32/msvc_vcproj.cpp | 12 ++++++++---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index c9ba248..a397ae9 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -1266,7 +1266,7 @@ void VCXProjectWriter::write(XmlOutput &xml, const VCCLCompilerTool &tool) << attrTagT(_OpenMPSupport, tool.OpenMP) << attrTagS(_Optimization, toString(tool.Optimization)) << attrTagS(_PrecompiledHeader, toString(tool.UsePrecompiledHeader)) - << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderFile) + << attrTagS(_PrecompiledHeaderFile, tool.PrecompiledHeaderThrough) << attrTagS(_PrecompiledHeaderOutputFile, tool.PrecompiledHeaderFile) << attrTagT(_PreprocessKeepComments, tool.KeepComments) << attrTagX(_PreprocessorDefinitions, tool.PreprocessorDefinitions, ";") @@ -1791,6 +1791,7 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut filter.CompilerTool = VCCLCompilerTool(); // Unset some default options + filter.CustomBuildTool.config = filter.Config; filter.CompilerTool.BufferSecurityCheck = unset; filter.CompilerTool.DebugInformationFormat = debugUnknown; filter.CompilerTool.ExceptionHandling = ehDefault; @@ -1925,16 +1926,12 @@ bool VCXProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, XmlOut << valueTagX(filter.CompilerTool.ForcedIncludeFiles); } - if ( !filter.CompilerTool.PrecompiledHeaderFile.isEmpty() ) { + if ( !filter.CompilerTool.PrecompiledHeaderThrough.isEmpty() ) { xml << tag("PrecompiledHeaderFile") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) - << valueTag(filter.CompilerTool.PrecompiledHeaderFile); - } - - if ( filter.CompilerTool.UsePrecompiledHeader ) { - - xml << tag("PrecompiledHeader") + << valueTag(filter.CompilerTool.PrecompiledHeaderThrough) + << tag("PrecompiledHeader") << attrTag("Condition", QString("'$(Configuration)|$(Platform)'=='%1'").arg(filter.Config->Name)) << valueTag(toString(filter.CompilerTool.UsePrecompiledHeader)); } diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 6e1ee8d..e001884 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2110,9 +2110,9 @@ void VCFilter::modifyPCHstage(QString str) lines << "*"; lines << "* This file is auto-generated by qmake since no PRECOMPILED_SOURCE was"; lines << "* specified, and is used as the common stdafx.cpp. The file is only"; - lines << "* generated when creating "; - lines << (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj"); - lines << " project files, and is not used for"; + lines << QLatin1String("* generated when creating ") + + (Config->CompilerVersion < NET2010 ? ".vcproj" : ".vcxproj") + + " project files, and is not used for"; lines << "* command line compilations by nmake."; lines << "*"; lines << "* WARNING: All changes made in this file will be lost."; @@ -2865,6 +2865,7 @@ void VCProjectWriter::outputFileConfig(VCFilter &filter, XmlOutput &xml, const Q filter.CompilerTool = VCCLCompilerTool(); // Unset some default options + filter.CustomBuildTool.config = filter.Config; filter.CompilerTool.BufferSecurityCheck = unset; filter.CompilerTool.DebugInformationFormat = debugUnknown; filter.CompilerTool.ExceptionHandling = ehDefault; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 449dcb0..345bd3a 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -207,9 +207,9 @@ const char _slnExtSections[] = "\n\tGlobalSection(ExtensibilityGlobals) = pos VcprojGenerator::VcprojGenerator() : Win32MakefileGenerator(), - init_flag(false) + init_flag(false), + projectWriter(0) { - projectWriter = createProjectWriter(); } VcprojGenerator::~VcprojGenerator() @@ -660,6 +660,7 @@ void VcprojGenerator::init() if (init_flag) return; init_flag = true; + projectWriter = createProjectWriter(); if(project->first("TEMPLATE") == "vcsubdirs") //too much work for subdirs return; @@ -775,7 +776,7 @@ bool VcprojGenerator::mergeBuildProject(MakefileGenerator *other) warn_msg(WarnLogic, "VcprojGenerator: Cannot merge null project."); return false; } - if (other->projectFile()->first("MAKEFILE_GENERATOR") != "MSVC.NET") { + if (other->projectFile()->first("MAKEFILE_GENERATOR") != project->first("MAKEFILE_GENERATOR")) { warn_msg(WarnLogic, "VcprojGenerator: Cannot merge other types of projects! (ignored)"); return false; } @@ -804,6 +805,9 @@ void VcprojGenerator::initProject() // Own elements ----------------------------- vcProject.Name = unescapeFilePath(project->first("QMAKE_ORIG_TARGET")); switch(which_dotnet_version()) { + case NET2010: + vcProject.Version = "10.00"; + break; case NET2008: vcProject.Version = "9,00"; break; @@ -888,6 +892,7 @@ void VcprojGenerator::initConfiguration() conf.PrimaryOutput.append(project->first("TARGET_VERSION_EXT")); } else { conf.PrimaryOutput = project->first("PrimaryOutput"); + conf.OutputDirectory = "."; } conf.Name = project->values("BUILD_NAME").join(" "); @@ -906,7 +911,6 @@ void VcprojGenerator::initConfiguration() conf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); conf.ImportLibrary = conf.linker.ImportLibrary; conf.IntermediateDirectory = project->first("OBJECTS_DIR"); - conf.OutputDirectory = "."; conf.WholeProgramOptimization = conf.compiler.WholeProgramOptimization; temp = project->first("UseOfATL"); if(!temp.isEmpty()) -- cgit v0.12 From e7eed096a0c33607a7a37baaf06e5952dc9d556b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 9 Aug 2010 14:07:01 +0200 Subject: Remove dependency of OpenGL Utility Library (GLU). GLU is not part of standard OpenGL and is not used internally in Qt, so we should not depend on it. Task-number: QT-12227 Reviewed-by: kim --- config.tests/x11/glxfbconfig/glxfbconfig.pro | 2 +- config.tests/x11/opengl/opengl.cpp | 5 ----- config.tests/x11/opengl/opengl.pro | 2 +- dist/changes-4.8.0 | 4 ++++ mkspecs/aix-g++-64/qmake.conf | 2 +- mkspecs/aix-g++/qmake.conf | 2 +- mkspecs/aix-xlc-64/qmake.conf | 2 +- mkspecs/aix-xlc/qmake.conf | 2 +- mkspecs/common/linux.conf | 2 +- mkspecs/cygwin-g++/qmake.conf | 2 +- mkspecs/darwin-g++/qmake.conf | 2 +- mkspecs/freebsd-g++/qmake.conf | 2 +- mkspecs/freebsd-g++34/qmake.conf | 2 +- mkspecs/freebsd-g++40/qmake.conf | 2 +- mkspecs/freebsd-icc/qmake.conf | 2 +- mkspecs/hpux-acc-64/qmake.conf | 2 +- mkspecs/hpux-acc-o64/qmake.conf | 2 +- mkspecs/hpux-acc/qmake.conf | 2 +- mkspecs/hpux-g++-64/qmake.conf | 2 +- mkspecs/hpux-g++/qmake.conf | 2 +- mkspecs/hpuxi-acc-32/qmake.conf | 2 +- mkspecs/hpuxi-acc-64/qmake.conf | 2 +- mkspecs/hpuxi-g++-64/qmake.conf | 2 +- mkspecs/hurd-g++/qmake.conf | 2 +- mkspecs/irix-cc-64/qmake.conf | 2 +- mkspecs/irix-cc/qmake.conf | 2 +- mkspecs/irix-g++-64/qmake.conf | 2 +- mkspecs/irix-g++/qmake.conf | 2 +- mkspecs/linux-cxx/qmake.conf | 2 +- mkspecs/linux-ecc-64/qmake.conf | 2 +- mkspecs/linux-icc/qmake.conf | 2 +- mkspecs/linux-kcc/qmake.conf | 2 +- mkspecs/linux-pgcc/qmake.conf | 2 +- mkspecs/lynxos-g++/qmake.conf | 2 +- mkspecs/netbsd-g++/qmake.conf | 2 +- mkspecs/openbsd-g++/qmake.conf | 2 +- mkspecs/sco-cc/qmake.conf | 2 +- mkspecs/sco-g++/qmake.conf | 2 +- mkspecs/solaris-cc-64/qmake.conf | 2 +- mkspecs/solaris-cc/qmake.conf | 2 +- mkspecs/solaris-g++-64/qmake.conf | 2 +- mkspecs/solaris-g++/qmake.conf | 2 +- mkspecs/tru64-cxx/qmake.conf | 2 +- mkspecs/tru64-g++/qmake.conf | 2 +- mkspecs/unixware-cc/qmake.conf | 2 +- mkspecs/unixware-g++/qmake.conf | 2 +- mkspecs/unsupported/linux-host-g++/qmake.conf | 2 +- mkspecs/unsupported/qnx-g++/qmake.conf | 2 +- mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf | 2 +- mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf | 2 +- src/opengl/qgl.h | 4 ---- 51 files changed, 52 insertions(+), 57 deletions(-) diff --git a/config.tests/x11/glxfbconfig/glxfbconfig.pro b/config.tests/x11/glxfbconfig/glxfbconfig.pro index 4705ca6..65f855a 100644 --- a/config.tests/x11/glxfbconfig/glxfbconfig.pro +++ b/config.tests/x11/glxfbconfig/glxfbconfig.pro @@ -7,4 +7,4 @@ for(p, QMAKE_LIBDIR_OPENGL) { } CONFIG -= qt -LIBS += -lGL -lGLU +LIBS += -lGL diff --git a/config.tests/x11/opengl/opengl.cpp b/config.tests/x11/opengl/opengl.cpp index 3802365..6c1815d 100644 --- a/config.tests/x11/opengl/opengl.cpp +++ b/config.tests/x11/opengl/opengl.cpp @@ -40,11 +40,6 @@ ****************************************************************************/ #include -#include - -#ifndef GLU_VERSION_1_2 -# error "Required GLU version 1.2 not found." -#endif int main(int, char **) { diff --git a/config.tests/x11/opengl/opengl.pro b/config.tests/x11/opengl/opengl.pro index 5fd41d3..5c3a1c5 100644 --- a/config.tests/x11/opengl/opengl.pro +++ b/config.tests/x11/opengl/opengl.pro @@ -8,4 +8,4 @@ for(p, QMAKE_LIBDIR_OPENGL) { CONFIG -= qt win32-g++*:LIBS += -lopengl32 -else:LIBS += -lGL -lGLU +else:LIBS += -lGL diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index 9d16f11..f22460f 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -43,6 +43,10 @@ QtGui - QTabBar: reduced minimumSizeHint if ElideMode is set. + QtOpenGL + -------- + - Removed dependency of OpenGL Utility Library (GLU) + **************************************************************************** * Database Drivers * diff --git a/mkspecs/aix-g++-64/qmake.conf b/mkspecs/aix-g++-64/qmake.conf index d9d9c38..b0179d5 100644 --- a/mkspecs/aix-g++-64/qmake.conf +++ b/mkspecs/aix-g++-64/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads diff --git a/mkspecs/aix-g++/qmake.conf b/mkspecs/aix-g++/qmake.conf index 5fc4c17..2e2e991 100644 --- a/mkspecs/aix-g++/qmake.conf +++ b/mkspecs/aix-g++/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads diff --git a/mkspecs/aix-xlc-64/qmake.conf b/mkspecs/aix-xlc-64/qmake.conf index ae87b88..486b8c6 100644 --- a/mkspecs/aix-xlc-64/qmake.conf +++ b/mkspecs/aix-xlc-64/qmake.conf @@ -62,7 +62,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads diff --git a/mkspecs/aix-xlc/qmake.conf b/mkspecs/aix-xlc/qmake.conf index fe91236..8655db6 100644 --- a/mkspecs/aix-xlc/qmake.conf +++ b/mkspecs/aix-xlc/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthreads diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf index 4fbe2dc..e443be1 100644 --- a/mkspecs/common/linux.conf +++ b/mkspecs/common/linux.conf @@ -28,7 +28,7 @@ QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl QMAKE_LIBS_EGL = -lEGL -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_OPENGL_ES1 = -lGLES_CM QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 diff --git a/mkspecs/cygwin-g++/qmake.conf b/mkspecs/cygwin-g++/qmake.conf index 29d0958..ddfceb0 100644 --- a/mkspecs/cygwin-g++/qmake.conf +++ b/mkspecs/cygwin-g++/qmake.conf @@ -65,7 +65,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/darwin-g++/qmake.conf b/mkspecs/darwin-g++/qmake.conf index fc55503..84dc764 100644 --- a/mkspecs/darwin-g++/qmake.conf +++ b/mkspecs/darwin-g++/qmake.conf @@ -74,7 +74,7 @@ QMAKE_LFLAGS_RPATH = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/freebsd-g++/qmake.conf b/mkspecs/freebsd-g++/qmake.conf index 51a1960..ac52e0f 100644 --- a/mkspecs/freebsd-g++/qmake.conf +++ b/mkspecs/freebsd-g++/qmake.conf @@ -28,7 +28,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/freebsd-g++34/qmake.conf b/mkspecs/freebsd-g++34/qmake.conf index 810efab..0f52993 100644 --- a/mkspecs/freebsd-g++34/qmake.conf +++ b/mkspecs/freebsd-g++34/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/freebsd-g++40/qmake.conf b/mkspecs/freebsd-g++40/qmake.conf index 4b0ac4c..3d0851a 100644 --- a/mkspecs/freebsd-g++40/qmake.conf +++ b/mkspecs/freebsd-g++40/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/freebsd-icc/qmake.conf b/mkspecs/freebsd-icc/qmake.conf index 99d6126..acc8f14 100644 --- a/mkspecs/freebsd-icc/qmake.conf +++ b/mkspecs/freebsd-icc/qmake.conf @@ -86,7 +86,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/hpux-acc-64/qmake.conf b/mkspecs/hpux-acc-64/qmake.conf index 38c8555..b9aaf5a 100644 --- a/mkspecs/hpux-acc-64/qmake.conf +++ b/mkspecs/hpux-acc-64/qmake.conf @@ -106,7 +106,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpux-acc-o64/qmake.conf b/mkspecs/hpux-acc-o64/qmake.conf index 630129c..389e813 100644 --- a/mkspecs/hpux-acc-o64/qmake.conf +++ b/mkspecs/hpux-acc-o64/qmake.conf @@ -104,7 +104,7 @@ QMAKE_LIBS_DYNLOAD = -ldld QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpux-acc/qmake.conf b/mkspecs/hpux-acc/qmake.conf index 1c732c6..d1b6e5c 100644 --- a/mkspecs/hpux-acc/qmake.conf +++ b/mkspecs/hpux-acc/qmake.conf @@ -85,7 +85,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = -ldld QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpux-g++-64/qmake.conf b/mkspecs/hpux-g++-64/qmake.conf index d8b0a4a..f796496 100644 --- a/mkspecs/hpux-g++-64/qmake.conf +++ b/mkspecs/hpux-g++-64/qmake.conf @@ -68,7 +68,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = -ldld QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpux-g++/qmake.conf b/mkspecs/hpux-g++/qmake.conf index 312c44b..e9891e7 100644 --- a/mkspecs/hpux-g++/qmake.conf +++ b/mkspecs/hpux-g++/qmake.conf @@ -68,7 +68,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldld QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpuxi-acc-32/qmake.conf b/mkspecs/hpuxi-acc-32/qmake.conf index a26cb32..d7e4a0a 100644 --- a/mkspecs/hpuxi-acc-32/qmake.conf +++ b/mkspecs/hpuxi-acc-32/qmake.conf @@ -60,7 +60,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpuxi-acc-64/qmake.conf b/mkspecs/hpuxi-acc-64/qmake.conf index 3e2d59f..3ed9b55 100644 --- a/mkspecs/hpuxi-acc-64/qmake.conf +++ b/mkspecs/hpuxi-acc-64/qmake.conf @@ -103,7 +103,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL -lXt QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hpuxi-g++-64/qmake.conf b/mkspecs/hpuxi-g++-64/qmake.conf index 3151d85..a8f445c 100644 --- a/mkspecs/hpuxi-g++-64/qmake.conf +++ b/mkspecs/hpuxi-g++-64/qmake.conf @@ -71,7 +71,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread QMAKE_LIBS_YACC = -ly diff --git a/mkspecs/hurd-g++/qmake.conf b/mkspecs/hurd-g++/qmake.conf index 6570e40..d89f2e4 100644 --- a/mkspecs/hurd-g++/qmake.conf +++ b/mkspecs/hurd-g++/qmake.conf @@ -67,7 +67,7 @@ QMAKE_LIBS_NIS = -lnsl QMAKE_LIBS_QT_THREAD = -lqt-mt QMAKE_LIBS_THREAD = -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_MOC = $$[QT_INSTALL_BINS]/moc diff --git a/mkspecs/irix-cc-64/qmake.conf b/mkspecs/irix-cc-64/qmake.conf index b8d316e..ec94824 100644 --- a/mkspecs/irix-cc-64/qmake.conf +++ b/mkspecs/irix-cc-64/qmake.conf @@ -94,7 +94,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lm +QMAKE_LIBS_OPENGL = -lGL -lm QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/irix-cc/qmake.conf b/mkspecs/irix-cc/qmake.conf index 2f4f03f..777da9b 100644 --- a/mkspecs/irix-cc/qmake.conf +++ b/mkspecs/irix-cc/qmake.conf @@ -94,7 +94,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lm +QMAKE_LIBS_OPENGL = -lGL -lm QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/irix-g++-64/qmake.conf b/mkspecs/irix-g++-64/qmake.conf index 610d92c..aa853de 100644 --- a/mkspecs/irix-g++-64/qmake.conf +++ b/mkspecs/irix-g++-64/qmake.conf @@ -67,7 +67,7 @@ QMAKE_LIBS_X11SM = -lSM -lICE # libGLU is using the SGI C++ library internally and this somehow clashes # with the GNU C++ library (similar name mangling and symbol names?) # so we add -lC so that the SGI C++ library is used first... -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/irix-g++/qmake.conf b/mkspecs/irix-g++/qmake.conf index 41841f3..77d47a9 100644 --- a/mkspecs/irix-g++/qmake.conf +++ b/mkspecs/irix-g++/qmake.conf @@ -67,7 +67,7 @@ QMAKE_LIBS_X11SM = -lSM -lICE # libGLU is using the SGI C++ library internally and this somehow clashes # with the GNU C++ library (similar name mangling and symbol names?) # so we add -lC so that the SGI C++ library is used first... -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/linux-cxx/qmake.conf b/mkspecs/linux-cxx/qmake.conf index 879c78a..ce303b7 100644 --- a/mkspecs/linux-cxx/qmake.conf +++ b/mkspecs/linux-cxx/qmake.conf @@ -60,7 +60,7 @@ QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_MOC = $$[QT_INSTALL_BINS]/moc diff --git a/mkspecs/linux-ecc-64/qmake.conf b/mkspecs/linux-ecc-64/qmake.conf index aa50b87..61a056b 100644 --- a/mkspecs/linux-ecc-64/qmake.conf +++ b/mkspecs/linux-ecc-64/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index 3b26f7d..16e5197 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -70,7 +70,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/linux-kcc/qmake.conf b/mkspecs/linux-kcc/qmake.conf index 5c6001c..01e3b73 100644 --- a/mkspecs/linux-kcc/qmake.conf +++ b/mkspecs/linux-kcc/qmake.conf @@ -72,7 +72,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/linux-pgcc/qmake.conf b/mkspecs/linux-pgcc/qmake.conf index 16d0023..63ede78 100644 --- a/mkspecs/linux-pgcc/qmake.conf +++ b/mkspecs/linux-pgcc/qmake.conf @@ -63,7 +63,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/lynxos-g++/qmake.conf b/mkspecs/lynxos-g++/qmake.conf index fc0fc43..6b6f405 100644 --- a/mkspecs/lynxos-g++/qmake.conf +++ b/mkspecs/lynxos-g++/qmake.conf @@ -66,7 +66,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread diff --git a/mkspecs/netbsd-g++/qmake.conf b/mkspecs/netbsd-g++/qmake.conf index 1d3fd2b..4d4270d 100644 --- a/mkspecs/netbsd-g++/qmake.conf +++ b/mkspecs/netbsd-g++/qmake.conf @@ -64,7 +64,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/openbsd-g++/qmake.conf b/mkspecs/openbsd-g++/qmake.conf index c948c90..f4bb223 100644 --- a/mkspecs/openbsd-g++/qmake.conf +++ b/mkspecs/openbsd-g++/qmake.conf @@ -65,7 +65,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/sco-cc/qmake.conf b/mkspecs/sco-cc/qmake.conf index 6eb5ca1..179b774 100644 --- a/mkspecs/sco-cc/qmake.conf +++ b/mkspecs/sco-cc/qmake.conf @@ -60,7 +60,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_MOC = $$[QT_INSTALL_BINS]/moc diff --git a/mkspecs/sco-g++/qmake.conf b/mkspecs/sco-g++/qmake.conf index d4091ff..9b321a4 100644 --- a/mkspecs/sco-g++/qmake.conf +++ b/mkspecs/sco-g++/qmake.conf @@ -61,7 +61,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lsocket -lm -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_MOC = $$[QT_INSTALL_BINS]/moc diff --git a/mkspecs/solaris-cc-64/qmake.conf b/mkspecs/solaris-cc-64/qmake.conf index a026756..80709af 100644 --- a/mkspecs/solaris-cc-64/qmake.conf +++ b/mkspecs/solaris-cc-64/qmake.conf @@ -83,7 +83,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl diff --git a/mkspecs/solaris-cc/qmake.conf b/mkspecs/solaris-cc/qmake.conf index 8a8f1ac..0672841 100644 --- a/mkspecs/solaris-cc/qmake.conf +++ b/mkspecs/solaris-cc/qmake.conf @@ -66,7 +66,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl diff --git a/mkspecs/solaris-g++-64/qmake.conf b/mkspecs/solaris-g++-64/qmake.conf index 01e331c..7bc7b9f 100644 --- a/mkspecs/solaris-g++-64/qmake.conf +++ b/mkspecs/solaris-g++-64/qmake.conf @@ -87,7 +87,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl diff --git a/mkspecs/solaris-g++/qmake.conf b/mkspecs/solaris-g++/qmake.conf index c7f6406..be21cdd 100644 --- a/mkspecs/solaris-g++/qmake.conf +++ b/mkspecs/solaris-g++/qmake.conf @@ -70,7 +70,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lrt QMAKE_LIBS_NETWORK = -lresolv -lsocket -lxnet -lnsl diff --git a/mkspecs/tru64-cxx/qmake.conf b/mkspecs/tru64-cxx/qmake.conf index d2c6937..afabf3e 100644 --- a/mkspecs/tru64-cxx/qmake.conf +++ b/mkspecs/tru64-cxx/qmake.conf @@ -60,7 +60,7 @@ QMAKE_LIBS = -lm QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lrt diff --git a/mkspecs/tru64-g++/qmake.conf b/mkspecs/tru64-g++/qmake.conf index f2b8e39..6acd5cd 100644 --- a/mkspecs/tru64-g++/qmake.conf +++ b/mkspecs/tru64-g++/qmake.conf @@ -62,7 +62,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lpthread -lexc -lrt diff --git a/mkspecs/unixware-cc/qmake.conf b/mkspecs/unixware-cc/qmake.conf index 5f88b80..74478d6 100644 --- a/mkspecs/unixware-cc/qmake.conf +++ b/mkspecs/unixware-cc/qmake.conf @@ -64,7 +64,7 @@ QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = diff --git a/mkspecs/unixware-g++/qmake.conf b/mkspecs/unixware-g++/qmake.conf index 34d6d61..a158d95 100644 --- a/mkspecs/unixware-g++/qmake.conf +++ b/mkspecs/unixware-g++/qmake.conf @@ -64,7 +64,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = -ldl QMAKE_LIBS_X11 = -lXext -lX11 -lresolv -lsocket -lnsl -lm QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL -lXt +QMAKE_LIBS_OPENGL = -lGL -lXt QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = -lthread diff --git a/mkspecs/unsupported/linux-host-g++/qmake.conf b/mkspecs/unsupported/linux-host-g++/qmake.conf index 38849f8..46ecf37 100644 --- a/mkspecs/unsupported/linux-host-g++/qmake.conf +++ b/mkspecs/unsupported/linux-host-g++/qmake.conf @@ -101,7 +101,7 @@ QMAKE_LIBS_X11 = -lXext -lX11 -lm QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl QMAKE_LIBS_EGL = -lEGL -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_OPENGL_ES1 = -lGLES_CM QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 diff --git a/mkspecs/unsupported/qnx-g++/qmake.conf b/mkspecs/unsupported/qnx-g++/qmake.conf index 37e7bce..dfe9bed 100644 --- a/mkspecs/unsupported/qnx-g++/qmake.conf +++ b/mkspecs/unsupported/qnx-g++/qmake.conf @@ -31,7 +31,7 @@ QMAKE_LIBS = QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 -lm -lsocket QMAKE_LIBS_X11SM = -lSM -lICE -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = QMAKE_LIBS_NETWORK = -lsocket diff --git a/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf b/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf index e3eb6cd..a3b571b 100644 --- a/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf +++ b/mkspecs/unsupported/vxworks-ppc-dcc/qmake.conf @@ -78,7 +78,7 @@ QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = QMAKE_LIBS_NETWORK = # -lnetwrap # only needed if kernel is missing gethostbyname and friends diff --git a/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf b/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf index d0aeff6..8bdf1c5 100644 --- a/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf +++ b/mkspecs/unsupported/vxworks-simpentium-dcc/qmake.conf @@ -78,7 +78,7 @@ QMAKE_LIBS_DYNLOAD = QMAKE_LIBS_X11 = -lXext -lX11 QMAKE_LIBS_X11SM = -lSM -lICE QMAKE_LIBS_NIS = -lnsl -QMAKE_LIBS_OPENGL = -lGLU -lGL +QMAKE_LIBS_OPENGL = -lGL QMAKE_LIBS_OPENGL_QT = -lGL QMAKE_LIBS_THREAD = QMAKE_LIBS_NETWORK = # -lnet # only needed if kernel is missing gethostbyname and friends diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index 9315ac4..2ac4cb6 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -56,7 +56,6 @@ QT_BEGIN_HEADER #if defined(Q_WS_MAC) # include -# include #elif defined(QT_OPENGL_ES_1) # include #ifndef GL_DOUBLE @@ -75,9 +74,6 @@ typedef GLfloat GLdouble; #endif #else # include -# ifndef QT_LINUXBASE -# include -# endif #endif QT_BEGIN_NAMESPACE -- cgit v0.12 From ac6323c4346be5fb5b1111194b2ee98706a69ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Mon, 9 Aug 2010 14:48:12 +0200 Subject: Replace gluPerspective with qgluPerspective. GLU dependency was removed in commit: c67b4cac2e53ae77c4e16487838c17be85e73aa3, so we have to implement the function ourselves. Reviewed-by: kim --- demos/boxes/glbuffers.cpp | 10 ++++++++++ demos/boxes/glbuffers.h | 2 ++ demos/boxes/qtbox.cpp | 2 +- demos/boxes/scene.cpp | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/demos/boxes/glbuffers.cpp b/demos/boxes/glbuffers.cpp index 694d05b..84ab26c 100644 --- a/demos/boxes/glbuffers.cpp +++ b/demos/boxes/glbuffers.cpp @@ -42,6 +42,16 @@ #include "glbuffers.h" #include + +void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) +{ + const GLdouble ymax = zNear * tan(fovy * M_PI / 360.0); + const GLdouble ymin = -ymax; + const GLdouble xmin = ymin * aspect; + const GLdouble xmax = ymax * aspect; + glFrustum(xmin, xmax, ymin, ymax, zNear, zFar); +} + //============================================================================// // GLTexture // //============================================================================// diff --git a/demos/boxes/glbuffers.h b/demos/boxes/glbuffers.h index 67a4ea6..8c1e209 100644 --- a/demos/boxes/glbuffers.h +++ b/demos/boxes/glbuffers.h @@ -58,6 +58,8 @@ if (m_failed || !(assertion)) { returnStatement; \ } +void qgluPerspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); + QT_BEGIN_NAMESPACE class QMatrix4x4; QT_END_NAMESPACE diff --git a/demos/boxes/qtbox.cpp b/demos/boxes/qtbox.cpp index 3aaf985..e3a5978 100644 --- a/demos/boxes/qtbox.cpp +++ b/demos/boxes/qtbox.cpp @@ -324,7 +324,7 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadMatrixf(moveToRectMatrix); - gluPerspective(60.0, 1.0, 0.01, 10.0); + qgluPerspective(60.0, 1.0, 0.01, 10.0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp index 97953f2..d65af22 100644 --- a/demos/boxes/scene.cpp +++ b/demos/boxes/scene.cpp @@ -922,7 +922,7 @@ void Scene::drawBackground(QPainter *painter, const QRectF &) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); - gluPerspective(60.0, width / height, 0.01, 15.0); + qgluPerspective(60.0, width / height, 0.01, 15.0); glMatrixMode(GL_MODELVIEW); -- cgit v0.12 From 0650ec9effe5d9dd643d1bc19d2af591244671d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 10 Aug 2010 15:03:12 +0200 Subject: Fix documentation for QAccessible::InterfaceFactory Reported to me by Martin P. --- .../snippets/code/src_gui_accessible_qaccessible.cpp | 4 ++++ src/gui/accessible/qaccessible.cpp | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp b/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp index 8434d81..c5ca441 100644 --- a/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp +++ b/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp @@ -46,3 +46,7 @@ if (child) { delete child; } //! [0] + +//! [1] +typedef QAccessibleInterface* myFactoryFunction(const QString &key, QObject *); +//! [1] \ No newline at end of file diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 0921bdb..a6d1dbd 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -409,13 +409,18 @@ static void qAccessibleCleanup() /*! \typedef QAccessible::InterfaceFactory - A function pointer type. Use a function with this prototype to install - interface factories with installFactory(). + This is a typedef for a pointer to a function with the following + signature: - The function receives a QObject pointer. If the QObject - provides a QAccessibleInterface, it sets the second parameter to - point to the corresponding QAccessibleInterface, and returns true; - otherwise returns false. + \snippet doc/src/snippets/code/src_gui_accessible_qaccessible.cpp 1 + + The function receives a QString and a QObject pointer, where the + QString is the key identifying the interface. The QObject is used + to pass on to the QAccessibleInterface so that it can hold a reference + to it. + + If the key and the QObject does not have a corresponding + QAccessibleInterface, a null-pointer will be returned. Installed factories are called by queryAccessibilityInterface() until one provides an interface. -- cgit v0.12 From dd2a5c1556cf29fac03ae789dd5c43f482011d68 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 28 Jul 2010 12:40:30 +0200 Subject: Fix compilation on 64-bit Windows. When compiling for 64-bit with Visual Studio 2008, inline assembly is not supported. Use intrisic instead. Reviewed-by: Benjamin Poulain --- src/corelib/tools/qsimd.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 5aa7217..8005d7d 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -46,6 +46,10 @@ #include #endif +#if defined(Q_OS_WIN64) && !defined(Q_CC_GNU) +#include +#endif + QT_BEGIN_NAMESPACE uint qDetectCPUFeatures() @@ -261,31 +265,10 @@ uint qDetectCPUFeatures() : "%eax", "%ecx", "%edx" ); #elif defined (Q_OS_WIN64) - _asm { - push rax - push rbx - push rcx - push rdx - pushfd - pop rax - mov ebx, eax - xor eax, 00200000h - push rax - popfd - pushfd - pop rax - mov edx, 0 - xor eax, ebx - jz skip - - mov eax, 1 - cpuid - mov feature_result, ecx - skip: - pop rdx - pop rcx - pop rbx - pop rax + { + int info[4]; + __cpuid(info, 1); + feature_result = info[2]; } #endif -- cgit v0.12 From 99fd5825dfb4d50cff93165995701a65b7a8e4ed Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 10 Aug 2010 15:58:25 +0200 Subject: Make selection work across ligatures For widgets like QPlainTextEdit, selection across ligatures (typically 'fi', 'ffi', 'fl', etc.) end up highlighting the entire ligature glyphs, this patch fixed that by dividing width inside the ligature so that selection will not expand past the actual selected characters. Since cursor position already considered this, we merely adopted the algorithm and made it a separated helper function for all necessary cases. Dividing width directly looks like a temporary workaround but works well enough so far for cursor positions. Task-number: QTBUG-11969 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 531e46b..9d27343 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1035,6 +1035,35 @@ QScriptItem &QTextLineItemIterator::next() return *si; } +static QFixed offsetInLigature(const unsigned short *logClusters, + const QGlyphLayout &glyphs, + int pos, int max, int glyph_pos) +{ + int offsetInCluster = 0; + for (int i = pos - 1; i >= 0; i--) { + if (logClusters[i] == glyph_pos) + offsetInCluster++; + else + break; + } + + // in the case that the offset is inside a (multi-character) glyph, + // interpolate the position. + if (offsetInCluster > 0) { + int clusterLength = 0; + for (int i = pos - offsetInCluster; i < max; i++) { + if (logClusters[i] == glyph_pos) + clusterLength++; + else + break; + } + if (clusterLength) + return glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength; + } + + return 0; +} + bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const { *selectionX = *selectionWidth = 0; @@ -1074,8 +1103,19 @@ bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selec swidth += glyphs.effectiveAdvance(g); } - *selectionX = x + soff; - *selectionWidth = swidth; + // If the starting character is in the middle of a ligature, + // selection should only contain the right part of that ligature + // glyph, so we need to get the width of the left part here and + // add it to *selectionX + QFixed leftOffsetInLigature = offsetInLigature(logClusters, glyphs, from, + to, start_glyph); + *selectionX = x + soff + leftOffsetInLigature; + *selectionWidth = swidth - leftOffsetInLigature; + // If the ending character is also part of a ligature, swidth does + // not contain that part yet, we also need to find out the width of + // that left part + *selectionWidth += offsetInLigature(logClusters, glyphs, to, + eng->length(item), end_glyph); } return true; } @@ -2633,14 +2673,6 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const if(pos == l) x += si->width; } else { - int offsetInCluster = 0; - for (int i=pos-1; i >= 0; i--) { - if (logClusters[i] == glyph_pos) - offsetInCluster++; - else - break; - } - if (reverse) { int end = qMin(lineEnd, si->position + l) - si->position; int glyph_end = end == l ? si->num_glyphs : logClusters[end]; @@ -2652,17 +2684,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const for (int i = glyph_start; i < glyph_pos; i++) x += glyphs.effectiveAdvance(i); } - if (offsetInCluster > 0) { // in the case that the offset is inside a (multi-character) glyph, interpolate the position. - int clusterLength = 0; - for (int i=pos - offsetInCluster; i < line.length; i++) { - if (logClusters[i] == glyph_pos) - clusterLength++; - else - break; - } - if (clusterLength) - x+= glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength; - } + x += offsetInLigature(logClusters, glyphs, pos, line.length, glyph_pos); } *cursorPos = pos + si->position; -- cgit v0.12 From ca8d92f1d30b1519ccbfdab44e3868e9556b3fb5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Aug 2010 11:46:52 +0200 Subject: Optimize QSharedPointer::operator=(const QSharedPointer &) internalSet check that stringref is > 0 Which is not required as we do not assign from a QWeakPointer Reviewed-by: Thiago Task-number: QTBUG-12700 --- src/corelib/tools/qsharedpointer_impl.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index dd27f7e..7f0de5f 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -387,7 +387,13 @@ namespace QtSharedPointer { template inline void internalCopy(const ExternalRefCount &other) { - internalSet(other.d, other.data()); + Data *o = other.d; + T *actual = other.value; + if (o) + other.ref(); + qSwap(d, o); + qSwap(this->value, actual); + deref(o, actual); } inline void internalSwap(ExternalRefCount &other) -- cgit v0.12 From 4e626903d0f6df00fa83c18061a12cb3a5dbd603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 10 Aug 2010 16:53:18 +0200 Subject: Replace gluOrtho2d with glOrtho. GLU dependency was removed in commit: c67b4cac2e53ae77c4e16487838c17be85e73aa3, so instead of using gluOrtho2d we simply use glOrtho with near=-1 and far=1. --- src/3rdparty/phonon/qt7/videowidget.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/qt7/videowidget.mm b/src/3rdparty/phonon/qt7/videowidget.mm index 736dcdf..c281e16 100644 --- a/src/3rdparty/phonon/qt7/videowidget.mm +++ b/src/3rdparty/phonon/qt7/videowidget.mm @@ -278,7 +278,7 @@ public: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, GLsizei(w), GLsizei(h)); - gluOrtho2D(0, GLsizei(w), 0, GLsizei(h)); + glOrtho(0, GLsizei(w), 0, GLsizei(h), -1, 1); updateGL(); } -- cgit v0.12 From 7a3e217f4dab6a47a00da34c22f950fc2a9d8a53 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 10 Aug 2010 15:53:10 +0200 Subject: qmake vcproj generator cleanup MSVCPROJ_CXXFLAGS removed. This was unused. MSVCPROJ_LFLAGS removed. This was used to convert the values of QMAKE_LFLAGS, QMAKE_LIBDIR and DEF_FILE to linker command line options. Then they were converted back to set values in the object model. This journey to the world of command line options isn't necessary... Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 345bd3a..f32ba7e 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -996,7 +996,17 @@ void VcprojGenerator::initLinkerTool() { findLibraries(); // Need to add the highest version of the libs VCConfiguration &conf = vcProject.Configuration; - conf.linker.parseOptions(project->values("MSVCPROJ_LFLAGS")); + conf.linker.parseOptions(project->values("QMAKE_LFLAGS")); + + foreach (const QString &libDir, project->values("QMAKE_LIBDIR")) { + if (libDir.startsWith("/LIBPATH:")) + conf.linker.AdditionalLibraryDirectories += libDir.mid(9); + else + conf.linker.AdditionalLibraryDirectories += libDir; + } + + if (!project->values("DEF_FILE").isEmpty()) + conf.linker.ModuleDefinitionFile = project->first("DEF_FILE"); foreach(QString libs, project->values("MSVCPROJ_LIBS")) { if (libs.left(9).toUpper() == "/LIBPATH:") { @@ -1458,17 +1468,6 @@ void VcprojGenerator::initOld() // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS"); project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS_PRIVATE"); - project->values("MSVCPROJ_LFLAGS") += project->values("QMAKE_LFLAGS"); - if(!project->values("QMAKE_LIBDIR").isEmpty()) { - QStringList strl = project->values("QMAKE_LIBDIR"); - QStringList::iterator stri; - for(stri = strl.begin(); stri != strl.end(); ++stri) { - if(!(*stri).startsWith("/LIBPATH:")) - (*stri).prepend("/LIBPATH:"); - } - project->values("MSVCPROJ_LFLAGS") += strl; - } - project->values("MSVCPROJ_CXXFLAGS") += project->values("QMAKE_CXXFLAGS"); QStringList &incs = project->values("INCLUDEPATH"); for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { QString inc = (*incit); @@ -1507,9 +1506,6 @@ void VcprojGenerator::initOld() project->values("MSVCPROJ_COPY_DLL_DESC").append(deststr); } - if (!project->values("DEF_FILE").isEmpty()) - project->values("MSVCPROJ_LFLAGS").append("/DEF:"+project->first("DEF_FILE")); - project->values("QMAKE_INTERNAL_PRL_LIBS") << "MSVCPROJ_LIBS"; // Verbose output if "-d -d"... -- cgit v0.12 From 0c9866d6b23062bc08e739b66f41de200b660df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kimmo=20Kotaj=C3=A4rvi?= Date: Wed, 26 May 2010 14:53:23 +0200 Subject: Fix for QTBUG-2182: "connection still in use" warnings. --- src/sql/kernel/qsqldatabase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 76bc2b0..324a3ce 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -163,7 +163,7 @@ public: static QSqlDatabase database(const QString& name, bool open); static void addDatabase(const QSqlDatabase &db, const QString & name); static void removeDatabase(const QString& name); - static void invalidateDb(const QSqlDatabase &db, const QString &name); + static void invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn = true); static DriverDict &driverDict(); static void cleanConnections(); }; @@ -197,7 +197,7 @@ void QSqlDatabasePrivate::cleanConnections() QConnectionDict::iterator it = dict->begin(); while (it != dict->end()) { - invalidateDb(it.value(), it.key()); + invalidateDb(it.value(), it.key(), false); ++it; } dict->clear(); @@ -229,9 +229,9 @@ QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null() return &n; } -void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name) +void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn) { - if (db.d->ref != 1) { + if (db.d->ref != 1 && doWarn) { qWarning("QSqlDatabasePrivate::removeDatabase: connection '%s' is still in use, " "all queries will cease to work.", name.toLocal8Bit().constData()); db.d->disable(); -- cgit v0.12 From 1023209b9c335d72dc489d67e632d80cadac924d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Aug 2010 09:59:53 +0200 Subject: Fix build os QSharedPointer on MSVC Which does not support template friends Reviewed-by: Thiago --- src/corelib/tools/qsharedpointer_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 7f0de5f..bb06f3a 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -322,7 +322,6 @@ namespace QtSharedPointer { protected: typedef ExternalRefCountData Data; - inline void ref() const { d->weakref.ref(); d->strongref.ref(); } inline void deref() { deref(d, this->value); } static inline void deref(Data *d, T *value) @@ -409,6 +408,7 @@ namespace QtSharedPointer { template friend class QT_PREPEND_NAMESPACE(QWeakPointer); template friend QSharedPointer copyAndSetPointer(X * ptr, const QSharedPointer &src); #endif + inline void ref() const { d->weakref.ref(); d->strongref.ref(); } inline void internalSet(Data *o, T *actual) { -- 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 ae1a4a918137e99417e70a4f2c2c43f14406f993 Mon Sep 17 00:00:00 2001 From: Carolina Gomes Date: Wed, 11 Aug 2010 11:11:41 +0200 Subject: Patch to QTBUG-3078 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 723 Reviewed-by: Jan-Arve Sæther --- src/gui/graphicsview/qgraphicsgridlayout.cpp | 12 ++++++++++++ src/gui/graphicsview/qgraphicsgridlayout.h | 1 + src/gui/graphicsview/qgridlayoutengine.cpp | 9 +++++++++ src/gui/graphicsview/qgridlayoutengine_p.h | 1 + .../qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 18 ++++++++++++++++++ 5 files changed, 41 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 062b5ac..2660b06 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -589,6 +589,18 @@ void QGraphicsGridLayout::removeAt(int index) } /*! + Removes the layout item \a item without destroying it. + Ownership of the item is transferred to the caller. + + \sa addItem() +*/ +void QGraphicsGridLayout::removeItem(QGraphicsLayoutItem *item) +{ + Q_D(QGraphicsGridLayout); + int index = d->engine.indexOf(item); + removeAt(index); +} +/*! \reimp */ void QGraphicsGridLayout::invalidate() diff --git a/src/gui/graphicsview/qgraphicsgridlayout.h b/src/gui/graphicsview/qgraphicsgridlayout.h index ddfb447..d10235c 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.h +++ b/src/gui/graphicsview/qgraphicsgridlayout.h @@ -114,6 +114,7 @@ public: int count() const; QGraphicsLayoutItem *itemAt(int index) const; void removeAt(int index); + void removeItem(QGraphicsLayoutItem *item); void invalidate(); diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index a084647..f68df73 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -775,6 +775,15 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const return q_items.at(index); } +int QGridLayoutEngine::indexOf(QGraphicsLayoutItem *item) const +{ + for(int i = 0; i < q_items.size(); ++i) { + if(item == q_items.at(i)->layoutItem()) + return i; + } + return -1; +} + int QGridLayoutEngine::effectiveFirstRow(Qt::Orientation orientation) const { ensureEffectiveFirstAndLastRows(); diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h index 9ac9a8e..a4ef21d 100644 --- a/src/gui/graphicsview/qgridlayoutengine_p.h +++ b/src/gui/graphicsview/qgridlayoutengine_p.h @@ -326,6 +326,7 @@ public: // returns the number of items inserted, which may be less than (rowCount * columnCount) int itemCount() const; QGridLayoutItem *itemAt(int index) const; + int indexOf(QGraphicsLayoutItem *item) const; int effectiveFirstRow(Qt::Orientation orientation = Qt::Vertical) const; int effectiveLastRow(Qt::Orientation orientation = Qt::Vertical) const; diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index d1d6860..123dd89 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -78,6 +78,7 @@ private slots: void horizontalSpacing(); void itemAt(); void removeAt(); + void removeLayoutItems(); void rowAlignment(); void rowCount(); void rowMaximumHeight(); @@ -992,6 +993,23 @@ void tst_QGraphicsGridLayout::removeAt() delete widget; } +void tst_QGraphicsGridLayout::removeLayoutItems() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); + scene.addItem(widget); + QGraphicsGridLayout *l = new QGraphicsGridLayout(); + widget->setLayout(l); + + populateLayout(l, 3, 2); + QCOMPARE(l->count(), 6); + l->removeItem(l->itemAt(5)); + l->removeItem(l->itemAt(4)); + QCOMPARE(l->count(), 4); +} + // public Qt::Alignment rowAlignment(int row) const void tst_QGraphicsGridLayout::rowAlignment() { -- cgit v0.12 From 23122981e186e6b071f6690dec0fd1d57ee3bbdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Wed, 11 Aug 2010 11:16:10 +0200 Subject: Some polishing to merge request 723 --- src/gui/graphicsview/qgraphicsgridlayout.cpp | 2 +- src/gui/graphicsview/qgridlayoutengine.cpp | 4 ++-- tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 13 +++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/gui/graphicsview/qgraphicsgridlayout.cpp index 2660b06..8a3f17a 100644 --- a/src/gui/graphicsview/qgraphicsgridlayout.cpp +++ b/src/gui/graphicsview/qgraphicsgridlayout.cpp @@ -589,7 +589,7 @@ void QGraphicsGridLayout::removeAt(int index) } /*! - Removes the layout item \a item without destroying it. + Removes the layout item \a item without destroying it. Ownership of the item is transferred to the caller. \sa addItem() diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index f68df73..8b65282 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -777,8 +777,8 @@ QGridLayoutItem *QGridLayoutEngine::itemAt(int index) const int QGridLayoutEngine::indexOf(QGraphicsLayoutItem *item) const { - for(int i = 0; i < q_items.size(); ++i) { - if(item == q_items.at(i)->layoutItem()) + for (int i = 0; i < q_items.size(); ++i) { + if (item == q_items.at(i)->layoutItem()) return i; } return -1; diff --git a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 123dd89..55d75af 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -78,7 +78,7 @@ private slots: void horizontalSpacing(); void itemAt(); void removeAt(); - void removeLayoutItems(); + void removeItem(); void rowAlignment(); void rowCount(); void rowMaximumHeight(); @@ -993,7 +993,7 @@ void tst_QGraphicsGridLayout::removeAt() delete widget; } -void tst_QGraphicsGridLayout::removeLayoutItems() +void tst_QGraphicsGridLayout::removeItem() { QGraphicsScene scene; QGraphicsView view(&scene); @@ -1008,6 +1008,15 @@ void tst_QGraphicsGridLayout::removeLayoutItems() l->removeItem(l->itemAt(5)); l->removeItem(l->itemAt(4)); QCOMPARE(l->count(), 4); + + // Avoid crashing. Note that the warning message might change in the future. + QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData()); + l->removeItem(0); + QCOMPARE(l->count(), 4); + + QTest::ignoreMessage(QtWarningMsg, QString::fromAscii("QGraphicsGridLayout::removeAt: invalid index -1").toLatin1().constData()); + l->removeItem(new QGraphicsWidget); + QCOMPARE(l->count(), 4); } // public Qt::Alignment rowAlignment(int row) const -- cgit v0.12 From 56396b4b2b66da3133aff1b3864c550ce892d233 Mon Sep 17 00:00:00 2001 From: Magne Pettersen Zachrisen Date: Tue, 10 Aug 2010 21:52:06 +0200 Subject: Added -random option to tests, making the test cases within a test execute in arbitrary order. Very useful for avoiding test cases being dependent on the running order. Added -seed option -random to make it possible to reroduce test results. The seed is printed out when -random is specified Added selftests for -random and -seed options Changed int parsing into strtol and QTime->QDateTime as suggested by Mr Macieira, fixed selftests Merge-request: 2362 Reviewed-by: Thiago Macieira --- src/testlib/qabstracttestlogger_p.h | 2 + src/testlib/qplaintestlogger.cpp | 22 +++- src/testlib/qplaintestlogger_p.h | 4 + src/testlib/qtestcase.cpp | 157 ++++++++++++++++++++------ src/testlib/qtestlightxmlstreamer.cpp | 8 +- src/testlib/qtestlog.cpp | 55 +++++---- src/testlib/qtestlog_p.h | 2 +- src/testlib/qtestlogger.cpp | 27 ++++- src/testlib/qtestlogger_p.h | 5 + src/testlib/qtestxmlstreamer.cpp | 10 +- src/testlib/qxmltestlogger.cpp | 27 ++++- src/testlib/qxmltestlogger_p.h | 4 + src/testlib/testlib.pro | 1 + tests/auto/selftests/expected_random.lightxml | 20 ++++ tests/auto/selftests/expected_random.txt | 9 ++ tests/auto/selftests/expected_random.xml | 23 ++++ tests/auto/selftests/expected_random.xunitxml | 14 +++ tests/auto/selftests/random/random.pro | 9 ++ tests/auto/selftests/random/tst_random.cpp | 28 +++++ tests/auto/selftests/selftests.pro | 2 +- tests/auto/selftests/selftests.qrc | 6 +- tests/auto/selftests/tst_selftests.cpp | 5 + 22 files changed, 368 insertions(+), 72 deletions(-) create mode 100644 tests/auto/selftests/expected_random.lightxml create mode 100644 tests/auto/selftests/expected_random.txt create mode 100644 tests/auto/selftests/expected_random.xml create mode 100644 tests/auto/selftests/expected_random.xunitxml create mode 100644 tests/auto/selftests/random/random.pro create mode 100644 tests/auto/selftests/random/tst_random.cpp diff --git a/src/testlib/qabstracttestlogger_p.h b/src/testlib/qabstracttestlogger_p.h index c84f327..a996e88 100644 --- a/src/testlib/qabstracttestlogger_p.h +++ b/src/testlib/qabstracttestlogger_p.h @@ -95,6 +95,8 @@ public: virtual void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0) = 0; + virtual void registerRandomSeed(unsigned int seed) = 0; + static void outputString(const char *msg); static bool isTtyOutput(); }; diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 1a0e737..59248a9 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -384,6 +384,7 @@ namespace QTest { } QPlainTestLogger::QPlainTestLogger() +: randomSeed(9), hasRandomSeed(false) { #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) InitializeCriticalSection(&QTest::outputCriticalSection); @@ -415,10 +416,17 @@ void QPlainTestLogger::startLogging() QTest::qt_snprintf(buf, sizeof(buf), "Testing %s\n", QTestResult::currentTestObjectName()); } else { - QTest::qt_snprintf(buf, sizeof(buf), - "********* Start testing of %s *********\n" - "Config: Using QTest library " QTEST_VERSION_STR - ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion()); + if (hasRandomSeed) { + QTest::qt_snprintf(buf, sizeof(buf), + "********* Start testing of %s *********\n" + "Config: Using QTest library " QTEST_VERSION_STR + ", Qt %s, Random seed %d\n", QTestResult::currentTestObjectName(), qVersion(), randomSeed); + } else { + QTest::qt_snprintf(buf, sizeof(buf), + "********* Start testing of %s *********\n" + "Config: Using QTest library " QTEST_VERSION_STR + ", Qt %s\n", QTestResult::currentTestObjectName(), qVersion()); + } } QTest::outputMessage(buf); } @@ -480,4 +488,10 @@ void QPlainTestLogger::addMessage(MessageTypes type, const char *message, QTest::printMessage(QTest::messageType2String(type), message, file, line); } +void QPlainTestLogger::registerRandomSeed(unsigned int seed) +{ + randomSeed = seed; + hasRandomSeed = true; +} + QT_END_NAMESPACE diff --git a/src/testlib/qplaintestlogger_p.h b/src/testlib/qplaintestlogger_p.h index f1f1d4e..9195600 100644 --- a/src/testlib/qplaintestlogger_p.h +++ b/src/testlib/qplaintestlogger_p.h @@ -75,6 +75,10 @@ public: void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); + void registerRandomSeed(unsigned int seed); +private: + unsigned int randomSeed; + bool hasRandomSeed; }; QT_END_NAMESPACE diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 17f1a6b..5934850 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -826,25 +826,46 @@ namespace QTest { static QObject *currentTestObject = 0; - static struct TestFunction { - TestFunction():function(0), data(0) {} - ~TestFunction() { delete [] data; } - int function; - char *data; - } *testFuncs; - + class TestFunction { + public: + TestFunction() : function_(-1), data_(0) {} + void set(int function, char *data) { function_ = function; data_ = data; } + char *data() const { return data_; } + int function() const { return function_; } + ~TestFunction() { delete[] data_; } + private: + int function_; + char *data_; + }; /** - * Contains the count of test functions that was supplied - * on the command line, if any. Hence, if lastTestFuncIdx is - * more than zero, those functions should be run instead of + * Contains the list of test functions that was supplied + * on the command line, if any. Hence, if not empty, + * those functions should be run instead of * all appearing in the test case. */ - static int lastTestFuncIdx = -1; + static TestFunction * testFuncs = 0; + static int testFuncCount = 0; + + /** Don't leak testFuncs on exit even on error */ + static struct TestFuncCleanup + { + void cleanup() + { + delete[] testFuncs; + testFuncCount = 0; + testFuncs = 0; + } + + ~TestFuncCleanup() { cleanup(); } + } testFuncCleaner; static int keyDelay = -1; static int mouseDelay = -1; static int eventDelay = -1; + static bool randomOrder = false; static int keyVerbose = -1; + static unsigned int seed = 0; + static bool seedSet = false; #if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN) static bool noCrashHandler = false; #endif @@ -930,6 +951,41 @@ int Q_TESTLIB_EXPORT defaultKeyDelay() return keyDelay; } +void seedRandom() +{ + static bool randomSeeded = false; + if (!randomSeeded) { + if (!QTest::seedSet) { + QTest::seed = QDateTime::currentDateTime().toTime_t(); + } + qsrand(QTest::seed); + randomSeeded = true; + } +} + +int qTestRandomSeed() +{ + Q_ASSERT(QTest::seedSet); + return QTest::seed; +} + +template +void swap(T * array, int pos, int otherPos) +{ + T tmp = array[pos]; + array[pos] = array[otherPos]; + array[otherPos] = tmp; +} + +template +static void randomizeList(T * array, int size) +{ + for (int i = 0; i != size; i++) { + int pos = qrand() % size; + swap(array, pos, i); + } +} + static bool isValidSlot(const QMetaMethod &sl) { if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty() @@ -971,8 +1027,6 @@ static int qToInt(char *str) static void qParseArgs(int argc, char *argv[]) { - lastTestFuncIdx = -1; - const char *testOptions = " options:\n" " -functions : Returns a list of current testfunctions\n" @@ -985,6 +1039,9 @@ static void qParseArgs(int argc, char *argv[]) " -v1 : Print enter messages for each testfunction\n" " -v2 : Also print out each QVERIFY/QCOMPARE/QTEST\n" " -vs : Print every signal emitted\n" + " -random : Run testcases within each test in random order\n" + " -seed n : Positive integer to be used as seed for -random. If not specified,\n" + " the current time will be used as seed.\n" " -eventdelay ms : Set default delay for mouse and keyboard simulation to ms milliseconds\n" " -keydelay ms : Set default delay for keyboard simulation to ms milliseconds\n" " -mousedelay ms : Set default delay for mouse simulation to ms milliseconds\n" @@ -1100,6 +1157,22 @@ static void qParseArgs(int argc, char *argv[]) #endif } else if (strcmp(argv[i], "-eventcounter") == 0) { QBenchmarkGlobalData::current->setMode(QBenchmarkGlobalData::EventCounter); + } else if (strcmp(argv[i], "-random") == 0) { + QTest::randomOrder = true; + } else if (strcmp(argv[i], "-seed") == 0) { + bool argumentOk = false; + if (i + 1 < argc) { + char * endpt = 0; + long longSeed = strtol(argv[++i], &endpt, 10); + argumentOk = (*endpt == '\0' && longSeed >= 0); + QTest::seed = longSeed; + } + if (!argumentOk) { + printf("-seed needs an extra positive integer parameter to specify the seed\n"); + exit(1); + } else { + QTest::seedSet = true; + } } else if (strcmp(argv[i], "-minimumvalue") == 0) { if (i + 1 >= argc) { printf("-minimumvalue needs an extra parameter to indicate the minimum time(ms)\n"); @@ -1140,6 +1213,10 @@ static void qParseArgs(int argc, char *argv[]) printf("Unknown option: '%s'\n\n%s", argv[i], testOptions); exit(1); } else { + if (!QTest::testFuncs) { + QTest::testFuncs = new QTest::TestFunction[512]; + } + int colon = -1; char buf[512], *data=0; int off; @@ -1161,17 +1238,16 @@ static void qParseArgs(int argc, char *argv[]) qPrintTestSlots(); exit(1); } - ++QTest::lastTestFuncIdx; - if (!QTest::testFuncs) { - struct Cleanup { ~Cleanup() { delete[] QTest::testFuncs; } }; - static Cleanup cleanup; - QTest::testFuncs = new TestFunction[512]; - } - QTest::testFuncs[QTest::lastTestFuncIdx].function = idx; - QTest::testFuncs[QTest::lastTestFuncIdx].data = data; - QTEST_ASSERT(QTest::lastTestFuncIdx < 512); + testFuncs[testFuncCount].set(idx, data); + testFuncCount++; + QTEST_ASSERT(QTest::testFuncCount < 512); } } + + if (QTest::seedSet && !QTest::randomOrder) { + printf("-seed requires -random\n"); + exit(1); + } } QBenchmarkResult qMedian(const QList &container) @@ -1466,9 +1542,11 @@ static void qInvokeTestMethods(QObject *testObject) { const QMetaObject *metaObject = testObject->metaObject(); QTEST_ASSERT(metaObject); - - QTestLog::startLogging(); - + if (QTest::randomOrder) { + QTestLog::startLogging(QTest::seed); + } else { + QTestLog::startLogging(); + } QTestResult::setCurrentTestFunction("initTestCase"); QTestResult::setCurrentTestLocation(QTestResult::DataFunc); QTestTable::globalTestTable(); @@ -1484,21 +1562,31 @@ static void qInvokeTestMethods(QObject *testObject) if(!QTestResult::skipCurrentTest() && !previousFailed) { - if (lastTestFuncIdx >= 0) { - for (int i = 0; i <= lastTestFuncIdx; ++i) { - if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(), - testFuncs[i].data)) + if (QTest::testFuncs) { + if (QTest::randomOrder) + randomizeList(QTest::testFuncs, QTest::testFuncCount); + for (int i = 0; i != QTest::testFuncCount; i++) { + if (!qInvokeTestMethod(metaObject->method(QTest::testFuncs[i].function()).signature(), + QTest::testFuncs[i].data())) { break; + } } + testFuncCleaner.cleanup(); } else { int methodCount = metaObject->methodCount(); - for (int i = 0; i < methodCount; ++i) { - QMetaMethod slotMethod = metaObject->method(i); - if (!isValidSlot(slotMethod)) + QMetaMethod *testMethods = new QMetaMethod[methodCount]; + for (int i = 0; i != methodCount; i++) + testMethods[i] = metaObject->method(i); + if (QTest::randomOrder) + randomizeList(testMethods, methodCount); + for (int i = 0; i != methodCount; i++) { + if (!isValidSlot(testMethods[i])) continue; - if (!qInvokeTestMethod(slotMethod.signature())) + if (!qInvokeTestMethod(testMethods[i].signature())) break; } + delete[] testMethods; + testMethods = 0; } } @@ -1689,6 +1777,9 @@ int QTest::qExec(QObject *testObject, int argc, char **argv) QTestResult::setCurrentTestObject(metaObject->className()); qParseArgs(argc, argv); + if (QTest::randomOrder) { + seedRandom(); + } #ifdef QTESTLIB_USE_VALGRIND if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) { const QStringList origAppArgs(QCoreApplication::arguments()); diff --git a/src/testlib/qtestlightxmlstreamer.cpp b/src/testlib/qtestlightxmlstreamer.cpp index 0ac9ea8..cc5397a 100644 --- a/src/testlib/qtestlightxmlstreamer.cpp +++ b/src/testlib/qtestlightxmlstreamer.cpp @@ -42,6 +42,7 @@ #include "qtestlightxmlstreamer.h" #include "qtestelement.h" #include "qtestelementattribute.h" +#include "qtestlogger_p.h" #include "QtTest/private/qtestlog_p.h" #include "QtTest/private/qtestresult_p.h" @@ -164,8 +165,13 @@ void QTestLightXmlStreamer::formatBeforeAttributes(const QTestElement *element, void QTestLightXmlStreamer::output(QTestElement *element) const { QTestCharBuffer buf; - QTest::qt_asprintf(&buf, "\n %s\n %s\n", + if (logger()->hasRandomSeed()) { + QTest::qt_asprintf(&buf, "\n %s\n %s\n %d\n", + qVersion(), QTEST_VERSION_STR, logger()->randomSeed() ); + } else { + QTest::qt_asprintf(&buf, "\n %s\n %s\n", qVersion(), QTEST_VERSION_STR ); + } outputString(buf.constData()); QTest::qt_asprintf(&buf, "\n"); diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 398dec5..d58e231 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -168,6 +168,29 @@ namespace QTest { } } +void initLogger() +{ + switch (QTest::logMode) { + case QTestLog::Plain: + QTest::testLogger = new QPlainTestLogger; + break; + case QTestLog::XML:{ + if(QTest::flushMode == QTestLog::FLushOn) + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete); + else + QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML); + break; + }case QTestLog::LightXML:{ + if(QTest::flushMode == QTestLog::FLushOn) + QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); + else + QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml); + break; + }case QTestLog::XunitXML: + QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml); + } +} + } QTestLog::QTestLog() @@ -268,32 +291,20 @@ void QTestLog::addBenchmarkResult(const QBenchmarkResult &result) QTest::testLogger->addBenchmarkResult(result); } -void QTestLog::startLogging() +void QTestLog::startLogging(unsigned int randomSeed) { QTEST_ASSERT(!QTest::testLogger); - - switch (QTest::logMode) { - case QTestLog::Plain: - QTest::testLogger = new QPlainTestLogger; - break; - case QTestLog::XML:{ - if(QTest::flushMode == QTestLog::FLushOn) - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Complete); - else - QTest::testLogger = new QTestLogger(QTestLogger::TLF_XML); - break; - }case QTestLog::LightXML:{ - if(QTest::flushMode == QTestLog::FLushOn) - QTest::testLogger = new QXmlTestLogger(QXmlTestLogger::Light); - else - QTest::testLogger = new QTestLogger(QTestLogger::TLF_LightXml); - break; - }case QTestLog::XunitXML: - QTest::testLogger = new QTestLogger(QTestLogger::TLF_XunitXml); - } - + QTest::initLogger(); + QTest::testLogger->registerRandomSeed(randomSeed); QTest::testLogger->startLogging(); + QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler); +} +void QTestLog::startLogging() +{ + QTEST_ASSERT(!QTest::testLogger); + QTest::initLogger(); + QTest::testLogger->startLogging(); QTest::oldMessageHandler = qInstallMsgHandler(QTest::messageHandler); } diff --git a/src/testlib/qtestlog_p.h b/src/testlib/qtestlog_p.h index d36ff04..01d39eb 100644 --- a/src/testlib/qtestlog_p.h +++ b/src/testlib/qtestlog_p.h @@ -83,6 +83,7 @@ public: static void info(const char *msg, const char *file, int line); static void startLogging(); + static void startLogging(unsigned int randomSeed); static void stopLogging(); static void setLogMode(LogMode mode); @@ -97,7 +98,6 @@ public: static void setMaxWarnings(int max); static void setFlushMode(FlushMode mode); - private: QTestLog(); ~QTestLog(); diff --git a/src/testlib/qtestlogger.cpp b/src/testlib/qtestlogger.cpp index f0be6be..cab97d1 100644 --- a/src/testlib/qtestlogger.cpp +++ b/src/testlib/qtestlogger.cpp @@ -62,7 +62,8 @@ QTestLogger::QTestLogger(int fm) warningCounter(0), skipCounter(0), systemCounter(0), qdebugCounter(0), qwarnCounter(0), qfatalCounter(0), - infoCounter(0) + infoCounter(0), randomSeed_(0), + hasRandomSeed_(false) { } @@ -133,6 +134,14 @@ void QTestLogger::stopLogging() property->addAttribute(QTest::AI_PropertyValue, qVersion()); properties->addLogElement(property); + if (hasRandomSeed()) { + property = new QTestElement(QTest::LET_Property); + property->addAttribute(QTest::AI_Name, "RandomSeed"); + QTest::qt_snprintf(buf, sizeof(buf), "%i", randomSeed()); + property->addAttribute(QTest::AI_PropertyValue, buf); + properties->addLogElement(property); + } + currentLogElement->addLogElement(properties); currentLogElement->addLogElement(iterator); @@ -420,5 +429,21 @@ int QTestLogger::infoCount() const return infoCounter; } +void QTestLogger::registerRandomSeed(unsigned int seed) +{ + randomSeed_ = seed; + hasRandomSeed_ = true; +} + +unsigned int QTestLogger::randomSeed() const +{ + return randomSeed_; +} + +bool QTestLogger::hasRandomSeed() const +{ + return hasRandomSeed_; +} + QT_END_NAMESPACE diff --git a/src/testlib/qtestlogger_p.h b/src/testlib/qtestlogger_p.h index bb7a358..8932a85 100644 --- a/src/testlib/qtestlogger_p.h +++ b/src/testlib/qtestlogger_p.h @@ -101,6 +101,9 @@ class QTestLogger : public QAbstractTestLogger int qwarnCount() const; int qfatalCount() const; int infoCount() const; + void registerRandomSeed(unsigned int seed); + unsigned int randomSeed() const; + bool hasRandomSeed() const; private: QTestElement *listOfTestcases; @@ -121,6 +124,8 @@ class QTestLogger : public QAbstractTestLogger int qwarnCounter; int qfatalCounter; int infoCounter; + unsigned int randomSeed_; + bool hasRandomSeed_; }; QT_END_NAMESPACE diff --git a/src/testlib/qtestxmlstreamer.cpp b/src/testlib/qtestxmlstreamer.cpp index f63c221..a6b8376 100644 --- a/src/testlib/qtestxmlstreamer.cpp +++ b/src/testlib/qtestxmlstreamer.cpp @@ -42,6 +42,7 @@ #include "qtestxmlstreamer.h" #include "qtestelement.h" #include "qtestelementattribute.h" +#include "qtestlogger_p.h" #include "QtTest/private/qtestlog_p.h" #include "QtTest/private/qtestresult_p.h" @@ -204,8 +205,13 @@ void QTestXmlStreamer::output(QTestElement *element) const quotedTc.constData()); outputString(buf.constData()); - QTest::qt_asprintf(&buf, "\n %s\n %s\n", - qVersion(), QTEST_VERSION_STR ); + if (logger()->hasRandomSeed()) { + QTest::qt_asprintf(&buf, "\n %s\n %s\n %d\n", + qVersion(), QTEST_VERSION_STR, logger()->randomSeed() ); + } else { + QTest::qt_asprintf(&buf, "\n %s\n %s\n", + qVersion(), QTEST_VERSION_STR ); + } outputString(buf.constData()); QTest::qt_asprintf(&buf, "\n"); diff --git a/src/testlib/qxmltestlogger.cpp b/src/testlib/qxmltestlogger.cpp index 07e8ef0..2bf7d77 100644 --- a/src/testlib/qxmltestlogger.cpp +++ b/src/testlib/qxmltestlogger.cpp @@ -93,7 +93,7 @@ namespace QTest { QXmlTestLogger::QXmlTestLogger(XmlMode mode ) - :xmlmode(mode) + :xmlmode(mode), randomSeed(0), hasRandomSeed(false) { } @@ -116,11 +116,20 @@ void QXmlTestLogger::startLogging() outputString(buf.constData()); } - QTest::qt_asprintf(&buf, - "\n" - " %s\n" - " "QTEST_VERSION_STR"\n" - "\n", qVersion()); + if (hasRandomSeed) { + QTest::qt_asprintf(&buf, + "\n" + " %s\n" + " "QTEST_VERSION_STR"\n" + " %d\n" + "\n", qVersion(), randomSeed); + } else { + QTest::qt_asprintf(&buf, + "\n" + " %s\n" + " "QTEST_VERSION_STR"\n" + "\n", qVersion()); + } outputString(buf.constData()); } @@ -441,4 +450,10 @@ int QXmlTestLogger::xmlCdata(QTestCharBuffer* str, char const* src) return allocateStringFn(str, src, QXmlTestLogger::xmlCdata); } +void QXmlTestLogger::registerRandomSeed(unsigned int seed) +{ + randomSeed = seed; + hasRandomSeed = true; +} + QT_END_NAMESPACE diff --git a/src/testlib/qxmltestlogger_p.h b/src/testlib/qxmltestlogger_p.h index ae918dc..82dd8a6 100644 --- a/src/testlib/qxmltestlogger_p.h +++ b/src/testlib/qxmltestlogger_p.h @@ -79,6 +79,8 @@ public: void addMessage(MessageTypes type, const char *message, const char *file = 0, int line = 0); + void registerRandomSeed(unsigned int seed); + static int xmlCdata(QTestCharBuffer *dest, char const* src); static int xmlQuote(QTestCharBuffer *dest, char const* src); static int xmlCdata(QTestCharBuffer *dest, char const* src, size_t n); @@ -86,6 +88,8 @@ public: private: XmlMode xmlmode; + unsigned int randomSeed; + bool hasRandomSeed; }; QT_END_NAMESPACE diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index a8186d8..6bb0492 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -1,6 +1,7 @@ TARGET = QtTest QPRO_PWD = $$PWD QT = core +CONFIG += debug INCLUDEPATH += . unix:!embedded:QMAKE_PKGCONFIG_DESCRIPTION = Qt \ Unit \ diff --git a/tests/auto/selftests/expected_random.lightxml b/tests/auto/selftests/expected_random.lightxml new file mode 100644 index 0000000..15f56a1 --- /dev/null +++ b/tests/auto/selftests/expected_random.lightxml @@ -0,0 +1,20 @@ + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + 325 + + + + + + + + + + + + + + + + diff --git a/tests/auto/selftests/expected_random.txt b/tests/auto/selftests/expected_random.txt new file mode 100644 index 0000000..3f4c11d --- /dev/null +++ b/tests/auto/selftests/expected_random.txt @@ -0,0 +1,9 @@ +********* Start testing of tst_Random ********* +Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@, Random seed 325 +PASS : tst_Random::initTestCase() +PASS : tst_Random::testTwo() +PASS : tst_Random::testOne() +PASS : tst_Random::testThree() +PASS : tst_Random::cleanupTestCase() +Totals: 5 passed, 0 failed, 0 skipped +********* Finished testing of tst_Random ********* diff --git a/tests/auto/selftests/expected_random.xml b/tests/auto/selftests/expected_random.xml new file mode 100644 index 0000000..3677287 --- /dev/null +++ b/tests/auto/selftests/expected_random.xml @@ -0,0 +1,23 @@ + + + + @INSERT_QT_VERSION_HERE@ + @INSERT_QT_VERSION_HERE@ + 325 + + + + + + + + + + + + + + + + + diff --git a/tests/auto/selftests/expected_random.xunitxml b/tests/auto/selftests/expected_random.xunitxml new file mode 100644 index 0000000..262aa0a --- /dev/null +++ b/tests/auto/selftests/expected_random.xunitxml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/auto/selftests/random/random.pro b/tests/auto/selftests/random/random.pro new file mode 100644 index 0000000..19572ad --- /dev/null +++ b/tests/auto/selftests/random/random.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +SOURCES += tst_random.cpp +QT = core + +mac:CONFIG -= app_bundle +CONFIG -= debug_and_release_target + + +TARGET = random diff --git a/tests/auto/selftests/random/tst_random.cpp b/tests/auto/selftests/random/tst_random.cpp new file mode 100644 index 0000000..1ee922e --- /dev/null +++ b/tests/auto/selftests/random/tst_random.cpp @@ -0,0 +1,28 @@ +#include +#include + +class tst_Random: public QObject +{ + Q_OBJECT + +private slots: + void testOne() const {} + void testTwo() const {} + void testThree() const {} +}; + +/* +int main(int argc, char * argv[]) +{ + int failures = 0; + tst_Random tst; + for (int i = 0; i != 10; i++) { + failures += QTest::qExec(&tst, argc, argv); + } + return failures; +} +*/ +QTEST_MAIN(tst_Random) + +#include "tst_random.moc" + diff --git a/tests/auto/selftests/selftests.pro b/tests/auto/selftests/selftests.pro index d854b5e..bfbd598 100644 --- a/tests/auto/selftests/selftests.pro +++ b/tests/auto/selftests/selftests.pro @@ -5,7 +5,7 @@ SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skipglobal skip \ skipinit skipinitdata datetime singleskip assert waitwithoutgui differentexec \ exceptionthrow qexecstringlist datatable commandlinedata\ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ - benchliboptions xunit badxml longstring + benchliboptions xunit badxml longstring random INSTALLS = diff --git a/tests/auto/selftests/selftests.qrc b/tests/auto/selftests/selftests.qrc index f82722b..ba7ca4f 100644 --- a/tests/auto/selftests/selftests.qrc +++ b/tests/auto/selftests/selftests.qrc @@ -90,6 +90,10 @@ expected_multiexec.xml expected_multiexec.xunitxml expected_qexecstringlist.txt + expected_random.txt + expected_random.lightxml + expected_random.xml + expected_random.xunitxml expected_singleskip.lightxml expected_singleskip.txt expected_singleskip.xml @@ -134,5 +138,5 @@ expected_xunit.txt expected_xunit.xml expected_xunit.xunitxml - + diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 0818b4c..9fb7ce6 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -245,6 +245,7 @@ void tst_Selftests::runSubTest_data() << "xunit" << "longstring" << "badxml" + << "random" ; foreach (Logger const& logger, allLoggers()) { @@ -273,6 +274,9 @@ void tst_Selftests::runSubTest_data() else if (subtest == "badxml") { arguments << "-eventcounter"; } + else if (subtest == "random") { + arguments << QString("-random -seed 325").split(' '); + } // These tests don't work right with loggers other than plain, usually because // they internally supply arguments to themselves. @@ -632,3 +636,4 @@ void tst_Selftests::cleanupTestCase() QTEST_MAIN(tst_Selftests) #include "tst_selftests.moc" + -- cgit v0.12 From c74489031684a77bdec5f009e234cbec4497cd0d Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 12 Aug 2010 08:46:38 +1000 Subject: Fixed linking against libQtTest on Mac. Fixes: `ld: framework not found QtTest' testlib was forcing CONFIG+=debug, which caused only the QtTest_debug variant of the framework to be produced on Mac. Qt libraries shouldn't force release or debug at this level. --- src/testlib/testlib.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro index 6bb0492..a8186d8 100644 --- a/src/testlib/testlib.pro +++ b/src/testlib/testlib.pro @@ -1,7 +1,6 @@ TARGET = QtTest QPRO_PWD = $$PWD QT = core -CONFIG += debug INCLUDEPATH += . unix:!embedded:QMAKE_PKGCONFIG_DESCRIPTION = Qt \ Unit \ -- cgit v0.12 From cf13b06e88e68ca966d6327c0e12cc7b89d616fc Mon Sep 17 00:00:00 2001 From: John Brooks Date: Thu, 12 Aug 2010 10:14:25 +0200 Subject: Cleanup the connection list logic in QObject::sender Merge-request: 2433 Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qobject.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 143dbff..9ce111d 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2298,13 +2298,12 @@ QObject *QObject::sender() const if (!d->currentSender) return 0; - // Return 0 if d->currentSender isn't in d->senders - bool found = false; - for (QObjectPrivate::Connection *c = d->senders; c && !found; c = c->next) - found = (c->sender == d->currentSender->sender); - if (!found) - return 0; - return d->currentSender->sender; + for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) { + if (c->sender == d->currentSender->sender) + return d->currentSender->sender; + } + + return 0; } /*! -- cgit v0.12 From a6892d69281d3555f3c3fd03f3b3892b1940191d Mon Sep 17 00:00:00 2001 From: John Brooks Date: Thu, 12 Aug 2010 10:14:28 +0200 Subject: Added QObject::senderSignalIndex() Returns the metamethod index of the signal executing the current slot Merge-request: 2433 Reviewed-by: Bradley T. Hughes --- src/corelib/kernel/qobject.cpp | 43 +++++++++++++++++++++++++++++++++++++- src/corelib/kernel/qobject.h | 1 + tests/auto/qobject/tst_qobject.cpp | 24 +++++++++++++++++++-- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 9ce111d..ceffa66 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2287,7 +2287,7 @@ static void err_info_about_objects(const char * func, a thread different from this object's thread. Do not use this function in this type of scenario. - \sa QSignalMapper + \sa senderSignalIndex(), QSignalMapper */ QObject *QObject::sender() const @@ -2307,6 +2307,47 @@ QObject *QObject::sender() const } /*! + \since 4.8 + + Returns the meta-method index of the signal that called the currently + executing slot, which is a member of the class returned by sender(). + If called outside of a slot activated by a signal, -1 is returned. + + For signals with default parameters, this function will always return + the index with all parameters, regardless of which was used with + connect(). For example, the signal \c {destroyed(QObject *obj = 0)} + will have two different indexes (with and without the parameter), but + this function will always return the index with a parameter. This does + not apply when overloading signals with different parameters. + + \warning This function violates the object-oriented principle of + modularity. However, getting access to the signal index might be useful + when many signals are connected to a single slot. + + \warning The return value of this function is not valid when the slot + is called via a Qt::DirectConnection from a thread different from this + object's thread. Do not use this function in this type of scenario. + + \sa sender(), QMetaObject::indexOfSignal(), QMetaObject::method() +*/ + +int QObject::senderSignalIndex() const +{ + Q_D(const QObject); + + QMutexLocker locker(signalSlotLock(this)); + if (!d->currentSender) + return -1; + + for (QObjectPrivate::Connection *c = d->senders; c; c = c->next) { + if (c->sender == d->currentSender->sender) + return d->currentSender->signal; + } + + return -1; +} + +/*! Returns the number of receivers connected to the \a signal. Since both slots and signals can be used as receivers for signals, diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 21bad16..b5db936 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -280,6 +280,7 @@ public Q_SLOTS: protected: QObject *sender() const; + int senderSignalIndex() const; int receivers(const char* signal) const; virtual void timerEvent(QTimerEvent *); diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp index fc38a84..abfe24b 100644 --- a/tests/auto/qobject/tst_qobject.cpp +++ b/tests/auto/qobject/tst_qobject.cpp @@ -1782,9 +1782,12 @@ class SuperObject : public QObject Q_OBJECT public: QObject *theSender; + int theSignalId; + SuperObject() { theSender = 0; + theSignalId = 0; } friend class tst_QObject; @@ -1795,16 +1798,17 @@ public slots: void rememberSender() { theSender = sender(); + theSignalId = senderSignalIndex(); } void deleteAndRememberSender() { delete theSender; - theSender = sender(); + rememberSender(); } signals: + void anotherSignal(); void theSignal(); - }; void tst_QObject::sender() @@ -1812,12 +1816,23 @@ void tst_QObject::sender() { SuperObject sender; SuperObject receiver; + connect(&sender, SIGNAL(anotherSignal()), + &receiver, SLOT(rememberSender())); connect(&sender, SIGNAL(theSignal()), &receiver, SLOT(rememberSender())); QCOMPARE(receiver.sender(), (QObject *)0); + QCOMPARE(receiver.senderSignalIndex(), -1); emit sender.theSignal(); QCOMPARE(receiver.theSender, (QObject *)&sender); QCOMPARE(receiver.sender(), (QObject *)0); + QCOMPARE(receiver.theSignalId, + sender.metaObject()->indexOfSignal("theSignal()")); + QCOMPARE(receiver.senderSignalIndex(), -1); + + emit sender.anotherSignal(); + QCOMPARE(receiver.theSignalId, + sender.metaObject()->indexOfSignal("anotherSignal()")); + QCOMPARE(receiver.senderSignalIndex(), -1); } { @@ -1834,11 +1849,16 @@ void tst_QObject::sender() Qt::DirectConnection); QCOMPARE(receiver->sender(), (QObject *)0); + QCOMPARE(receiver->senderSignalIndex(), -1); receiver->theSender = 0; + receiver->theSignalId = -1; thread.start(); emit sender->theSignal(); QCOMPARE(receiver->theSender, (QObject *) sender); QCOMPARE(receiver->sender(), (QObject *)0); + QCOMPARE(receiver->theSignalId, + sender->metaObject()->indexOfSignal("theSignal()")); + QCOMPARE(receiver->senderSignalIndex(), -1); QVERIFY(thread.wait(10000)); delete receiver; -- cgit v0.12 From 53e2167cfae5fd5275892ccc926b7436199e3590 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:14:51 +0200 Subject: QNativeSocketEngine: Fix wrong debug output --- src/network/socket/qnativesocketengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index f91ce5f..bb3f0e4 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -887,7 +887,7 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize) { Q_Q(QNativeSocketEngine); if (!q->isValid()) { - qWarning("QNativeSocketEngine::unbufferedRead: Invalid socket"); + qWarning("QNativeSocketEngine::nativeRead: Invalid socket"); return -1; } -- cgit v0.12 From 01057a2d328004d33983198e6afc8c9ab03cc65d Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:16:15 +0200 Subject: QAbstractSocket: Enable Unbuffered OpenMode for TCP Reviewed-by: Peter Hartmann Reviewed-by: Jeremy Katz Reviewed-by: Aleksandar Sasha Babic --- src/network/socket/qabstractsocket.cpp | 143 +++++++++++++++++++++++++-------- 1 file changed, 111 insertions(+), 32 deletions(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 171fbb6..ca72271 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -627,8 +627,9 @@ bool QAbstractSocketPrivate::canReadNotification() // only emit readyRead() when not recursing, and only if there is data available bool hasData = newBytes > 0 #ifndef QT_NO_UDPSOCKET - || (!isBuffered && socketEngine && socketEngine->hasPendingDatagrams()) + || (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams()) #endif + || (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine) ; if (!emittedReadyRead && hasData) { @@ -1350,8 +1351,11 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint } #endif - if (!d_func()->isBuffered) - openMode |= QAbstractSocket::Unbuffered; + if (openMode & QIODevice::Unbuffered) + d->isBuffered = false; // Unbuffered QTcpSocket + else if (!d_func()->isBuffered) + openMode |= QAbstractSocket::Unbuffered; // QUdpSocket + QIODevice::open(openMode); d->state = HostLookupState; emit stateChanged(d->state); @@ -1431,10 +1435,12 @@ qint64 QAbstractSocket::bytesAvailable() const { Q_D(const QAbstractSocket); qint64 available = QIODevice::bytesAvailable(); - if (d->isBuffered) - available += (qint64) d->readBuffer.size(); - else if (d->socketEngine && d->socketEngine->isValid()) + + available += (qint64) d->readBuffer.size(); + + if (!d->isBuffered && d->socketEngine && d->socketEngine->isValid()) available += d->socketEngine->bytesAvailable(); + #if defined(QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocket::bytesAvailable() == %llu", available); #endif @@ -2067,42 +2073,51 @@ bool QAbstractSocket::flush() qint64 QAbstractSocket::readData(char *data, qint64 maxSize) { Q_D(QAbstractSocket); - if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid()) - d->socketEngine->setReadNotificationEnabled(true); - - if (!d->isBuffered) { - if (!d->socketEngine) - return -1; // no socket engine is probably EOF - qint64 readBytes = d->socketEngine->read(data, maxSize); - if (readBytes < 0) { - d->socketError = d->socketEngine->error(); - setErrorString(d->socketEngine->errorString()); - } - if (!d->socketEngine->isReadNotificationEnabled()) - d->socketEngine->setReadNotificationEnabled(true); -#if defined (QABSTRACTSOCKET_DEBUG) - qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld", - data, qt_prettyDebug(data, 32, readBytes).data(), maxSize, - readBytes); -#endif - return readBytes; - } - if (d->readBuffer.isEmpty()) + // This is for a buffered QTcpSocket + if (d->isBuffered && d->readBuffer.isEmpty()) // if we're still connected, return 0 indicating there may be more data in the future // if we're not connected, return -1 indicating EOF return d->state == QAbstractSocket::ConnectedState ? qint64(0) : qint64(-1); - // If readFromSocket() read data, copy it to its destination. - if (maxSize == 1) { + // short cut for a char read if we have something in the buffer + if (maxSize == 1 && !d->readBuffer.isEmpty()) { *data = d->readBuffer.getChar(); #if defined (QABSTRACTSOCKET_DEBUG) - qDebug("QAbstractSocket::readData(%p '%c (0x%.2x)', 1) == 1", + qDebug("QAbstractSocket::readData(%p '%c (0x%.2x)', 1) == 1 [char buffer]", data, isprint(int(uchar(*data))) ? *data : '?', *data); #endif + if (d->readBuffer.isEmpty() && d->socketEngine) + d->socketEngine->setReadNotificationEnabled(true); return 1; } + // Special case for an Unbuffered QTcpSocket + // Re-filling the buffer. + if (d->socketType == TcpSocket + && !d->isBuffered + && d->readBuffer.size() < maxSize + && d->readBufferMaxSize > 0 + && maxSize < d->readBufferMaxSize + && d->socketEngine) { + qDebug() << "QAbstractSocket::readData filling buffer"; + // Our buffer is empty and a read() was requested for a byte amount that is smaller + // than the readBufferMaxSize. This means that we should fill our buffer since we want + // such small reads come from the buffer and not always go to the costly socket engine read() + qint64 bytesToRead = d->socketEngine->bytesAvailable(); + if (bytesToRead > 0) { + char *ptr = d->readBuffer.reserve(bytesToRead); + qint64 readBytes = d->socketEngine->read(ptr, bytesToRead); + if (readBytes == -2) { + // No bytes currently available for reading. + d->readBuffer.chop(bytesToRead); + } else { + d->readBuffer.chop(int(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes))); + } + } + } + + // First try to satisfy the read from the buffer qint64 bytesToRead = qMin(qint64(d->readBuffer.size()), maxSize); qint64 readSoFar = 0; while (readSoFar < bytesToRead) { @@ -2114,8 +2129,50 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize) d->readBuffer.free(bytesToReadFromThisBlock); } + if (d->socketEngine && !d->socketEngine->isReadNotificationEnabled() && d->socketEngine->isValid()) + d->socketEngine->setReadNotificationEnabled(true); + + if (readSoFar > 0) { + // we read some data from buffer. + // Just return, readyRead will be emitted again +#if defined (QABSTRACTSOCKET_DEBUG) + qDebug("QAbstractSocket::readData(%p '%c (0x%.2x)', %lli) == %lli [buffer]", + data, isprint(int(uchar(*data))) ? *data : '?', *data, maxSize, readSoFar); +#endif + + if (d->readBuffer.isEmpty() && d->socketEngine) + d->socketEngine->setReadNotificationEnabled(true); + return readSoFar; + } + + // This code path is for Unbuffered QTcpSocket or for connected UDP + + if (!d->isBuffered) { + if (!d->socketEngine) + return -1; // no socket engine is probably EOF + qint64 readBytes = d->socketEngine->read(data, maxSize); + if (readBytes == -2) { + // -2 from the engine means no bytes available (EAGAIN) so read more later + return 0; + } else if (readBytes < 0) { + d->socketError = d->socketEngine->error(); + setErrorString(d->socketEngine->errorString()); + } else if (!d->socketEngine->isReadNotificationEnabled()) { + // Only do this when there was no error + d->socketEngine->setReadNotificationEnabled(true); + } + +#if defined (QABSTRACTSOCKET_DEBUG) + qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld [engine]", + data, qt_prettyDebug(data, 32, readBytes).data(), maxSize, + readBytes); +#endif + return readBytes; + } + + #if defined (QABSTRACTSOCKET_DEBUG) - qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld", + qDebug("QAbstractSocket::readData(%p \"%s\", %lli) == %lld [unreachable]", data, qt_prettyDebug(data, qMin(32, readSoFar), readSoFar).data(), maxSize, readSoFar); #endif @@ -2140,7 +2197,23 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size) return -1; } - if (!d->isBuffered) { + if (!d->isBuffered && d->socketType == TcpSocket && d->writeBuffer.isEmpty()) { + // This code is for the new Unbuffered QTcpSocket use case + qint64 written = d->socketEngine->write(data, size); + if (written < 0) { + d->socketError = d->socketEngine->error(); + setErrorString(d->socketEngine->errorString()); + return written; + } else if (written < size) { + // Buffer what was not written yet + char *ptr = d->writeBuffer.reserve(size - written); + memcpy(ptr, data + written, size - written); + if (d->socketEngine) + d->socketEngine->setWriteNotificationEnabled(true); + } + return size; // size=actually written + what has been buffered + } else if (!d->isBuffered && d->socketType != TcpSocket) { + // This is for a QUdpSocket that was connect()ed qint64 written = d->socketEngine->write(data, size); if (written < 0) { d->socketError = d->socketEngine->error(); @@ -2159,6 +2232,12 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size) return written; } + // This is the code path for normal buffered QTcpSocket or + // unbuffered QTcpSocket when there was already something in the + // write buffer and therefore we could not do a direct engine write. + // We just write to our write buffer and enable the write notifier + // The write notifier then flush()es the buffer. + char *ptr = d->writeBuffer.reserve(size); if (size == 1) *ptr = *data; -- cgit v0.12 From 66a251c63191ae4dde4c9c3d6b2fcf75708c645a Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:19:26 +0200 Subject: QNAM Zerocopy: HTTP implementation part Reviewed-by: Peter Hartmann Reviewed-by: Jeremy Katz Reviewed-by: Aleksandar Sasha Babic --- src/network/access/qhttpnetworkconnection.cpp | 13 ++- .../access/qhttpnetworkconnectionchannel.cpp | 130 ++++++++++++++++----- .../access/qhttpnetworkconnectionchannel_p.h | 11 +- src/network/access/qhttpnetworkreply.cpp | 113 ++++++++++++++---- src/network/access/qhttpnetworkreply_p.h | 15 ++- src/network/access/qhttpnetworkrequest.cpp | 11 ++ src/network/access/qhttpnetworkrequest_p.h | 4 + 7 files changed, 230 insertions(+), 67 deletions(-) diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 9e2b85e..400bb12 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -117,6 +117,7 @@ void QHttpNetworkConnectionPrivate::init() { for (int i = 0; i < channelCount; i++) { channels[i].setConnection(this->q_func()); + channels[i].ssl = encrypt; channels[i].init(); } } @@ -530,33 +531,35 @@ void QHttpNetworkConnectionPrivate::fillPipeline(QAbstractSocket *socket) || channels[i].state == QHttpNetworkConnectionChannel::ReadingState)) return; - - //qDebug() << "QHttpNetworkConnectionPrivate::fillPipeline processing highPriorityQueue, size=" << highPriorityQueue.size() << " alreadyPipelined=" << channels[i].alreadyPipelinedRequests.length(); int lengthBefore; while (!highPriorityQueue.isEmpty()) { lengthBefore = channels[i].alreadyPipelinedRequests.length(); fillPipeline(highPriorityQueue, channels[i]); - if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) + if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) { + channels[i].pipelineFlush(); return; + } if (lengthBefore == channels[i].alreadyPipelinedRequests.length()) break; // did not process anything, now do the low prio queue } - //qDebug() << "QHttpNetworkConnectionPrivate::fillPipeline processing lowPriorityQueue, size=" << lowPriorityQueue.size() << " alreadyPipelined=" << channels[i].alreadyPipelinedRequests.length(); while (!lowPriorityQueue.isEmpty()) { lengthBefore = channels[i].alreadyPipelinedRequests.length(); fillPipeline(lowPriorityQueue, channels[i]); - if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) + if (channels[i].alreadyPipelinedRequests.length() >= defaultPipelineLength) { + channels[i].pipelineFlush(); return; + } if (lengthBefore == channels[i].alreadyPipelinedRequests.length()) break; // did not process anything } + channels[i].pipelineFlush(); } // returns true when the processing of a queue has been done diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 71a4de3..c0b5928 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -60,6 +60,7 @@ QT_BEGIN_NAMESPACE QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel() : socket(0) + , ssl(false) , state(IdleState) , reply(0) , written(0) @@ -90,11 +91,8 @@ void QHttpNetworkConnectionChannel::init() #else socket = new QTcpSocket; #endif - - // limit the socket read buffer size. we will read everything into - // the QHttpNetworkReply anyway, so let's grow only that and not - // here and there. - socket->setReadBufferSize(64*1024); + // Set by QNAM anyway, but let's be safe here + socket->setProxy(QNetworkProxy::NoProxy); QObject::connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_bytesWritten(qint64)), @@ -164,11 +162,12 @@ bool QHttpNetworkConnectionChannel::sendRequest() written = 0; // excluding the header bytesTotal = 0; - reply->d_func()->clear(); - reply->d_func()->connection = connection; - reply->d_func()->connectionChannel = this; - reply->d_func()->autoDecompress = request.d->autoDecompress; - reply->d_func()->pipeliningUsed = false; + QHttpNetworkReplyPrivate *replyPrivate = reply->d_func(); + replyPrivate->clear(); + replyPrivate->connection = connection; + replyPrivate->connectionChannel = this; + replyPrivate->autoDecompress = request.d->autoDecompress; + replyPrivate->pipeliningUsed = false; pendingEncrypt = false; // if the url contains authentication parameters, use the new ones @@ -328,7 +327,6 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() return; } - qint64 bytes = 0; QAbstractSocket::SocketState socketState = socket->state(); // connection might be closed to signal the end of data @@ -349,12 +347,14 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() } // read loop for the response - while (socket->bytesAvailable()) { + qint64 bytes = 0; + qint64 lastBytes = bytes; + do { + lastBytes = bytes; + QHttpNetworkReplyPrivate::ReplyState state = reply->d_func()->state; switch (state) { case QHttpNetworkReplyPrivate::NothingDoneState: { - // only eat whitespace on the first call - eatWhitespace(); state = reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState; // fallthrough } @@ -378,6 +378,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() return; } bytes += headerBytes; + // If headers were parsed successfully now it is the ReadingDataState if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState) { if (replyPrivate->isGzipped() && replyPrivate->autoDecompress) { // remove the Content-Length from header @@ -392,6 +393,10 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() } if (replyPrivate->shouldEmitSignals()) emit reply->headerChanged(); + // After headerChanged had been emitted + // we can suddenly have a replyPrivate->userProvidedDownloadBuffer + // this is handled in the ReadingDataState however + if (!replyPrivate->expectContent()) { replyPrivate->state = QHttpNetworkReplyPrivate::AllDoneState; allDone(); @@ -412,12 +417,24 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() return; } - if (!replyPrivate->isChunked() && !replyPrivate->autoDecompress - && replyPrivate->bodyLength > 0) { - // bulk files like images should fulfill these properties and - // we can therefore save on memory copying - bytes = replyPrivate->readBodyFast(socket, &replyPrivate->responseData); - replyPrivate->totalProgress += bytes; + if (replyPrivate->userProvidedDownloadBuffer) { + // the user provided a direct buffer where we should put all our data in. + // this only works when we can tell the user the content length and he/she can allocate + // the buffer in that size. + // note that this call will read only from the still buffered data + qint64 haveRead = replyPrivate->readBodyVeryFast(socket, replyPrivate->userProvidedDownloadBuffer + replyPrivate->totalProgress); + bytes += haveRead; + replyPrivate->totalProgress += haveRead; + + // the user will get notified of it via progress signal + emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); + } else if (!replyPrivate->isChunked() && !replyPrivate->autoDecompress + && replyPrivate->bodyLength > 0) { + // bulk files like images should fulfill these properties and + // we can therefore save on memory copying + qint64 haveRead = replyPrivate->readBodyFast(socket, &replyPrivate->responseData); + bytes += haveRead; + replyPrivate->totalProgress += haveRead; if (replyPrivate->shouldEmitSignals()) { emit reply->readyRead(); emit reply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength); @@ -428,8 +445,9 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() // use the traditional slower reading (for compressed encoding, chunked encoding, // no content-length etc) QByteDataBuffer byteDatas; - bytes = replyPrivate->readBody(socket, &byteDatas); - if (bytes) { + qint64 haveRead = replyPrivate->readBody(socket, &byteDatas); + if (haveRead) { + bytes += haveRead; if (replyPrivate->autoDecompress) replyPrivate->appendCompressedReplyData(byteDatas); else @@ -463,7 +481,7 @@ void QHttpNetworkConnectionChannel::_q_receiveReply() default: break; } - } + } while (bytes != lastBytes && reply); } // called when unexpectedly reading a -1 or when data is expected but socket is closed @@ -506,7 +524,7 @@ bool QHttpNetworkConnectionChannel::ensureConnection() if (socketState != QAbstractSocket::ConnectedState) { // connect to the host if not already connected. state = QHttpNetworkConnectionChannel::ConnectingState; - pendingEncrypt = connection->d_func()->encrypt; + pendingEncrypt = ssl; // reset state pipeliningSupported = PipeliningSupportUnknown; @@ -529,23 +547,43 @@ bool QHttpNetworkConnectionChannel::ensureConnection() #ifndef QT_NO_NETWORKPROXY // HTTPS always use transparent proxy. - if (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy && !connection->d_func()->encrypt) { + if (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy && !ssl) { connectHost = connection->d_func()->networkProxy.hostName(); connectPort = connection->d_func()->networkProxy.port(); } #endif - if (connection->d_func()->encrypt) { + if (ssl) { #ifndef QT_NO_OPENSSL QSslSocket *sslSocket = qobject_cast(socket); sslSocket->connectToHostEncrypted(connectHost, connectPort); if (ignoreAllSslErrors) sslSocket->ignoreSslErrors(); sslSocket->ignoreSslErrors(ignoreSslErrorsList); + + // limit the socket read buffer size. we will read everything into + // the QHttpNetworkReply anyway, so let's grow only that and not + // here and there. + socket->setReadBufferSize(64*1024); #else connection->d_func()->emitReplyError(socket, reply, QNetworkReply::ProtocolUnknownError); #endif } else { - socket->connectToHost(connectHost, connectPort); + // In case of no proxy we can use the Unbuffered QTcpSocket + if (connection->d_func()->networkProxy.type() == QNetworkProxy::NoProxy + && connection->cacheProxy().type() == QNetworkProxy::NoProxy + && connection->transparentProxy().type() == QNetworkProxy::NoProxy) { + socket->connectToHost(connectHost, connectPort, QIODevice::ReadWrite | QIODevice::Unbuffered); + // For an Unbuffered QTcpSocket, the read buffer size has a special meaning. + socket->setReadBufferSize(1*1024); + + } else { + socket->connectToHost(connectHost, connectPort); + + // limit the socket read buffer size. we will read everything into + // the QHttpNetworkReply anyway, so let's grow only that and not + // here and there. + socket->setReadBufferSize(64*1024); + } } return false; } @@ -593,6 +631,7 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete) void QHttpNetworkConnectionChannel::allDone() { + eatWhitespace(); // FIXME HACK! #ifndef QT_NO_COMPRESS // expand the whole data. if (reply->d_func()->expectContent() && reply->d_func()->autoDecompress && !reply->d_func()->streamEnd) @@ -789,7 +828,7 @@ bool QHttpNetworkConnectionChannel::resetUploadData() } -void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair) +void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair) { // this is only called for simple GET @@ -802,16 +841,32 @@ void QHttpNetworkConnectionChannel::pipelineInto(HttpMessagePair &pair) reply->d_func()->pipeliningUsed = true; #ifndef QT_NO_NETWORKPROXY - QByteArray header = QHttpNetworkRequestPrivate::header(request, - (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy)); + pipeline.append(QHttpNetworkRequestPrivate::header(request, + (connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy))); #else - QByteArray header = QHttpNetworkRequestPrivate::header(request, false); + pipeline.append(QHttpNetworkRequestPrivate::header(request, false)); #endif - socket->write(header); alreadyPipelinedRequests.append(pair); + + // pipelineFlush() needs to be called at some point afterwards } +void QHttpNetworkConnectionChannel::pipelineFlush() +{ + if (pipeline.isEmpty()) + return; + + // The goal of this is so that we have everything in one TCP packet. + // For the Unbuffered QTcpSocket this is manually needed, the buffered + // QTcpSocket does it automatically. + // Also, sometimes the OS does it for us (Nagle's algorithm) but that + // happens only sometimes. + socket->write(pipeline); + pipeline.clear(); +} + + void QHttpNetworkConnectionChannel::closeAndResendCurrentRequest() { requeueCurrentlyPipelinedRequests(); @@ -844,6 +899,17 @@ bool QHttpNetworkConnectionChannel::isSocketReading() const //private slots void QHttpNetworkConnectionChannel::_q_readyRead() { + // We got a readyRead but no bytes are available.. + // This happens for the Unbuffered QTcpSocket + if (socket->bytesAvailable() == 0) { + char c; + qint64 ret = socket->peek(&c, 1); + if (ret < 0) { + socket->disconnectFromHost(); + return; + } + } + if (isSocketWaiting() || isSocketReading()) { state = QHttpNetworkConnectionChannel::ReadingState; if (reply) diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index 41a896d..e384e9d 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -99,6 +99,7 @@ public: BusyState = (ConnectingState|WritingState|WaitingState|ReadingState|Wait4AuthState) }; QAbstractSocket *socket; + bool ssl; ChannelState state; QHttpNetworkRequest request; // current request QHttpNetworkReply *reply; // current reply for this request @@ -125,7 +126,11 @@ public: }; PipeliningSupport pipeliningSupported; QList alreadyPipelinedRequests; - + QByteArray pipeline; // temporary buffer that gets sent to socket in pipelineFlush + void pipelineInto(HttpMessagePair &pair); + void pipelineFlush(); + void requeueCurrentlyPipelinedRequests(); + void detectPipeliningSupport(); QHttpNetworkConnectionChannel(); @@ -145,10 +150,6 @@ public: bool resetUploadData(); // return true if resetting worked or there is no upload data - void pipelineInto(HttpMessagePair &pair); - void requeueCurrentlyPipelinedRequests(); - void detectPipeliningSupport(); - void handleUnexpectedEOF(); void closeAndResendCurrentRequest(); diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index 108ba8a..1c55482 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -119,6 +119,7 @@ void QHttpNetworkReply::setRequest(const QHttpNetworkRequest &request) { Q_D(QHttpNetworkReply); d->request = request; + d->ssl = request.isSsl(); } int QHttpNetworkReply::statusCode() const @@ -195,6 +196,25 @@ void QHttpNetworkReply::setDownstreamLimited(bool dsl) d->connection->d_func()->readMoreLater(this); } +bool QHttpNetworkReply::supportsUserProvidedDownloadBuffer() +{ + Q_D(QHttpNetworkReply); + return (!d->isChunked() && !d->autoDecompress && d->bodyLength > 0); +} + +void QHttpNetworkReply::setUserProvidedDownloadBuffer(char* b) +{ + Q_D(QHttpNetworkReply); + if (supportsUserProvidedDownloadBuffer()) + d->userProvidedDownloadBuffer = b; +} + +char* QHttpNetworkReply::userProvidedDownloadBuffer() +{ + Q_D(QHttpNetworkReply); + return d->userProvidedDownloadBuffer; +} + bool QHttpNetworkReply::isFinished() const { return d_func()->state == QHttpNetworkReplyPrivate::AllDoneState; @@ -207,7 +227,10 @@ bool QHttpNetworkReply::isPipeliningUsed() const QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl) - : QHttpNetworkHeaderPrivate(newUrl), state(NothingDoneState), statusCode(100), + : QHttpNetworkHeaderPrivate(newUrl) + , state(NothingDoneState) + , ssl(false) + , statusCode(100), majorVersion(0), minorVersion(0), bodyLength(0), contentRead(0), totalProgress(0), chunkedTransferEncoding(false), connectionCloseEnabled(true), @@ -215,6 +238,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl) currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false), autoDecompress(false), responseData(), requestIsPrepared(false) ,pipeliningUsed(false), downstreamLimited(false) + ,userProvidedDownloadBuffer(0) { } @@ -448,6 +472,8 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket) return -1; // unexpected EOF else if (haveRead == 0) break; // read more later + else if (haveRead == 1 && bytes == 0 && (c == 11 || c == '\n' || c == '\r' || c == ' ' || c == 31)) + continue; // Ignore all whitespace that was trailing froma previous request on that socket bytes++; @@ -623,12 +649,32 @@ bool QHttpNetworkReplyPrivate::isConnectionCloseEnabled() // note this function can only be used for non-chunked, non-compressed with // known content length +qint64 QHttpNetworkReplyPrivate::readBodyVeryFast(QAbstractSocket *socket, char *b) +{ + // This first read is to flush the buffer inside the socket + qint64 haveRead = 0; + haveRead = socket->read(b, bodyLength - contentRead); + if (haveRead == -1) { + return 0; // ### error checking here; + } + contentRead += haveRead; + + if (contentRead == bodyLength) { + state = AllDoneState; + } + + return haveRead; +} + +// note this function can only be used for non-chunked, non-compressed with +// known content length qint64 QHttpNetworkReplyPrivate::readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb) { + qint64 toBeRead = qMin(socket->bytesAvailable(), bodyLength - contentRead); QByteArray bd; bd.resize(toBeRead); - qint64 haveRead = socket->read(bd.data(), bd.size()); + qint64 haveRead = socket->read(bd.data(), toBeRead); if (haveRead == -1) { bd.clear(); return 0; // ### error checking here; @@ -650,29 +696,34 @@ qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QByteDataBuff { qint64 bytes = 0; if (isChunked()) { - bytes += readReplyBodyChunked(socket, out); // chunked transfer encoding (rfc 2616, sec 3.6) - } else if (bodyLength > 0) { // we have a Content-Length + // chunked transfer encoding (rfc 2616, sec 3.6) + bytes += readReplyBodyChunked(socket, out); + } else if (bodyLength > 0) { + // we have a Content-Length bytes += readReplyBodyRaw(socket, out, bodyLength - contentRead); if (contentRead + bytes == bodyLength) state = AllDoneState; } else { + // no content length. just read what's possible bytes += readReplyBodyRaw(socket, out, socket->bytesAvailable()); } contentRead += bytes; return bytes; } -qint64 QHttpNetworkReplyPrivate::readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size) +qint64 QHttpNetworkReplyPrivate::readReplyBodyRaw(QAbstractSocket *socket, QByteDataBuffer *out, qint64 size) { + // FIXME get rid of this function and just use readBodyFast and give it socket->bytesAvailable() qint64 bytes = 0; - Q_ASSERT(in); + Q_ASSERT(socket); Q_ASSERT(out); - int toBeRead = qMin(128*1024, qMin(size, in->bytesAvailable())); + int toBeRead = qMin(128*1024, qMin(size, socket->bytesAvailable())); + while (toBeRead > 0) { QByteArray byteData; byteData.resize(toBeRead); - qint64 haveRead = in->read(byteData.data(), byteData.size()); + qint64 haveRead = socket->read(byteData.data(), byteData.size()); if (haveRead <= 0) { // ### error checking here byteData.clear(); @@ -684,25 +735,35 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyRaw(QIODevice *in, QByteDataBuffer bytes += haveRead; size -= haveRead; - toBeRead = qMin(128*1024, qMin(size, in->bytesAvailable())); + toBeRead = qMin(128*1024, qMin(size, socket->bytesAvailable())); } return bytes; } -qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out) +qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QAbstractSocket *socket, QByteDataBuffer *out) { qint64 bytes = 0; - while (in->bytesAvailable()) { // while we can read from input - // if we are done with the current chunk, get the size of the new chunk + while (socket->bytesAvailable()) { if (currentChunkRead >= currentChunkSize) { + // For the first chunk and when we're done with a chunk currentChunkSize = 0; currentChunkRead = 0; if (bytes) { + // After a chunk char crlf[2]; - bytes += in->read(crlf, 2); // read the "\r\n" after the chunk + // read the "\r\n" after the chunk + qint64 haveRead = socket->read(crlf, 2); + // FIXME: This code is slightly broken and not optimal. What if the 2 bytes are not available yet?! + // For nice reasons (the toLong in getChunkSize accepting \n at the beginning + // it right now still works, but we should definitely fix this. + + if (haveRead != 2) + return bytes; // FIXME + bytes += haveRead; } - bytes += getChunkSize(in, ¤tChunkSize); + // Note that chunk size gets stored in currentChunkSize, what is returned is the bytes read + bytes += getChunkSize(socket, ¤tChunkSize); if (currentChunkSize == -1) break; } @@ -712,8 +773,8 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QIODevice *in, QByteDataBu break; } - // otherwise, try to read what is missing for this chunk - qint64 haveRead = readReplyBodyRaw (in, out, currentChunkSize - currentChunkRead); + // otherwise, try to begin reading this chunk / to read what is missing for this chunk + qint64 haveRead = readReplyBodyRaw (socket, out, currentChunkSize - currentChunkRead); currentChunkRead += haveRead; bytes += haveRead; @@ -723,22 +784,25 @@ qint64 QHttpNetworkReplyPrivate::readReplyBodyChunked(QIODevice *in, QByteDataBu return bytes; } -qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize) +qint64 QHttpNetworkReplyPrivate::getChunkSize(QAbstractSocket *socket, qint64 *chunkSize) { qint64 bytes = 0; char crlf[2]; *chunkSize = -1; - int bytesAvailable = in->bytesAvailable(); + + int bytesAvailable = socket->bytesAvailable(); + // FIXME rewrite to permanent loop without bytesAvailable while (bytesAvailable > bytes) { - qint64 sniffedBytes = in->peek(crlf, 2); + qint64 sniffedBytes = socket->peek(crlf, 2); int fragmentSize = fragment.size(); + // check the next two bytes for a "\r\n", skip blank lines if ((fragmentSize && sniffedBytes == 2 && crlf[0] == '\r' && crlf[1] == '\n') ||(fragmentSize > 1 && fragment.endsWith('\r') && crlf[0] == '\n')) { - bytes += in->read(crlf, 1); // read the \r or \n + bytes += socket->read(crlf, 1); // read the \r or \n if (crlf[0] == '\r') - bytes += in->read(crlf, 1); // read the \n + bytes += socket->read(crlf, 1); // read the \n bool ok = false; // ignore the chunk-extension fragment = fragment.mid(0, fragment.indexOf(';')).trimmed(); @@ -748,10 +812,15 @@ qint64 QHttpNetworkReplyPrivate::getChunkSize(QIODevice *in, qint64 *chunkSize) } else { // read the fragment to the buffer char c = 0; - bytes += in->read(&c, 1); + qint64 haveRead = socket->read(&c, 1); + if (haveRead < 0) { + return -1; // FIXME + } + bytes += haveRead; fragment.append(c); } } + return bytes; } diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 4011c78..02ce248 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -128,6 +128,10 @@ public: QByteArray readAny(); void setDownstreamLimited(bool t); + bool supportsUserProvidedDownloadBuffer(); + void setUserProvidedDownloadBuffer(char*); + char* userProvidedDownloadBuffer(); + bool isFinished() const; bool isPipeliningUsed() const; @@ -147,6 +151,7 @@ Q_SIGNALS: void finished(); void finishedWithError(QNetworkReply::NetworkError errorCode, const QString &detail = QString()); void headerChanged(); + // FIXME we need to change this to qint64! void dataReadProgress(int done, int total); void dataSendProgress(qint64 done, qint64 total); @@ -168,15 +173,16 @@ public: qint64 readHeader(QAbstractSocket *socket); void parseHeader(const QByteArray &header); qint64 readBody(QAbstractSocket *socket, QByteDataBuffer *out); + qint64 readBodyVeryFast(QAbstractSocket *socket, char *b); qint64 readBodyFast(QAbstractSocket *socket, QByteDataBuffer *rb); bool findChallenge(bool forProxy, QByteArray &challenge) const; QAuthenticatorPrivate::Method authenticationMethod(bool isProxy) const; void clear(); void clearHttpLayerInformation(); - qint64 readReplyBodyRaw(QIODevice *in, QByteDataBuffer *out, qint64 size); - qint64 readReplyBodyChunked(QIODevice *in, QByteDataBuffer *out); - qint64 getChunkSize(QIODevice *in, qint64 *chunkSize); + qint64 readReplyBodyRaw(QAbstractSocket *in, QByteDataBuffer *out, qint64 size); + qint64 readReplyBodyChunked(QAbstractSocket *in, QByteDataBuffer *out); + qint64 getChunkSize(QAbstractSocket *in, qint64 *chunkSize); void appendUncompressedReplyData(QByteArray &qba); void appendUncompressedReplyData(QByteDataBuffer &data); @@ -205,6 +211,7 @@ public: } state; QHttpNetworkRequest request; + bool ssl; int statusCode; int majorVersion; int minorVersion; @@ -234,6 +241,8 @@ public: bool pipeliningUsed; bool downstreamLimited; + + char* userProvidedDownloadBuffer; }; diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index 639025e..d2f3212 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -63,6 +63,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest pipeliningAllowed = other.pipeliningAllowed; customVerb = other.customVerb; withCredentials = other.withCredentials; + ssl = other.ssl; } QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate() @@ -73,6 +74,7 @@ bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &ot { return QHttpNetworkHeaderPrivate::operator==(other) && (operation == other.operation) + && (ssl == other.ssl) && (uploadByteDevice == other.uploadByteDevice); } @@ -199,6 +201,15 @@ void QHttpNetworkRequest::setUrl(const QUrl &url) d->url = url; } +bool QHttpNetworkRequest::isSsl() const +{ + return d->ssl; +} +void QHttpNetworkRequest::setSsl(bool s) +{ + d->ssl = s; +} + qint64 QHttpNetworkRequest::contentLength() const { return d->contentLength(); diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h index 15cab73..123babc 100644 --- a/src/network/access/qhttpnetworkrequest_p.h +++ b/src/network/access/qhttpnetworkrequest_p.h @@ -116,6 +116,9 @@ public: bool withCredentials() const; void setWithCredentials(bool b); + bool isSsl() const; + void setSsl(bool); + void setUploadByteDevice(QNonContiguousByteDevice *bd); QNonContiguousByteDevice* uploadByteDevice() const; @@ -146,6 +149,7 @@ public: bool autoDecompress; bool pipeliningAllowed; bool withCredentials; + bool ssl; }; -- cgit v0.12 From 26af575213763c8202f1a142f42257d473076529 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:20:14 +0200 Subject: QNAM Zerocopy: QNAM implementation part Reviewed-by: Peter Hartmann Reviewed-by: Jeremy Katz Reviewed-by: Aleksandar Sasha Babic --- src/network/access/qnetworkaccessbackend.cpp | 11 ++++ src/network/access/qnetworkaccessbackend_p.h | 4 ++ src/network/access/qnetworkaccesshttpbackend.cpp | 33 +++++++++- src/network/access/qnetworkaccesshttpbackend_p.h | 1 + src/network/access/qnetworkreplyimpl.cpp | 80 ++++++++++++++++++++++++ src/network/access/qnetworkreplyimpl_p.h | 10 +++ 6 files changed, 138 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp index 60f7dc6..45495f7 100644 --- a/src/network/access/qnetworkaccessbackend.cpp +++ b/src/network/access/qnetworkaccessbackend.cpp @@ -252,6 +252,17 @@ void QNetworkAccessBackend::writeDownstreamData(QIODevice *data) reply->appendDownstreamData(data); } +// not actually appending data, it was already written to the user buffer +void QNetworkAccessBackend::writeDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal) +{ + reply->appendDownstreamDataDownloadBuffer(bytesReceived, bytesTotal); +} + +char* QNetworkAccessBackend::getDownloadBuffer(qint64 size) +{ + return reply->getDownloadBuffer(size); +} + QVariant QNetworkAccessBackend::header(QNetworkRequest::KnownHeaders header) const { return reply->q_func()->header(header); diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h index 4fe6de6..9f8a01f 100644 --- a/src/network/access/qnetworkaccessbackend_p.h +++ b/src/network/access/qnetworkaccessbackend_p.h @@ -177,6 +177,10 @@ protected: qint64 nextDownstreamBlockSize() const; void writeDownstreamData(QByteDataBuffer &list); + // not actually appending data, it was already written to the user buffer + void writeDownstreamDataDownloadBuffer(qint64, qint64); + char* getDownloadBuffer(qint64); + public slots: // for task 251801, needs to be a slot to be called asynchronously void writeDownstreamData(QIODevice *data); diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp index f617244..8b9a99f 100644 --- a/src/network/access/qnetworkaccesshttpbackend.cpp +++ b/src/network/access/qnetworkaccesshttpbackend.cpp @@ -542,6 +542,9 @@ void QNetworkAccessHttpBackend::postRequest() break; // can't happen } + bool encrypt = (url().scheme().toLower() == QLatin1String("https")); + httpRequest.setSsl(encrypt); + httpRequest.setUrl(url()); QList headers = request().rawHeaderList(); @@ -595,7 +598,6 @@ void QNetworkAccessHttpBackend::postRequest() httpReply->ignoreSslErrors(pendingIgnoreSslErrorsList); #endif - connect(httpReply, SIGNAL(readyRead()), SLOT(replyReadyRead())); connect(httpReply, SIGNAL(finished()), SLOT(replyFinished())); connect(httpReply, SIGNAL(finishedWithError(QNetworkReply::NetworkError,QString)), SLOT(httpError(QNetworkReply::NetworkError,QString))); @@ -859,9 +861,33 @@ void QNetworkAccessHttpBackend::replyHeaderChanged() if (!isCachingEnabled()) setCachingEnabled(true); } + + // Check if a download buffer is supported from the HTTP reply + char *buf = 0; + if (httpReply->supportsUserProvidedDownloadBuffer()) { + // Check if a download buffer is supported by the user + buf = getDownloadBuffer(httpReply->contentLength()); + if (buf) { + httpReply->setUserProvidedDownloadBuffer(buf); + // If there is a download buffer we react on the progress signal + connect(httpReply, SIGNAL(dataReadProgress(int,int)), SLOT(replyDownloadProgressSlot(int,int))); + } + } + + // If there is no buffer, we react on the readyRead signal + if (!buf) { + connect(httpReply, SIGNAL(readyRead()), SLOT(replyReadyRead())); + } + metaDataChanged(); } +void QNetworkAccessHttpBackend::replyDownloadProgressSlot(int received, int total) +{ + // we can be sure here that there is a download buffer + writeDownstreamDataDownloadBuffer(received, total); +} + void QNetworkAccessHttpBackend::httpAuthenticationRequired(const QHttpNetworkRequest &, QAuthenticator *auth) { @@ -1169,6 +1195,11 @@ bool QNetworkAccessHttpBackend::canResume() const return false; } + // If we're using a download buffer then we don't support resuming/migration + // right now. Too much trouble. + if (httpReply->userProvidedDownloadBuffer()) + return false; + return true; } diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h index c4c88ae..fb12781 100644 --- a/src/network/access/qnetworkaccesshttpbackend_p.h +++ b/src/network/access/qnetworkaccesshttpbackend_p.h @@ -104,6 +104,7 @@ private slots: void replyReadyRead(); void replyFinished(); void replyHeaderChanged(); + void replyDownloadProgressSlot(int,int); void httpAuthenticationRequired(const QHttpNetworkRequest &request, QAuthenticator *auth); void httpCacheCredentials(const QHttpNetworkRequest &request, QAuthenticator *auth); void httpError(QNetworkReply::NetworkError error, const QString &errorString); diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index 3798ac2..c8808af 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -49,11 +49,15 @@ #include "QtNetwork/qnetworksession.h" #include "qnetworkaccesshttpbackend_p.h" #include "qnetworkaccessmanager_p.h" +#include #include QT_BEGIN_NAMESPACE +typedef QSharedPointer > QVarLengthArraySharedPointer; +Q_DECLARE_METATYPE(QVarLengthArraySharedPointer) + inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() : backend(0), outgoingData(0), outgoingDataBuffer(0), copyDevice(0), @@ -62,6 +66,8 @@ inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() bytesDownloaded(0), lastBytesDownloaded(-1), bytesUploaded(-1), preMigrationDownloaded(-1), httpStatusCode(0), state(Idle) + , downloadBuffer(0) + , downloadBufferPosition(0) { } @@ -125,6 +131,10 @@ void QNetworkReplyImplPrivate::_q_copyReadyRead() if (!copyDevice || !q->isOpen()) return; + // FIXME Optimize to use download buffer if it is a QBuffer. + // Needs to be done where sendCacheContents() (?) of HTTP is emitting + // metaDataChanged ? + forever { qint64 bytesToRead = nextDownstreamBlockSize(); if (bytesToRead == 0) @@ -590,6 +600,55 @@ void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data) qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented"); } +char* QNetworkReplyImplPrivate::getDownloadBuffer(qint64 size) +{ + Q_Q(QNetworkReplyImpl); + + // Check attribute() if allocating a buffer of that size can be allowed + if (!downloadBuffer) { + QVariant bufferAllocationPolicy = request.attribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute); + if (bufferAllocationPolicy.isValid() && bufferAllocationPolicy.toLongLong() >= size) { + downloadBufferArray = QSharedPointer >(new QVarLengthArray()); + downloadBufferArray->reserve(size); + + downloadBuffer = downloadBufferArray->data(); + + q->setAttribute(QNetworkRequest::DownloadBufferAttribute, qVariantFromValue > > (downloadBufferArray)); + } + } + + return downloadBuffer; +} + +void QNetworkReplyImplPrivate::appendDownstreamDataDownloadBuffer(qint64 bytesReceived, qint64 bytesTotal) +{ + Q_Q(QNetworkReplyImpl); + if (!q->isOpen()) + return; + + if (cacheEnabled && !cacheSaveDevice) + initCacheSaveDevice(); + + if (cacheSaveDevice && bytesReceived == bytesTotal) { +// if (lastBytesDownloaded == -1) +// lastBytesDownloaded = 0; +// cacheSaveDevice->write(downloadBuffer + lastBytesDownloaded, bytesReceived - lastBytesDownloaded); + + // Write everything in one go if we use a download buffer. might be more performant. + cacheSaveDevice->write(downloadBuffer, bytesTotal); + } + + bytesDownloaded = bytesReceived; + lastBytesDownloaded = bytesReceived; + + // Update the array so our user (e.g. QtWebKit) knows the real size + if (bytesReceived > 0) + downloadBufferArray->resize(bytesReceived); + + emit q->downloadProgress(bytesDownloaded, bytesTotal); + emit q->readyRead(); +} + void QNetworkReplyImplPrivate::finished() { Q_Q(QNetworkReplyImpl); @@ -784,6 +843,13 @@ bool QNetworkReplyImpl::canReadLine () const */ qint64 QNetworkReplyImpl::bytesAvailable() const { + // Special case for the "zero copy" download buffer + Q_D(const QNetworkReplyImpl); + if (d->downloadBuffer) { + qint64 maxAvail = d->downloadBufferArray->size() - d->downloadBufferPosition; + return QNetworkReply::bytesAvailable() + maxAvail; + } + return QNetworkReply::bytesAvailable() + d_func()->readBuffer.byteAmount(); } @@ -838,8 +904,22 @@ void QNetworkReplyImpl::ignoreSslErrorsImplementation(const QList &er qint64 QNetworkReplyImpl::readData(char *data, qint64 maxlen) { Q_D(QNetworkReplyImpl); + + // Special case code if we have the "zero copy" download buffer + if (d->downloadBuffer) { + qint64 maxAvail = qMin(d->downloadBufferArray->size() - d->downloadBufferPosition, maxlen); + if (maxAvail == 0) + return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0; + // FIXME what about "Aborted" state? + qMemCopy(data, d->downloadBuffer + d->downloadBufferPosition, maxAvail); + d->downloadBufferPosition += maxAvail; + return maxAvail; + } + + if (d->readBuffer.isEmpty()) return d->state == QNetworkReplyImplPrivate::Finished ? -1 : 0; + // FIXME what about "Aborted" state? d->backendNotify(QNetworkReplyImplPrivate::NotifyDownstreamReadyWrite); if (maxlen == 1) { diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index 38084bd..ab11ebe 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -62,6 +62,7 @@ #include "QtCore/qbuffer.h" #include "private/qringbuffer_p.h" #include "private/qbytedata_p.h" +#include QT_BEGIN_NAMESPACE @@ -163,6 +164,9 @@ public: void appendDownstreamData(QIODevice *data); void appendDownstreamData(const QByteArray &data); + char* getDownloadBuffer(qint64 size); + void appendDownstreamDataDownloadBuffer(qint64, qint64); + void finished(); void error(QNetworkReply::NetworkError code, const QString &errorString); void metaDataChanged(); @@ -191,6 +195,7 @@ public: QList proxyList; #endif + // Used for normal downloading. For "zero copy" the downloadBuffer is used QByteDataBuffer readBuffer; qint64 bytesDownloaded; qint64 lastBytesDownloaded; @@ -202,6 +207,11 @@ public: State state; + // only used when the "zero copy" style is used. Else readBuffer is used. + QSharedPointer< QVarLengthArray > downloadBufferArray; + char* downloadBuffer; + qint64 downloadBufferPosition; + Q_DECLARE_PUBLIC(QNetworkReplyImpl) }; -- cgit v0.12 From aa669904ff869a8b4f65a6e5cb87a8e85051a47e Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:21:16 +0200 Subject: tst_qhttpnetworkconnection: Pipelining auto test --- .../tst_qhttpnetworkconnection.cpp | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp index 89f608e..188ed29 100644 --- a/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp +++ b/tests/auto/qhttpnetworkconnection/tst_qhttpnetworkconnection.cpp @@ -110,6 +110,8 @@ private Q_SLOTS: void getEmptyWithPipelining(); + void getAndEverythingShouldBePipelined(); + void getAndThenDeleteObject(); void getAndThenDeleteObject_data(); }; @@ -1036,6 +1038,52 @@ void tst_QHttpNetworkConnection::getEmptyWithPipelining() qDeleteAll(replies); } +class GetAndEverythingShouldBePipelinedReceiver : public QObject +{ + Q_OBJECT +public: + int receivedCount; + int requestCount; + GetAndEverythingShouldBePipelinedReceiver(int rq) : receivedCount(0),requestCount(rq) { } +public Q_SLOTS: + void finishedSlot() { + QHttpNetworkReply *reply = (QHttpNetworkReply*) sender(); + receivedCount++; + + if (receivedCount == requestCount) + QTestEventLoop::instance().exitLoop(); + } +}; + +void tst_QHttpNetworkConnection::getAndEverythingShouldBePipelined() +{ + quint16 requestCount = 100; + // use 1 connection. + QHttpNetworkConnection connection(1, QtNetworkSettings::serverName()); + QUrl url("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); + QList requests; + QList replies; + + GetAndEverythingShouldBePipelinedReceiver receiver(requestCount); + + for (int i = 0; i < requestCount; i++) { + QHttpNetworkRequest *request = 0; + request = new QHttpNetworkRequest(url, QHttpNetworkRequest::Get); + request->setPipeliningAllowed(true); + requests.append(request); + QHttpNetworkReply *reply = connection.sendRequest(*request); + connect(reply, SIGNAL(finished()), &receiver, SLOT(finishedSlot())); + replies.append(reply); + } + QTestEventLoop::instance().enterLoop(40); + QVERIFY(!QTestEventLoop::instance().timeout()); + + qDeleteAll(requests); + qDeleteAll(replies); + +} + + void tst_QHttpNetworkConnection::getAndThenDeleteObject_data() { QTest::addColumn("replyFirst"); -- cgit v0.12 From 690598adbcb76b07dc791ab7ee5e3513ddd4096e Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:22:29 +0200 Subject: tst_qnetworkreply: Zerocopy auto test --- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 96 +++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp index 5af8034..bb91965 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -75,7 +75,8 @@ #include "../network-settings.h" - +typedef QSharedPointer > QVarLengthArraySharedPointer; +Q_DECLARE_METATYPE(QVarLengthArraySharedPointer) Q_DECLARE_METATYPE(QNetworkReply*) Q_DECLARE_METATYPE(QAuthenticator*) Q_DECLARE_METATYPE(QNetworkProxy) @@ -289,6 +290,13 @@ private Q_SLOTS: void symbianOpenCDataUrlCrash(); + void getFromHttpIntoBuffer_data(); + void getFromHttpIntoBuffer(); + + void ioGetFromHttpWithoutContentLength(); + + void ioGetFromHttpBrokenChunkedEncoding(); + // NOTE: This test must be last! void parentingRepliesToTheApp(); }; @@ -3936,6 +3944,7 @@ void tst_QNetworkReply::authorizationError() QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), httpStatusCode); QFETCH(QString, httpBody); + QCOMPARE(qint64(reply->size()), qint64(httpBody.size())); QCOMPARE(QString(reply->readAll()), httpBody); } @@ -4280,6 +4289,91 @@ void tst_QNetworkReply::symbianOpenCDataUrlCrash() QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), qint64(598)); } +void tst_QNetworkReply::getFromHttpIntoBuffer_data() +{ + QTest::addColumn("url"); + + QTest::newRow("rfc-internal") << QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/rfc3252.txt"); +} + +void tst_QNetworkReply::getFromHttpIntoBuffer() +{ + QFETCH(QUrl, url); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 1024*128); // 128 kB + + QNetworkAccessManager manager; + QNetworkReply *reply = manager.get(request); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(reply->isFinished()); + + QFile reference(SRCDIR "/rfc3252.txt"); + QVERIFY(reference.open(QIODevice::ReadOnly)); + + QCOMPARE(reference.bytesAvailable(), reply->bytesAvailable()); + QCOMPARE(reference.size(), reply->size()); + + // Compare the memory buffer + QVariant downloadBufferAttribute = reply->attribute(QNetworkRequest::DownloadBufferAttribute); + bool memoryComparison = + (0 == memcmp(static_cast(reference.readAll().data()), + downloadBufferAttribute.value > >()->constData(), reference.size())); + QVERIFY(memoryComparison); + + // Make sure the normal reading works + reference.seek(0); + QCOMPARE(reply->read(42), reference.read(42)); + QCOMPARE(reply->getChar(0), reference.getChar(0)); + QCOMPARE(reply->peek(23), reference.peek(23)); + QCOMPARE(reply->readLine(), reference.readLine()); + QCOMPARE(reference.bytesAvailable(), reply->bytesAvailable()); + QCOMPARE(reply->readAll(), reference.readAll()); + QVERIFY(reply->atEnd()); +} + +// Is handled somewhere else too, introduced this special test to have it more accessible +void tst_QNetworkReply::ioGetFromHttpWithoutContentLength() +{ + QByteArray dataToSend("HTTP/1.0 200 OK\r\n\r\nHALLO! 123!"); + MiniHttpServer server(dataToSend); + server.doClose = true; + + QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + + QCOMPARE(reply->url(), request.url()); + QVERIFY(reply->isFinished()); + QVERIFY(reply->error() == QNetworkReply::NoError); +} + +// Is handled somewhere else too, introduced this special test to have it more accessible +void tst_QNetworkReply::ioGetFromHttpBrokenChunkedEncoding() +{ + // This is wrong chunked encoding because of the X. What actually has to follow is \r\n + // and then the declaration of the final 0 chunk + QByteArray dataToSend("HTTP/1.0 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n3\r\nABCX"); + MiniHttpServer server(dataToSend); + server.doClose = false; // FIXME + + QNetworkRequest request(QUrl("http://localhost:" + QString::number(server.serverPort()))); + QNetworkReplyPtr reply = manager.get(request); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); + QTestEventLoop::instance().enterLoop(10); + + QEXPECT_FAIL(0, "We should close the socket and not just do nothing", Continue); + QVERIFY(!QTestEventLoop::instance().timeout()); + QEXPECT_FAIL(0, "We should close the socket and not just do nothing", Continue); + QVERIFY(reply->isFinished()); + QCOMPARE(reply->error(), QNetworkReply::NoError); +} // NOTE: This test must be last testcase in tst_qnetworkreply! -- cgit v0.12 From f28eb5e37c726ecd44bbbf1a5ad746570d2cac9b Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:23:04 +0200 Subject: tst_qiodevice: Add peek()ing auto test --- tests/auto/qiodevice/tst_qiodevice.cpp | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/auto/qiodevice/tst_qiodevice.cpp b/tests/auto/qiodevice/tst_qiodevice.cpp index 7048754..0226402 100644 --- a/tests/auto/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/qiodevice/tst_qiodevice.cpp @@ -81,6 +81,8 @@ private slots: void readLine2_data(); void readLine2(); + + void peekBug(); }; // Testing get/set functions @@ -591,5 +593,62 @@ void tst_QIODevice::readLine2() } } + +class PeekBug : public QIODevice { + Q_OBJECT +public: + char alphabet[27]; + qint64 counter; + PeekBug() : QIODevice(), counter(0) { + memcpy(alphabet,"abcdefghijklmnopqrstuvqxyz",27); + }; + qint64 readData(char *data, qint64 maxlen) { + qint64 pos = 0; + while (pos < maxlen) { + *(data + pos) = alphabet[counter]; + pos++; + counter++; + if (counter == 26) + counter = 0; + } + return maxlen; + } + qint64 writeData(const char *data, qint64 maxlen) { + return -1; + } + +}; + +// This is a testcase for the bug fixed with bd287865 +void tst_QIODevice::peekBug() +{ + PeekBug peekBug; + peekBug.open(QIODevice::ReadOnly | QIODevice::Unbuffered); + + char onetwo[2]; + peekBug.peek(onetwo, 2); + QCOMPARE(onetwo[0], 'a'); + QCOMPARE(onetwo[1], 'b'); + + peekBug.read(onetwo, 1); + QCOMPARE(onetwo[0], 'a'); + + peekBug.peek(onetwo, 2); + QCOMPARE(onetwo[0], 'b'); + QCOMPARE(onetwo[1], 'c'); + + peekBug.read(onetwo, 1); + QCOMPARE(onetwo[0], 'b'); + peekBug.read(onetwo, 1); + QCOMPARE(onetwo[0], 'c'); + peekBug.read(onetwo, 1); + QCOMPARE(onetwo[0], 'd'); + + peekBug.peek(onetwo, 2); + QCOMPARE(onetwo[0], 'e'); + QCOMPARE(onetwo[1], 'f'); + +} + QTEST_MAIN(tst_QIODevice) #include "tst_qiodevice.moc" -- cgit v0.12 From d70d5981c5f07d938c3fbddf3bafc486ef797251 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:24:10 +0200 Subject: tst_qbytearray: Auto test for reserve() This auto test tests undocumented but expected/intuitive behaviour. --- tests/auto/qbytearray/tst_qbytearray.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp index 07fdbc3..e3341d1 100644 --- a/tests/auto/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/qbytearray/tst_qbytearray.cpp @@ -142,6 +142,8 @@ private slots: void repeated_data() const; void byteRefDetaching() const; + + void reserve(); }; tst_QByteArray::tst_QByteArray() @@ -1516,6 +1518,22 @@ void tst_QByteArray::byteRefDetaching() const } } +void tst_QByteArray::reserve() +{ + int capacity = 100; + QByteArray qba; + qba.reserve(capacity); + QVERIFY(qba.capacity() == capacity); + char *data = qba.data(); + + // FIXME count from 0 to make it fail + for (int i = 1; i < capacity; i++) { + qba.resize(i); + QVERIFY(capacity == qba.capacity()); + QVERIFY(data == qba.data()); + } +} + const char globalChar = '1'; QTEST_APPLESS_MAIN(tst_QByteArray) -- cgit v0.12 From f08e07eb3f3beb2d0607272d645b23a310a67f8f Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:25:45 +0200 Subject: QNAM Zerocopy: Benchmark --- .../access/qnetworkreply/tst_qnetworkreply.cpp | 72 +++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp index 90ae153..0098d8e 100644 --- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -51,6 +51,9 @@ #include "../../../../auto/network-settings.h" +typedef QSharedPointer > QVarLengthArraySharedPointer; +Q_DECLARE_METATYPE(QVarLengthArraySharedPointer) + class TimedSender: public QThread { Q_OBJECT @@ -465,7 +468,8 @@ private slots: void httpUploadPerformance(); void httpDownloadPerformance_data(); void httpDownloadPerformance(); - + void httpDownloadPerformanceDownloadBuffer_data(); + void httpDownloadPerformanceDownloadBuffer(); }; void tst_qnetworkreply::httpLatency() @@ -649,6 +653,72 @@ void tst_qnetworkreply::httpDownloadPerformance() qint64 elapsed = time.elapsed(); qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, " << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec"; +}; + +class HttpDownloadPerformanceClientDownloadBuffer : QObject { + Q_OBJECT +private: + bool useDownloadBuffer; + QNetworkReply *reply; + qint64 uploadSize; +public: + HttpDownloadPerformanceClientDownloadBuffer (QNetworkReply *reply, bool useDownloadBuffer, qint64 uploadSize) + : useDownloadBuffer(useDownloadBuffer), reply(reply), uploadSize(uploadSize) + { + connect(reply, SIGNAL(finished()), this, SLOT(finishedSlot())); + } + + public slots: + void finishedSlot() { + if (useDownloadBuffer) { + QVariant downloadBufferAttribute = reply->attribute(QNetworkRequest::DownloadBufferAttribute); + QSharedPointer > data = downloadBufferAttribute.value > >(); + } else { + // We did not have a download buffer but we still need to benchmark having the data, e.g. reading it all. + char* replyData = (char*) qMalloc(uploadSize); + QVERIFY(reply->read(replyData, uploadSize) == uploadSize); + qFree(replyData); + } + } +}; + +void tst_qnetworkreply::httpDownloadPerformanceDownloadBuffer_data() +{ + QTest::addColumn("useDownloadBuffer"); + + QTest::newRow("use-download-buffer") << true; + QTest::newRow("do-not-use-download-buffer") << false; +} + +void tst_qnetworkreply::httpDownloadPerformanceDownloadBuffer() +{ + QFETCH(bool, useDownloadBuffer); + + // On my Linux Desktop the results are already visible with 128 kB, however we use this to have good results. +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_WINCE_WM) + // Show some mercy to non-desktop platform/s + enum {UploadSize = 4*1024*1024}; // 4 MB +#else + enum {UploadSize = 32*1024*1024}; // 32 MB +#endif + + HttpDownloadPerformanceServer server(UploadSize, true, false); + + QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1")); + if (useDownloadBuffer) + request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 1024*1024*128); // 128 MB is max allowed + + QNetworkAccessManager manager; + QNetworkReplyPtr reply = manager.get(request); + + HttpDownloadPerformanceClientDownloadBuffer client(reply, useDownloadBuffer, UploadSize); + + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QBENCHMARK { + QTestEventLoop::instance().enterLoop(40); + QCOMPARE(reply->error(), QNetworkReply::NoError); + QVERIFY(!QTestEventLoop::instance().timeout()); + } } QTEST_MAIN(tst_qnetworkreply) -- cgit v0.12 From 58a92e8fd06b868feae06f68221d08e2dcbf1d78 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 11:27:56 +0200 Subject: QAbstractSocket: Remove warning --- src/network/socket/qabstractsocket.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index ca72271..c0347dd 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -2100,7 +2100,6 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize) && d->readBufferMaxSize > 0 && maxSize < d->readBufferMaxSize && d->socketEngine) { - qDebug() << "QAbstractSocket::readData filling buffer"; // Our buffer is empty and a read() was requested for a byte amount that is smaller // than the readBufferMaxSize. This means that we should fill our buffer since we want // such small reads come from the buffer and not always go to the costly socket engine read() -- cgit v0.12 From 43b9ccb7284601247c474215f342ef13966de85b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Aug 2010 12:46:55 +0200 Subject: Revert the addition of the test of QtTest's random feature. It was added in commit 56396b4b2b66da3133aff1b3864c550ce892d233. Even though we have a -seed argument to provide reproduceability, it's only reproduceable if the PRNG algorithm is also kept. So we can't autotest this when we don't control the algorithm (for example, it's different from glibc to MSVC's runtime). --- tests/auto/selftests/expected_random.lightxml | 20 ------------------- tests/auto/selftests/expected_random.txt | 9 --------- tests/auto/selftests/expected_random.xml | 23 ---------------------- tests/auto/selftests/expected_random.xunitxml | 14 -------------- tests/auto/selftests/random/random.pro | 9 --------- tests/auto/selftests/random/tst_random.cpp | 28 --------------------------- tests/auto/selftests/selftests.pro | 2 +- tests/auto/selftests/selftests.qrc | 6 +----- tests/auto/selftests/tst_selftests.cpp | 5 ----- 9 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 tests/auto/selftests/expected_random.lightxml delete mode 100644 tests/auto/selftests/expected_random.txt delete mode 100644 tests/auto/selftests/expected_random.xml delete mode 100644 tests/auto/selftests/expected_random.xunitxml delete mode 100644 tests/auto/selftests/random/random.pro delete mode 100644 tests/auto/selftests/random/tst_random.cpp diff --git a/tests/auto/selftests/expected_random.lightxml b/tests/auto/selftests/expected_random.lightxml deleted file mode 100644 index 15f56a1..0000000 --- a/tests/auto/selftests/expected_random.lightxml +++ /dev/null @@ -1,20 +0,0 @@ - - @INSERT_QT_VERSION_HERE@ - @INSERT_QT_VERSION_HERE@ - 325 - - - - - - - - - - - - - - - - diff --git a/tests/auto/selftests/expected_random.txt b/tests/auto/selftests/expected_random.txt deleted file mode 100644 index 3f4c11d..0000000 --- a/tests/auto/selftests/expected_random.txt +++ /dev/null @@ -1,9 +0,0 @@ -********* Start testing of tst_Random ********* -Config: Using QTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@, Random seed 325 -PASS : tst_Random::initTestCase() -PASS : tst_Random::testTwo() -PASS : tst_Random::testOne() -PASS : tst_Random::testThree() -PASS : tst_Random::cleanupTestCase() -Totals: 5 passed, 0 failed, 0 skipped -********* Finished testing of tst_Random ********* diff --git a/tests/auto/selftests/expected_random.xml b/tests/auto/selftests/expected_random.xml deleted file mode 100644 index 3677287..0000000 --- a/tests/auto/selftests/expected_random.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - @INSERT_QT_VERSION_HERE@ - @INSERT_QT_VERSION_HERE@ - 325 - - - - - - - - - - - - - - - - - diff --git a/tests/auto/selftests/expected_random.xunitxml b/tests/auto/selftests/expected_random.xunitxml deleted file mode 100644 index 262aa0a..0000000 --- a/tests/auto/selftests/expected_random.xunitxml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/tests/auto/selftests/random/random.pro b/tests/auto/selftests/random/random.pro deleted file mode 100644 index 19572ad..0000000 --- a/tests/auto/selftests/random/random.pro +++ /dev/null @@ -1,9 +0,0 @@ -load(qttest_p4) -SOURCES += tst_random.cpp -QT = core - -mac:CONFIG -= app_bundle -CONFIG -= debug_and_release_target - - -TARGET = random diff --git a/tests/auto/selftests/random/tst_random.cpp b/tests/auto/selftests/random/tst_random.cpp deleted file mode 100644 index 1ee922e..0000000 --- a/tests/auto/selftests/random/tst_random.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -class tst_Random: public QObject -{ - Q_OBJECT - -private slots: - void testOne() const {} - void testTwo() const {} - void testThree() const {} -}; - -/* -int main(int argc, char * argv[]) -{ - int failures = 0; - tst_Random tst; - for (int i = 0; i != 10; i++) { - failures += QTest::qExec(&tst, argc, argv); - } - return failures; -} -*/ -QTEST_MAIN(tst_Random) - -#include "tst_random.moc" - diff --git a/tests/auto/selftests/selftests.pro b/tests/auto/selftests/selftests.pro index bfbd598..d854b5e 100644 --- a/tests/auto/selftests/selftests.pro +++ b/tests/auto/selftests/selftests.pro @@ -5,7 +5,7 @@ SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skipglobal skip \ skipinit skipinitdata datetime singleskip assert waitwithoutgui differentexec \ exceptionthrow qexecstringlist datatable commandlinedata\ benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \ - benchliboptions xunit badxml longstring random + benchliboptions xunit badxml longstring INSTALLS = diff --git a/tests/auto/selftests/selftests.qrc b/tests/auto/selftests/selftests.qrc index ba7ca4f..f82722b 100644 --- a/tests/auto/selftests/selftests.qrc +++ b/tests/auto/selftests/selftests.qrc @@ -90,10 +90,6 @@ expected_multiexec.xml expected_multiexec.xunitxml expected_qexecstringlist.txt - expected_random.txt - expected_random.lightxml - expected_random.xml - expected_random.xunitxml expected_singleskip.lightxml expected_singleskip.txt expected_singleskip.xml @@ -138,5 +134,5 @@ expected_xunit.txt expected_xunit.xml expected_xunit.xunitxml - + diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 9fb7ce6..0818b4c 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -245,7 +245,6 @@ void tst_Selftests::runSubTest_data() << "xunit" << "longstring" << "badxml" - << "random" ; foreach (Logger const& logger, allLoggers()) { @@ -274,9 +273,6 @@ void tst_Selftests::runSubTest_data() else if (subtest == "badxml") { arguments << "-eventcounter"; } - else if (subtest == "random") { - arguments << QString("-random -seed 325").split(' '); - } // These tests don't work right with loggers other than plain, usually because // they internally supply arguments to themselves. @@ -636,4 +632,3 @@ void tst_Selftests::cleanupTestCase() QTEST_MAIN(tst_Selftests) #include "tst_selftests.moc" - -- cgit v0.12 From f0912434632b1f17cb60688ed38bf830a5f25106 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 12 Aug 2010 15:13:10 +0200 Subject: QNAM: Fix namespaced compilation --- src/network/access/qnetworkreplyimpl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index c8808af..5345d63 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -54,10 +54,12 @@ #include QT_BEGIN_NAMESPACE - typedef QSharedPointer > QVarLengthArraySharedPointer; +QT_END_NAMESPACE Q_DECLARE_METATYPE(QVarLengthArraySharedPointer) +QT_BEGIN_NAMESPACE + inline QNetworkReplyImplPrivate::QNetworkReplyImplPrivate() : backend(0), outgoingData(0), outgoingDataBuffer(0), copyDevice(0), -- cgit v0.12 From 807ef9fde52c423088ab24f5b81146bc17d0afad Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 13 Aug 2010 09:11:08 +1000 Subject: QGLFunctions - cross-platform access to ES2.0 API --- dist/changes-4.8.0 | 2 + src/opengl/opengl.pro | 2 + src/opengl/qglfunctions.cpp | 3705 ++++++++++++++++++++++++++ src/opengl/qglfunctions.h | 2290 ++++++++++++++++ tests/auto/opengl.pro | 1 + tests/auto/qglfunctions/qglfunctions.pro | 7 + tests/auto/qglfunctions/tst_qglfunctions.cpp | 238 ++ 7 files changed, 6245 insertions(+) create mode 100644 src/opengl/qglfunctions.cpp create mode 100644 src/opengl/qglfunctions.h create mode 100644 tests/auto/qglfunctions/qglfunctions.pro create mode 100644 tests/auto/qglfunctions/tst_qglfunctions.cpp diff --git a/dist/changes-4.8.0 b/dist/changes-4.8.0 index f22460f..0c28274 100644 --- a/dist/changes-4.8.0 +++ b/dist/changes-4.8.0 @@ -46,6 +46,8 @@ QtGui QtOpenGL -------- - Removed dependency of OpenGL Utility Library (GLU) + - Added QGLFunctions, which provides cross-platform access to the + OpenGL/ES 2.0 API. **************************************************************************** diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index d6011cf..81b964a 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -20,6 +20,7 @@ contains(QT_CONFIG, egl):CONFIG += egl HEADERS += qgl.h \ qgl_p.h \ qglcolormap.h \ + qglfunctions.h \ qglpixelbuffer.h \ qglpixelbuffer_p.h \ qglframebufferobject.h \ @@ -31,6 +32,7 @@ HEADERS += qgl.h \ SOURCES += qgl.cpp \ qglcolormap.cpp \ + qglfunctions.cpp \ qglpixelbuffer.cpp \ qglframebufferobject.cpp \ qglextensions.cpp \ diff --git a/src/opengl/qglfunctions.cpp b/src/opengl/qglfunctions.cpp new file mode 100644 index 0000000..8a544c1 --- /dev/null +++ b/src/opengl/qglfunctions.cpp @@ -0,0 +1,3705 @@ +/**************************************************************************** +** +** 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 "qglfunctions.h" +#include "qgl_p.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QGLFunctions + \brief The QGLFunctions class provides cross-platform access to the OpenGL/ES 2.0 API. + \since 4.8 + \ingroup painting-3D + + OpenGL/ES 2.0 defines a subset of the OpenGL specification that is + common across many desktop and embedded OpenGL implementations. + However, it can be difficult to use the functions from that subset + because they need to be resolved manually on desktop systems. + + QGLFunctions provides a guaranteed API that is available on all + OpenGL systems and takes care of function resolution on systems + that need it. The recommended way to use QGLFunctions is by + direct inheritance: + + \code + class MyGLWidget : public QGLWidget, protected QGLFunctions + { + Q_OBJECT + public: + MyGLWidget(QWidget *parent = 0) : QGLWidget(parent) {} + + protected: + void initializeGL(); + void paintGL(); + }; + + void MyGLWidget::initializeGL() + { + initializeGLFunctions(); + } + \endcode + + The \c{paintGL()} function can then use any of the OpenGL/ES 2.0 + functions without explicit resolution, such as glActiveTexture() + in the following example: + + \code + void MyGLWidget::paintGL() + { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, textureId); + ... + } + \endcode + + QGLFunctions can also be used directly for ad-hoc invocation + of OpenGL/ES 2.0 functions on all platforms: + + \code + QGLFunctions glFuncs(QGLContext::currentContext()); + glFuncs.glActiveTexture(GL_TEXTURE1); + \endcode + + QGLFunctions provides wrappers for all OpenGL/ES 2.0 functions, + except those like \c{glDrawArrays()}, \c{glViewport()}, and + \c{glBindTexture()} that don't have portability issues. + + Including the header for QGLFunctions will also define all of + the OpenGL/ES 2.0 macro constants that are not already defined by + the system's OpenGL headers, such as \c{GL_TEXTURE1} above. + + The hasOpenGLFeature() and openGLFeatures() functions can be used + to determine if the OpenGL implementation has a major OpenGL/ES 2.0 + feature. For example, the following checks if non power of two + textures are available: + + \code + QGLFunctions funcs(QGLContext::currentContext()); + bool npot = funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures); + \endcode +*/ + +/*! + \enum QGLFunctions::OpenGLFeature + This enum defines OpenGL/ES 2.0 features that may be optional + on other platforms. + + \value Multitexture glActiveTexture() function is available. + \value Shaders Shader functions are available. + \value Buffers Vertex and index buffer functions are available. + \value Framebuffers Framebuffer object functions are available. + \value BlendColor glBlendColor() is available. + \value BlendEquation glBlendEquation() is available. + \value BlendEquationSeparate glBlendEquationSeparate() is available. + \value BlendFuncSeparate glBlendFuncSeparate() is available. + \value BlendSubtract Blend subtract mode is available. + \value CompressedTextures Compressed texture functions are available. + \value Multisample glSampleCoverage() function is available. + \value StencilSeparate Separate stencil functions are available. + \value NPOTTextures Non power of two textures are available. +*/ + +// Hidden private fields for additional extension data. +struct QGLFunctionsPrivateEx : public QGLFunctionsPrivate +{ + QGLFunctionsPrivateEx(const QGLContext *context = 0) + : QGLFunctionsPrivate(context) + , m_features(-1) {} + + int m_features; +}; + +#if QT_VERSION >= 0x040800 +Q_GLOBAL_STATIC(QGLContextGroupResource, qt_gl_functions_resource) +#else +static void qt_gl_functions_free(void *data) +{ + delete reinterpret_cast(data); +} + +Q_GLOBAL_STATIC_WITH_ARGS(QGLContextResource, qt_gl_functions_resource, (qt_gl_functions_free)) +#endif +static QGLFunctionsPrivateEx *qt_gl_functions(const QGLContext *context = 0) +{ + if (!context) + context = QGLContext::currentContext(); + Q_ASSERT(context); + QGLFunctionsPrivateEx *funcs = + reinterpret_cast + (qt_gl_functions_resource()->value(context)); +#if QT_VERSION < 0x040800 + if (!funcs) { + funcs = new QGLFunctionsPrivateEx(); + qt_gl_functions_resource()->insert(context, funcs); + } +#endif + return funcs; +} + +/*! + Constructs a default function resolver. The resolver cannot + be used until initializeGLFunctions() is called to specify + the context. + + \sa initializeGLFunctions() +*/ +QGLFunctions::QGLFunctions() + : d_ptr(0) +{ +} + +/*! + Constructs a function resolver for \a context. If \a context + is null, then the resolver will be created for the current QGLContext. + + An object constructed in this way can only be used with \a context + and other contexts that share with it. Use initializeGLFunctions() + to change the object's context association. + + \sa initializeGLFunctions() +*/ +QGLFunctions::QGLFunctions(const QGLContext *context) + : d_ptr(qt_gl_functions(context)) +{ +} + +/*! + \fn QGLFunctions::~QGLFunctions() + + Destroys this function resolver. +*/ + +static int qt_gl_resolve_features() +{ +#if defined(QT_OPENGL_ES_2) + return QGLFunctions::Multitexture | + QGLFunctions::Shaders | + QGLFunctions::Buffers | + QGLFunctions::Framebuffers | + QGLFunctions::BlendColor | + QGLFunctions::BlendEquation | + QGLFunctions::BlendEquationSeparate | + QGLFunctions::BlendFuncSeparate | + QGLFunctions::BlendSubtract | + QGLFunctions::CompressedTextures | + QGLFunctions::Multisample | + QGLFunctions::StencilSeparate | + QGLFunctions::NPOTTextures; +#elif defined(QT_OPENGL_ES) + int features = QGLFunctions::Multitexture | + QGLFunctions::Buffers | + QGLFunctions::CompressedTextures | + QGLFunctions::Multisample; + QGLExtensionMatcher extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); + if (extensions.match("GL_OES_framebuffer_object")) + features |= QGLFunctions::Framebuffers; + if (extensions.match("GL_OES_blend_equation_separate")) + features |= QGLFunctions::BlendEquationSeparate; + if (extensions.match("GL_OES_blend_func_separate")) + features |= QGLFunctions::BlendFuncSeparate; + if (extensions.match("GL_OES_blend_subtract")) + features |= QGLFunctions::BlendSubtract; + if (extensions.match("GL_OES_texture_npot")) + features |= QGLFunctions::NPOTTextures; + return features; +#else + int features = 0; + QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags(); + QGLExtensionMatcher extensions(reinterpret_cast(glGetString(GL_EXTENSIONS))); + + // Recognize features by extension name. + if (extensions.match("GL_ARB_multitexture")) + features |= QGLFunctions::Multitexture; + if (extensions.match("GL_ARB_shader_objects")) + features |= QGLFunctions::Shaders; + if (extensions.match("GL_EXT_framebuffer_object") || + extensions.match("GL_ARB_framebuffer_object")) + features |= QGLFunctions::Framebuffers; + if (extensions.match("GL_EXT_blend_color")) + features |= QGLFunctions::BlendColor; + if (extensions.match("GL_EXT_blend_equation_separate")) + features |= QGLFunctions::BlendEquationSeparate; + if (extensions.match("GL_EXT_blend_func_separate")) + features |= QGLFunctions::BlendFuncSeparate; + if (extensions.match("GL_EXT_blend_subtract")) + features |= QGLFunctions::BlendSubtract; + if (extensions.match("GL_ARB_texture_compression")) + features |= QGLFunctions::CompressedTextures; + if (extensions.match("GL_ARB_multisample")) + features |= QGLFunctions::Multisample; + if (extensions.match("GL_ARB_texture_non_power_of_two")) + features |= QGLFunctions::NPOTTextures; + + // Recognize features by minimum OpenGL version. + if (versions & QGLFormat::OpenGL_Version_1_2) { + features |= QGLFunctions::BlendColor | + QGLFunctions::BlendEquation; + } + if (versions & QGLFormat::OpenGL_Version_1_3) { + features |= QGLFunctions::Multitexture | + QGLFunctions::CompressedTextures | + QGLFunctions::Multisample; + } + if (versions & QGLFormat::OpenGL_Version_1_4) + features |= QGLFunctions::BlendFuncSeparate; + if (versions & QGLFormat::OpenGL_Version_1_5) + features |= QGLFunctions::Buffers; + if (versions & QGLFormat::OpenGL_Version_2_0) { + features |= QGLFunctions::Shaders | + QGLFunctions::StencilSeparate | + QGLFunctions::BlendEquationSeparate | + QGLFunctions::NPOTTextures; + } + return features; +#endif +} + +/*! + Returns the set of features that are present on this system's + OpenGL implementation. + + It is assumed that the QGLContext associated with this function + resolver is current. + + \sa hasOpenGLFeature() +*/ +QGLFunctions::OpenGLFeatures QGLFunctions::openGLFeatures() const +{ + QGLFunctionsPrivateEx *d = static_cast(d_ptr); + if (!d) + return 0; + if (d->m_features == -1) + d->m_features = qt_gl_resolve_features(); + return QGLFunctions::OpenGLFeatures(d->m_features); +} + +/*! + Returns true if \a feature is present on this system's OpenGL + implementation; false otherwise. + + It is assumed that the QGLContext associated with this function + resolver is current. + + \sa openGLFeatures() +*/ +bool QGLFunctions::hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const +{ + QGLFunctionsPrivateEx *d = static_cast(d_ptr); + if (!d) + return false; + if (d->m_features == -1) + d->m_features = qt_gl_resolve_features(); + return (d->m_features & int(feature)) != 0; +} + +/*! + Initializes GL function resolution for \a context. If \a context + is null, then the current QGLContext will be used. + + After calling this function, the QGLFunctions object can only be + used with \a context and other contexts that share with it. + Call initializeGLFunctions() again to change the object's context + association. +*/ +void QGLFunctions::initializeGLFunctions(const QGLContext *context) +{ + d_ptr = qt_gl_functions(context); +} + +/*! + \fn void QGLFunctions::glActiveTexture(GLenum texture) + + Convenience function that calls glActiveTexture(\a texture). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glActiveTexture.xml}{glActiveTexture()}. +*/ + +/*! + \fn void QGLFunctions::glAttachShader(GLuint program, GLuint shader) + + Convenience function that calls glAttachShader(\a program, \a shader). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glAttachShader.xml}{glAttachShader()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name) + + Convenience function that calls glBindAttribLocation(\a program, \a index, \a name). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBindAttribLocation.xml}{glBindAttribLocation()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer) + + Convenience function that calls glBindBuffer(\a target, \a buffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBindBuffer.xml}{glBindBuffer()}. +*/ + +/*! + \fn void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer) + + Convenience function that calls glBindFramebuffer(\a target, \a framebuffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBindFramebuffer.xml}{glBindFramebuffer()}. +*/ + +/*! + \fn void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer) + + Convenience function that calls glBindRenderbuffer(\a target, \a renderbuffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBindRenderbuffer.xml}{glBindRenderbuffer()}. +*/ + +/*! + \fn void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) + + Convenience function that calls glBlendColor(\a red, \a green, \a blue, \a alpha). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendColor.xml}{glBlendColor()}. +*/ + +/*! + \fn void QGLFunctions::glBlendEquation(GLenum mode) + + Convenience function that calls glBlendEquation(\a mode). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquation.xml}{glBlendEquation()}. +*/ + +/*! + \fn void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) + + Convenience function that calls glBlendEquationSeparate(\a modeRGB, \a modeAlpha). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendEquationSeparate.xml}{glBlendEquationSeparate()}. +*/ + +/*! + \fn void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) + + Convenience function that calls glBlendFuncSeparate(\a srcRGB, \a dstRGB, \a srcAlpha, \a dstAlpha). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBlendFuncSeparate.xml}{glBlendFuncSeparate()}. +*/ + +/*! + \fn void QGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage) + + Convenience function that calls glBufferData(\a target, \a size, \a data, \a usage). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferData.xml}{glBufferData()}. +*/ + +/*! + \fn void QGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data) + + Convenience function that calls glBufferSubData(\a target, \a offset, \a size, \a data). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glBufferSubData.xml}{glBufferSubData()}. +*/ + +/*! + \fn GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target) + + Convenience function that calls glCheckFramebufferStatus(\a target). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glCheckFramebufferStatus.xml}{glCheckFramebufferStatus()}. +*/ + +/*! + \fn void QGLFunctions::glClearDepthf(GLclampf depth) + + Convenience function that calls glClearDepth(\a depth) on + desktop OpenGL systems and glClearDepthf(\a depth) on + embedded OpenGL/ES systems. + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glClearDepthf.xml}{glClearDepthf()}. +*/ + +/*! + \fn void QGLFunctions::glCompileShader(GLuint shader) + + Convenience function that calls glCompileShader(\a shader). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glCompileShader.xml}{glCompileShader()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) + + Convenience function that calls glCompressedTexImage2D(\a target, \a level, \a internalformat, \a width, \a height, \a border, \a imageSize, \a data). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexImage2D.xml}{glCompressedTexImage2D()}. +*/ + +/*! + \fn void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) + + Convenience function that calls glCompressedTexSubImage2D(\a target, \a level, \a xoffset, \a yoffset, \a width, \a height, \a format, \a imageSize, \a data). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glCompressedTexSubImage2D.xml}{glCompressedTexSubImage2D()}. +*/ + +/*! + \fn GLuint QGLFunctions::glCreateProgram() + + Convenience function that calls glCreateProgram(). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateProgram.xml}{glCreateProgram()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn GLuint QGLFunctions::glCreateShader(GLenum type) + + Convenience function that calls glCreateShader(\a type). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glCreateShader.xml}{glCreateShader()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers) + + Convenience function that calls glDeleteBuffers(\a n, \a buffers). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteBuffers.xml}{glDeleteBuffers()}. +*/ + +/*! + \fn void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) + + Convenience function that calls glDeleteFramebuffers(\a n, \a framebuffers). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteFramebuffers.xml}{glDeleteFramebuffers()}. +*/ + +/*! + \fn void QGLFunctions::glDeleteProgram(GLuint program) + + Convenience function that calls glDeleteProgram(\a program). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteProgram.xml}{glDeleteProgram()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) + + Convenience function that calls glDeleteRenderbuffers(\a n, \a renderbuffers). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteRenderbuffers.xml}{glDeleteRenderbuffers()}. +*/ + +/*! + \fn void QGLFunctions::glDeleteShader(GLuint shader) + + Convenience function that calls glDeleteShader(\a shader). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDeleteShader.xml}{glDeleteShader()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar) + + Convenience function that calls glDepthRange(\a zNear, \a zFar) on + desktop OpenGL systems and glDepthRangef(\a zNear, \a zFar) on + embedded OpenGL/ES systems. + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDepthRangef.xml}{glDepthRangef()}. +*/ + +/*! + \fn void QGLFunctions::glDetachShader(GLuint program, GLuint shader) + + Convenience function that calls glDetachShader(\a program, \a shader). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDetachShader.xml}{glDetachShader()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glDisableVertexAttribArray(GLuint index) + + Convenience function that calls glDisableVertexAttribArray(\a index). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glDisableVertexAttribArray.xml}{glDisableVertexAttribArray()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glEnableVertexAttribArray(GLuint index) + + Convenience function that calls glEnableVertexAttribArray(\a index). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glEnableVertexAttribArray.xml}{glEnableVertexAttribArray()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) + + Convenience function that calls glFramebufferRenderbuffer(\a target, \a attachment, \a renderbuffertarget, \a renderbuffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferRenderbuffer.xml}{glFramebufferRenderbuffer()}. +*/ + +/*! + \fn void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) + + Convenience function that calls glFramebufferTexture2D(\a target, \a attachment, \a textarget, \a texture, \a level). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glFramebufferTexture2D.xml}{glFramebufferTexture2D()}. +*/ + +/*! + \fn void QGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers) + + Convenience function that calls glGenBuffers(\a n, \a buffers). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGenBuffers.xml}{glGenBuffers()}. +*/ + +/*! + \fn void QGLFunctions::glGenerateMipmap(GLenum target) + + Convenience function that calls glGenerateMipmap(\a target). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGenerateMipmap.xml}{glGenerateMipmap()}. +*/ + +/*! + \fn void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers) + + Convenience function that calls glGenFramebuffers(\a n, \a framebuffers). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGenFramebuffers.xml}{glGenFramebuffers()}. +*/ + +/*! + \fn void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) + + Convenience function that calls glGenRenderbuffers(\a n, \a renderbuffers). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGenRenderbuffers.xml}{glGenRenderbuffers()}. +*/ + +/*! + \fn void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) + + Convenience function that calls glGetActiveAttrib(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveAttrib.xml}{glGetActiveAttrib()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) + + Convenience function that calls glGetActiveUniform(\a program, \a index, \a bufsize, \a length, \a size, \a type, \a name). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetActiveUniform.xml}{glGetActiveUniform()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) + + Convenience function that calls glGetAttachedShaders(\a program, \a maxcount, \a count, \a shaders). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttachedShaders.xml}{glGetAttachedShaders()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn int QGLFunctions::glGetAttribLocation(GLuint program, const char* name) + + Convenience function that calls glGetAttribLocation(\a program, \a name). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetAttribLocation.xml}{glGetAttribLocation()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) + + Convenience function that calls glGetBufferParameteriv(\a target, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetBufferParameteriv.xml}{glGetBufferParameteriv()}. +*/ + +/*! + \fn void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) + + Convenience function that calls glGetFramebufferAttachmentParameteriv(\a target, \a attachment, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetFramebufferAttachmentParameteriv.xml}{glGetFramebufferAttachmentParameteriv()}. +*/ + +/*! + \fn void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params) + + Convenience function that calls glGetProgramiv(\a program, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramiv.xml}{glGetProgramiv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) + + Convenience function that calls glGetProgramInfoLog(\a program, \a bufsize, \a length, \a infolog). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetProgramInfoLog.xml}{glGetProgramInfoLog()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) + + Convenience function that calls glGetRenderbufferParameteriv(\a target, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetRenderbufferParameteriv.xml}{glGetRenderbufferParameteriv()}. +*/ + +/*! + \fn void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params) + + Convenience function that calls glGetShaderiv(\a shader, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderiv.xml}{glGetShaderiv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) + + Convenience function that calls glGetShaderInfoLog(\a shader, \a bufsize, \a length, \a infolog). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderInfoLog.xml}{glGetShaderInfoLog()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) + + Convenience function that calls glGetShaderPrecisionFormat(\a shadertype, \a precisiontype, \a range, \a precision). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderPrecisionFormat.xml}{glGetShaderPrecisionFormat()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) + + Convenience function that calls glGetShaderSource(\a shader, \a bufsize, \a length, \a source). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetShaderSource.xml}{glGetShaderSource()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params) + + Convenience function that calls glGetUniformfv(\a program, \a location, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformfv.xml}{glGetUniformfv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params) + + Convenience function that calls glGetUniformiv(\a program, \a location, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformiv.xml}{glGetUniformiv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn int QGLFunctions::glGetUniformLocation(GLuint program, const char* name) + + Convenience function that calls glGetUniformLocation(\a program, \a name). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetUniformLocation.xml}{glGetUniformLocation()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) + + Convenience function that calls glGetVertexAttribfv(\a index, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribfv.xml}{glGetVertexAttribfv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) + + Convenience function that calls glGetVertexAttribiv(\a index, \a pname, \a params). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribiv.xml}{glGetVertexAttribiv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) + + Convenience function that calls glGetVertexAttribPointerv(\a index, \a pname, \a pointer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glGetVertexAttribPointerv.xml}{glGetVertexAttribPointerv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn GLboolean QGLFunctions::glIsBuffer(GLuint buffer) + + Convenience function that calls glIsBuffer(\a buffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glIsBuffer.xml}{glIsBuffer()}. +*/ + +/*! + \fn GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer) + + Convenience function that calls glIsFramebuffer(\a framebuffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glIsFramebuffer.xml}{glIsFramebuffer()}. +*/ + +/*! + \fn GLboolean QGLFunctions::glIsProgram(GLuint program) + + Convenience function that calls glIsProgram(\a program). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glIsProgram.xml}{glIsProgram()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer) + + Convenience function that calls glIsRenderbuffer(\a renderbuffer). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glIsRenderbuffer.xml}{glIsRenderbuffer()}. +*/ + +/*! + \fn GLboolean QGLFunctions::glIsShader(GLuint shader) + + Convenience function that calls glIsShader(\a shader). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glIsShader.xml}{glIsShader()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glLinkProgram(GLuint program) + + Convenience function that calls glLinkProgram(\a program). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glLinkProgram.xml}{glLinkProgram()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glReleaseShaderCompiler() + + Convenience function that calls glReleaseShaderCompiler(). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glReleaseShaderCompiler.xml}{glReleaseShaderCompiler()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) + + Convenience function that calls glRenderbufferStorage(\a target, \a internalformat, \a width, \a height). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glRenderbufferStorage.xml}{glRenderbufferStorage()}. +*/ + +/*! + \fn void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert) + + Convenience function that calls glSampleCoverage(\a value, \a invert). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glSampleCoverage.xml}{glSampleCoverage()}. +*/ + +/*! + \fn void QGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length) + + Convenience function that calls glShaderBinary(\a n, \a shaders, \a binaryformat, \a binary, \a length). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderBinary.xml}{glShaderBinary()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) + + Convenience function that calls glShaderSource(\a shader, \a count, \a string, \a length). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glShaderSource.xml}{glShaderSource()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) + + Convenience function that calls glStencilFuncSeparate(\a face, \a func, \a ref, \a mask). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilFuncSeparate.xml}{glStencilFuncSeparate()}. +*/ + +/*! + \fn void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask) + + Convenience function that calls glStencilMaskSeparate(\a face, \a mask). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilMaskSeparate.xml}{glStencilMaskSeparate()}. +*/ + +/*! + \fn void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) + + Convenience function that calls glStencilOpSeparate(\a face, \a fail, \a zfail, \a zpass). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glStencilOpSeparate.xml}{glStencilOpSeparate()}. +*/ + +/*! + \fn void QGLFunctions::glUniform1f(GLint location, GLfloat x) + + Convenience function that calls glUniform1f(\a location, \a x). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1f.xml}{glUniform1f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v) + + Convenience function that calls glUniform1fv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1fv.xml}{glUniform1fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform1i(GLint location, GLint x) + + Convenience function that calls glUniform1i(\a location, \a x). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1i.xml}{glUniform1i()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v) + + Convenience function that calls glUniform1iv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform1iv.xml}{glUniform1iv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y) + + Convenience function that calls glUniform2f(\a location, \a x, \a y). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2f.xml}{glUniform2f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v) + + Convenience function that calls glUniform2fv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2fv.xml}{glUniform2fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y) + + Convenience function that calls glUniform2i(\a location, \a x, \a y). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2i.xml}{glUniform2i()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v) + + Convenience function that calls glUniform2iv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform2iv.xml}{glUniform2iv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) + + Convenience function that calls glUniform3f(\a location, \a x, \a y, \a z). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3f.xml}{glUniform3f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v) + + Convenience function that calls glUniform3fv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3fv.xml}{glUniform3fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z) + + Convenience function that calls glUniform3i(\a location, \a x, \a y, \a z). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3i.xml}{glUniform3i()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v) + + Convenience function that calls glUniform3iv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform3iv.xml}{glUniform3iv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + + Convenience function that calls glUniform4f(\a location, \a x, \a y, \a z, \a w). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4f.xml}{glUniform4f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v) + + Convenience function that calls glUniform4fv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4fv.xml}{glUniform4fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) + + Convenience function that calls glUniform4i(\a location, \a x, \a y, \a z, \a w). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4i.xml}{glUniform4i()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v) + + Convenience function that calls glUniform4iv(\a location, \a count, \a v). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniform4iv.xml}{glUniform4iv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + + Convenience function that calls glUniformMatrix2fv(\a location, \a count, \a transpose, \a value). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix2fv.xml}{glUniformMatrix2fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + + Convenience function that calls glUniformMatrix3fv(\a location, \a count, \a transpose, \a value). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix3fv.xml}{glUniformMatrix3fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) + + Convenience function that calls glUniformMatrix4fv(\a location, \a count, \a transpose, \a value). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUniformMatrix4fv.xml}{glUniformMatrix4fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glUseProgram(GLuint program) + + Convenience function that calls glUseProgram(\a program). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glUseProgram.xml}{glUseProgram()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glValidateProgram(GLuint program) + + Convenience function that calls glValidateProgram(\a program). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glValidateProgram.xml}{glValidateProgram()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x) + + Convenience function that calls glVertexAttrib1f(\a indx, \a x). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1f.xml}{glVertexAttrib1f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values) + + Convenience function that calls glVertexAttrib1fv(\a indx, \a values). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib1fv.xml}{glVertexAttrib1fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) + + Convenience function that calls glVertexAttrib2f(\a indx, \a x, \a y). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2f.xml}{glVertexAttrib2f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values) + + Convenience function that calls glVertexAttrib2fv(\a indx, \a values). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib2fv.xml}{glVertexAttrib2fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) + + Convenience function that calls glVertexAttrib3f(\a indx, \a x, \a y, \a z). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3f.xml}{glVertexAttrib3f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values) + + Convenience function that calls glVertexAttrib3fv(\a indx, \a values). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib3fv.xml}{glVertexAttrib3fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) + + Convenience function that calls glVertexAttrib4f(\a indx, \a x, \a y, \a z, \a w). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4f.xml}{glVertexAttrib4f()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values) + + Convenience function that calls glVertexAttrib4fv(\a indx, \a values). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttrib4fv.xml}{glVertexAttrib4fv()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +/*! + \fn void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) + + Convenience function that calls glVertexAttribPointer(\a indx, \a size, \a type, \a normalized, \a stride, \a ptr). + + For more information, see the OpenGL/ES 2.0 documentation for + \l{http://www.khronos.org/opengles/sdk/docs/man/glVertexAttribPointer.xml}{glVertexAttribPointer()}. + + This convenience function will do nothing on OpenGL/ES 1.x systems. +*/ + +#ifndef QT_OPENGL_ES_2 + +static void qglfResolveActiveTexture(GLenum texture) +{ + typedef void (QGLF_APIENTRYP type_glActiveTexture)(GLenum texture); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->activeTexture = (type_glActiveTexture) + context->getProcAddress(QLatin1String("glActiveTexture")); + if (!funcs->activeTexture) { + funcs->activeTexture = (type_glActiveTexture) + context->getProcAddress(QLatin1String("glActiveTextureARB")); + } + + if (funcs->activeTexture) + funcs->activeTexture(texture); + else + funcs->activeTexture = qglfResolveActiveTexture; +} + +static void qglfResolveAttachShader(GLuint program, GLuint shader) +{ + typedef void (QGLF_APIENTRYP type_glAttachShader)(GLuint program, GLuint shader); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->attachShader = (type_glAttachShader) + context->getProcAddress(QLatin1String("glAttachShader")); + if (!funcs->attachShader) { + funcs->attachShader = (type_glAttachShader) + context->getProcAddress(QLatin1String("glAttachObjectARB")); + } + + if (funcs->attachShader) + funcs->attachShader(program, shader); + else + funcs->attachShader = qglfResolveAttachShader; +} + +static void qglfResolveBindAttribLocation(GLuint program, GLuint index, const char* name) +{ + typedef void (QGLF_APIENTRYP type_glBindAttribLocation)(GLuint program, GLuint index, const char* name); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->bindAttribLocation = (type_glBindAttribLocation) + context->getProcAddress(QLatin1String("glBindAttribLocation")); + if (!funcs->bindAttribLocation) { + funcs->bindAttribLocation = (type_glBindAttribLocation) + context->getProcAddress(QLatin1String("glBindAttribLocationARB")); + } + + if (funcs->bindAttribLocation) + funcs->bindAttribLocation(program, index, name); + else + funcs->bindAttribLocation = qglfResolveBindAttribLocation; +} + +static void qglfResolveBindBuffer(GLenum target, GLuint buffer) +{ + typedef void (QGLF_APIENTRYP type_glBindBuffer)(GLenum target, GLuint buffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->bindBuffer = (type_glBindBuffer) + context->getProcAddress(QLatin1String("glBindBuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->bindBuffer) { + funcs->bindBuffer = (type_glBindBuffer) + context->getProcAddress(QLatin1String("glBindBufferOES")); + } +#endif + if (!funcs->bindBuffer) { + funcs->bindBuffer = (type_glBindBuffer) + context->getProcAddress(QLatin1String("glBindBufferEXT")); + } + if (!funcs->bindBuffer) { + funcs->bindBuffer = (type_glBindBuffer) + context->getProcAddress(QLatin1String("glBindBufferARB")); + } + + if (funcs->bindBuffer) + funcs->bindBuffer(target, buffer); + else + funcs->bindBuffer = qglfResolveBindBuffer; +} + +static void qglfResolveBindFramebuffer(GLenum target, GLuint framebuffer) +{ + typedef void (QGLF_APIENTRYP type_glBindFramebuffer)(GLenum target, GLuint framebuffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->bindFramebuffer = (type_glBindFramebuffer) + context->getProcAddress(QLatin1String("glBindFramebuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->bindFramebuffer) { + funcs->bindFramebuffer = (type_glBindFramebuffer) + context->getProcAddress(QLatin1String("glBindFramebufferOES")); + } +#endif + if (!funcs->bindFramebuffer) { + funcs->bindFramebuffer = (type_glBindFramebuffer) + context->getProcAddress(QLatin1String("glBindFramebufferEXT")); + } + if (!funcs->bindFramebuffer) { + funcs->bindFramebuffer = (type_glBindFramebuffer) + context->getProcAddress(QLatin1String("glBindFramebufferARB")); + } + + if (funcs->bindFramebuffer) + funcs->bindFramebuffer(target, framebuffer); + else + funcs->bindFramebuffer = qglfResolveBindFramebuffer; +} + +static void qglfResolveBindRenderbuffer(GLenum target, GLuint renderbuffer) +{ + typedef void (QGLF_APIENTRYP type_glBindRenderbuffer)(GLenum target, GLuint renderbuffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->bindRenderbuffer = (type_glBindRenderbuffer) + context->getProcAddress(QLatin1String("glBindRenderbuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->bindRenderbuffer) { + funcs->bindRenderbuffer = (type_glBindRenderbuffer) + context->getProcAddress(QLatin1String("glBindRenderbufferOES")); + } +#endif + if (!funcs->bindRenderbuffer) { + funcs->bindRenderbuffer = (type_glBindRenderbuffer) + context->getProcAddress(QLatin1String("glBindRenderbufferEXT")); + } + if (!funcs->bindRenderbuffer) { + funcs->bindRenderbuffer = (type_glBindRenderbuffer) + context->getProcAddress(QLatin1String("glBindRenderbufferARB")); + } + + if (funcs->bindRenderbuffer) + funcs->bindRenderbuffer(target, renderbuffer); + else + funcs->bindRenderbuffer = qglfResolveBindRenderbuffer; +} + +static void qglfResolveBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + typedef void (QGLF_APIENTRYP type_glBlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->blendColor = (type_glBlendColor) + context->getProcAddress(QLatin1String("glBlendColor")); +#ifdef QT_OPENGL_ES + if (!funcs->blendColor) { + funcs->blendColor = (type_glBlendColor) + context->getProcAddress(QLatin1String("glBlendColorOES")); + } +#endif + if (!funcs->blendColor) { + funcs->blendColor = (type_glBlendColor) + context->getProcAddress(QLatin1String("glBlendColorEXT")); + } + if (!funcs->blendColor) { + funcs->blendColor = (type_glBlendColor) + context->getProcAddress(QLatin1String("glBlendColorARB")); + } + + if (funcs->blendColor) + funcs->blendColor(red, green, blue, alpha); + else + funcs->blendColor = qglfResolveBlendColor; +} + +static void qglfResolveBlendEquation(GLenum mode) +{ + typedef void (QGLF_APIENTRYP type_glBlendEquation)(GLenum mode); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->blendEquation = (type_glBlendEquation) + context->getProcAddress(QLatin1String("glBlendEquation")); +#ifdef QT_OPENGL_ES + if (!funcs->blendEquation) { + funcs->blendEquation = (type_glBlendEquation) + context->getProcAddress(QLatin1String("glBlendEquationOES")); + } +#endif + if (!funcs->blendEquation) { + funcs->blendEquation = (type_glBlendEquation) + context->getProcAddress(QLatin1String("glBlendEquationEXT")); + } + if (!funcs->blendEquation) { + funcs->blendEquation = (type_glBlendEquation) + context->getProcAddress(QLatin1String("glBlendEquationARB")); + } + + if (funcs->blendEquation) + funcs->blendEquation(mode); + else + funcs->blendEquation = qglfResolveBlendEquation; +} + +static void qglfResolveBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +{ + typedef void (QGLF_APIENTRYP type_glBlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->blendEquationSeparate = (type_glBlendEquationSeparate) + context->getProcAddress(QLatin1String("glBlendEquationSeparate")); +#ifdef QT_OPENGL_ES + if (!funcs->blendEquationSeparate) { + funcs->blendEquationSeparate = (type_glBlendEquationSeparate) + context->getProcAddress(QLatin1String("glBlendEquationSeparateOES")); + } +#endif + if (!funcs->blendEquationSeparate) { + funcs->blendEquationSeparate = (type_glBlendEquationSeparate) + context->getProcAddress(QLatin1String("glBlendEquationSeparateEXT")); + } + if (!funcs->blendEquationSeparate) { + funcs->blendEquationSeparate = (type_glBlendEquationSeparate) + context->getProcAddress(QLatin1String("glBlendEquationSeparateARB")); + } + + if (funcs->blendEquationSeparate) + funcs->blendEquationSeparate(modeRGB, modeAlpha); + else + funcs->blendEquationSeparate = qglfResolveBlendEquationSeparate; +} + +static void qglfResolveBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ + typedef void (QGLF_APIENTRYP type_glBlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->blendFuncSeparate = (type_glBlendFuncSeparate) + context->getProcAddress(QLatin1String("glBlendFuncSeparate")); +#ifdef QT_OPENGL_ES + if (!funcs->blendFuncSeparate) { + funcs->blendFuncSeparate = (type_glBlendFuncSeparate) + context->getProcAddress(QLatin1String("glBlendFuncSeparateOES")); + } +#endif + if (!funcs->blendFuncSeparate) { + funcs->blendFuncSeparate = (type_glBlendFuncSeparate) + context->getProcAddress(QLatin1String("glBlendFuncSeparateEXT")); + } + if (!funcs->blendFuncSeparate) { + funcs->blendFuncSeparate = (type_glBlendFuncSeparate) + context->getProcAddress(QLatin1String("glBlendFuncSeparateARB")); + } + + if (funcs->blendFuncSeparate) + funcs->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); + else + funcs->blendFuncSeparate = qglfResolveBlendFuncSeparate; +} + +static void qglfResolveBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage) +{ + typedef void (QGLF_APIENTRYP type_glBufferData)(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->bufferData = (type_glBufferData) + context->getProcAddress(QLatin1String("glBufferData")); +#ifdef QT_OPENGL_ES + if (!funcs->bufferData) { + funcs->bufferData = (type_glBufferData) + context->getProcAddress(QLatin1String("glBufferDataOES")); + } +#endif + if (!funcs->bufferData) { + funcs->bufferData = (type_glBufferData) + context->getProcAddress(QLatin1String("glBufferDataEXT")); + } + if (!funcs->bufferData) { + funcs->bufferData = (type_glBufferData) + context->getProcAddress(QLatin1String("glBufferDataARB")); + } + + if (funcs->bufferData) + funcs->bufferData(target, size, data, usage); + else + funcs->bufferData = qglfResolveBufferData; +} + +static void qglfResolveBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data) +{ + typedef void (QGLF_APIENTRYP type_glBufferSubData)(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->bufferSubData = (type_glBufferSubData) + context->getProcAddress(QLatin1String("glBufferSubData")); +#ifdef QT_OPENGL_ES + if (!funcs->bufferSubData) { + funcs->bufferSubData = (type_glBufferSubData) + context->getProcAddress(QLatin1String("glBufferSubDataOES")); + } +#endif + if (!funcs->bufferSubData) { + funcs->bufferSubData = (type_glBufferSubData) + context->getProcAddress(QLatin1String("glBufferSubDataEXT")); + } + if (!funcs->bufferSubData) { + funcs->bufferSubData = (type_glBufferSubData) + context->getProcAddress(QLatin1String("glBufferSubDataARB")); + } + + if (funcs->bufferSubData) + funcs->bufferSubData(target, offset, size, data); + else + funcs->bufferSubData = qglfResolveBufferSubData; +} + +static GLenum qglfResolveCheckFramebufferStatus(GLenum target) +{ + typedef GLenum (QGLF_APIENTRYP type_glCheckFramebufferStatus)(GLenum target); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus) + context->getProcAddress(QLatin1String("glCheckFramebufferStatus")); +#ifdef QT_OPENGL_ES + if (!funcs->checkFramebufferStatus) { + funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus) + context->getProcAddress(QLatin1String("glCheckFramebufferStatusOES")); + } +#endif + if (!funcs->checkFramebufferStatus) { + funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus) + context->getProcAddress(QLatin1String("glCheckFramebufferStatusEXT")); + } + if (!funcs->checkFramebufferStatus) { + funcs->checkFramebufferStatus = (type_glCheckFramebufferStatus) + context->getProcAddress(QLatin1String("glCheckFramebufferStatusARB")); + } + + if (funcs->checkFramebufferStatus) + return funcs->checkFramebufferStatus(target); + funcs->checkFramebufferStatus = qglfResolveCheckFramebufferStatus; + return GLenum(0); +} + +static void qglfResolveCompileShader(GLuint shader) +{ + typedef void (QGLF_APIENTRYP type_glCompileShader)(GLuint shader); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->compileShader = (type_glCompileShader) + context->getProcAddress(QLatin1String("glCompileShader")); + if (!funcs->compileShader) { + funcs->compileShader = (type_glCompileShader) + context->getProcAddress(QLatin1String("glCompileShader")); + } + + if (funcs->compileShader) + funcs->compileShader(shader); + else + funcs->compileShader = qglfResolveCompileShader; +} + +static void qglfResolveCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) +{ + typedef void (QGLF_APIENTRYP type_glCompressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->compressedTexImage2D = (type_glCompressedTexImage2D) + context->getProcAddress(QLatin1String("glCompressedTexImage2D")); +#ifdef QT_OPENGL_ES + if (!funcs->compressedTexImage2D) { + funcs->compressedTexImage2D = (type_glCompressedTexImage2D) + context->getProcAddress(QLatin1String("glCompressedTexImage2DOES")); + } +#endif + if (!funcs->compressedTexImage2D) { + funcs->compressedTexImage2D = (type_glCompressedTexImage2D) + context->getProcAddress(QLatin1String("glCompressedTexImage2DEXT")); + } + if (!funcs->compressedTexImage2D) { + funcs->compressedTexImage2D = (type_glCompressedTexImage2D) + context->getProcAddress(QLatin1String("glCompressedTexImage2DARB")); + } + + if (funcs->compressedTexImage2D) + funcs->compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); + else + funcs->compressedTexImage2D = qglfResolveCompressedTexImage2D; +} + +static void qglfResolveCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) +{ + typedef void (QGLF_APIENTRYP type_glCompressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D) + context->getProcAddress(QLatin1String("glCompressedTexSubImage2D")); +#ifdef QT_OPENGL_ES + if (!funcs->compressedTexSubImage2D) { + funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D) + context->getProcAddress(QLatin1String("glCompressedTexSubImage2DOES")); + } +#endif + if (!funcs->compressedTexSubImage2D) { + funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D) + context->getProcAddress(QLatin1String("glCompressedTexSubImage2DEXT")); + } + if (!funcs->compressedTexSubImage2D) { + funcs->compressedTexSubImage2D = (type_glCompressedTexSubImage2D) + context->getProcAddress(QLatin1String("glCompressedTexSubImage2DARB")); + } + + if (funcs->compressedTexSubImage2D) + funcs->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); + else + funcs->compressedTexSubImage2D = qglfResolveCompressedTexSubImage2D; +} + +static GLuint qglfResolveCreateProgram() +{ + typedef GLuint (QGLF_APIENTRYP type_glCreateProgram)(); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->createProgram = (type_glCreateProgram) + context->getProcAddress(QLatin1String("glCreateProgram")); + if (!funcs->createProgram) { + funcs->createProgram = (type_glCreateProgram) + context->getProcAddress(QLatin1String("glCreateProgramObjectARB")); + } + + if (funcs->createProgram) + return funcs->createProgram(); + funcs->createProgram = qglfResolveCreateProgram; + return GLuint(0); +} + +static GLuint qglfResolveCreateShader(GLenum type) +{ + typedef GLuint (QGLF_APIENTRYP type_glCreateShader)(GLenum type); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->createShader = (type_glCreateShader) + context->getProcAddress(QLatin1String("glCreateShader")); + if (!funcs->createShader) { + funcs->createShader = (type_glCreateShader) + context->getProcAddress(QLatin1String("glCreateShaderObjectARB")); + } + + if (funcs->createShader) + return funcs->createShader(type); + funcs->createShader = qglfResolveCreateShader; + return GLuint(0); +} + +static void qglfResolveDeleteBuffers(GLsizei n, const GLuint* buffers) +{ + typedef void (QGLF_APIENTRYP type_glDeleteBuffers)(GLsizei n, const GLuint* buffers); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->deleteBuffers = (type_glDeleteBuffers) + context->getProcAddress(QLatin1String("glDeleteBuffers")); +#ifdef QT_OPENGL_ES + if (!funcs->deleteBuffers) { + funcs->deleteBuffers = (type_glDeleteBuffers) + context->getProcAddress(QLatin1String("glDeleteBuffersOES")); + } +#endif + if (!funcs->deleteBuffers) { + funcs->deleteBuffers = (type_glDeleteBuffers) + context->getProcAddress(QLatin1String("glDeleteBuffersEXT")); + } + if (!funcs->deleteBuffers) { + funcs->deleteBuffers = (type_glDeleteBuffers) + context->getProcAddress(QLatin1String("glDeleteBuffersARB")); + } + + if (funcs->deleteBuffers) + funcs->deleteBuffers(n, buffers); + else + funcs->deleteBuffers = qglfResolveDeleteBuffers; +} + +static void qglfResolveDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) +{ + typedef void (QGLF_APIENTRYP type_glDeleteFramebuffers)(GLsizei n, const GLuint* framebuffers); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->deleteFramebuffers = (type_glDeleteFramebuffers) + context->getProcAddress(QLatin1String("glDeleteFramebuffers")); +#ifdef QT_OPENGL_ES + if (!funcs->deleteFramebuffers) { + funcs->deleteFramebuffers = (type_glDeleteFramebuffers) + context->getProcAddress(QLatin1String("glDeleteFramebuffersOES")); + } +#endif + if (!funcs->deleteFramebuffers) { + funcs->deleteFramebuffers = (type_glDeleteFramebuffers) + context->getProcAddress(QLatin1String("glDeleteFramebuffersEXT")); + } + if (!funcs->deleteFramebuffers) { + funcs->deleteFramebuffers = (type_glDeleteFramebuffers) + context->getProcAddress(QLatin1String("glDeleteFramebuffersARB")); + } + + if (funcs->deleteFramebuffers) + funcs->deleteFramebuffers(n, framebuffers); + else + funcs->deleteFramebuffers = qglfResolveDeleteFramebuffers; +} + +static void qglfResolveDeleteProgram(GLuint program) +{ + typedef void (QGLF_APIENTRYP type_glDeleteProgram)(GLuint program); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->deleteProgram = (type_glDeleteProgram) + context->getProcAddress(QLatin1String("glDeleteProgram")); + if (!funcs->deleteProgram) { + funcs->deleteProgram = (type_glDeleteProgram) + context->getProcAddress(QLatin1String("glDeleteObjectARB")); + } + + if (funcs->deleteProgram) + funcs->deleteProgram(program); + else + funcs->deleteProgram = qglfResolveDeleteProgram; +} + +static void qglfResolveDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) +{ + typedef void (QGLF_APIENTRYP type_glDeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers) + context->getProcAddress(QLatin1String("glDeleteRenderbuffers")); +#ifdef QT_OPENGL_ES + if (!funcs->deleteRenderbuffers) { + funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers) + context->getProcAddress(QLatin1String("glDeleteRenderbuffersOES")); + } +#endif + if (!funcs->deleteRenderbuffers) { + funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers) + context->getProcAddress(QLatin1String("glDeleteRenderbuffersEXT")); + } + if (!funcs->deleteRenderbuffers) { + funcs->deleteRenderbuffers = (type_glDeleteRenderbuffers) + context->getProcAddress(QLatin1String("glDeleteRenderbuffersARB")); + } + + if (funcs->deleteRenderbuffers) + funcs->deleteRenderbuffers(n, renderbuffers); + else + funcs->deleteRenderbuffers = qglfResolveDeleteRenderbuffers; +} + +static void qglfResolveDeleteShader(GLuint shader) +{ + typedef void (QGLF_APIENTRYP type_glDeleteShader)(GLuint shader); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->deleteShader = (type_glDeleteShader) + context->getProcAddress(QLatin1String("glDeleteShader")); + if (!funcs->deleteShader) { + funcs->deleteShader = (type_glDeleteShader) + context->getProcAddress(QLatin1String("glDeleteObjectARB")); + } + + if (funcs->deleteShader) + funcs->deleteShader(shader); + else + funcs->deleteShader = qglfResolveDeleteShader; +} + +static void qglfResolveDetachShader(GLuint program, GLuint shader) +{ + typedef void (QGLF_APIENTRYP type_glDetachShader)(GLuint program, GLuint shader); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->detachShader = (type_glDetachShader) + context->getProcAddress(QLatin1String("glDetachShader")); + if (!funcs->detachShader) { + funcs->detachShader = (type_glDetachShader) + context->getProcAddress(QLatin1String("glDetachObjectARB")); + } + + if (funcs->detachShader) + funcs->detachShader(program, shader); + else + funcs->detachShader = qglfResolveDetachShader; +} + +static void qglfResolveDisableVertexAttribArray(GLuint index) +{ + typedef void (QGLF_APIENTRYP type_glDisableVertexAttribArray)(GLuint index); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->disableVertexAttribArray = (type_glDisableVertexAttribArray) + context->getProcAddress(QLatin1String("glDisableVertexAttribArray")); + if (!funcs->disableVertexAttribArray) { + funcs->disableVertexAttribArray = (type_glDisableVertexAttribArray) + context->getProcAddress(QLatin1String("glDisableVertexAttribArrayARB")); + } + + if (funcs->disableVertexAttribArray) + funcs->disableVertexAttribArray(index); + else + funcs->disableVertexAttribArray = qglfResolveDisableVertexAttribArray; +} + +static void qglfResolveEnableVertexAttribArray(GLuint index) +{ + typedef void (QGLF_APIENTRYP type_glEnableVertexAttribArray)(GLuint index); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->enableVertexAttribArray = (type_glEnableVertexAttribArray) + context->getProcAddress(QLatin1String("glEnableVertexAttribArray")); + if (!funcs->enableVertexAttribArray) { + funcs->enableVertexAttribArray = (type_glEnableVertexAttribArray) + context->getProcAddress(QLatin1String("glEnableVertexAttribArrayARB")); + } + + if (funcs->enableVertexAttribArray) + funcs->enableVertexAttribArray(index); + else + funcs->enableVertexAttribArray = qglfResolveEnableVertexAttribArray; +} + +static void qglfResolveFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + typedef void (QGLF_APIENTRYP type_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer) + context->getProcAddress(QLatin1String("glFramebufferRenderbuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->framebufferRenderbuffer) { + funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer) + context->getProcAddress(QLatin1String("glFramebufferRenderbufferOES")); + } +#endif + if (!funcs->framebufferRenderbuffer) { + funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer) + context->getProcAddress(QLatin1String("glFramebufferRenderbufferEXT")); + } + if (!funcs->framebufferRenderbuffer) { + funcs->framebufferRenderbuffer = (type_glFramebufferRenderbuffer) + context->getProcAddress(QLatin1String("glFramebufferRenderbufferARB")); + } + + if (funcs->framebufferRenderbuffer) + funcs->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); + else + funcs->framebufferRenderbuffer = qglfResolveFramebufferRenderbuffer; +} + +static void qglfResolveFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + typedef void (QGLF_APIENTRYP type_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->framebufferTexture2D = (type_glFramebufferTexture2D) + context->getProcAddress(QLatin1String("glFramebufferTexture2D")); +#ifdef QT_OPENGL_ES + if (!funcs->framebufferTexture2D) { + funcs->framebufferTexture2D = (type_glFramebufferTexture2D) + context->getProcAddress(QLatin1String("glFramebufferTexture2DOES")); + } +#endif + if (!funcs->framebufferTexture2D) { + funcs->framebufferTexture2D = (type_glFramebufferTexture2D) + context->getProcAddress(QLatin1String("glFramebufferTexture2DEXT")); + } + if (!funcs->framebufferTexture2D) { + funcs->framebufferTexture2D = (type_glFramebufferTexture2D) + context->getProcAddress(QLatin1String("glFramebufferTexture2DARB")); + } + + if (funcs->framebufferTexture2D) + funcs->framebufferTexture2D(target, attachment, textarget, texture, level); + else + funcs->framebufferTexture2D = qglfResolveFramebufferTexture2D; +} + +static void qglfResolveGenBuffers(GLsizei n, GLuint* buffers) +{ + typedef void (QGLF_APIENTRYP type_glGenBuffers)(GLsizei n, GLuint* buffers); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->genBuffers = (type_glGenBuffers) + context->getProcAddress(QLatin1String("glGenBuffers")); +#ifdef QT_OPENGL_ES + if (!funcs->genBuffers) { + funcs->genBuffers = (type_glGenBuffers) + context->getProcAddress(QLatin1String("glGenBuffersOES")); + } +#endif + if (!funcs->genBuffers) { + funcs->genBuffers = (type_glGenBuffers) + context->getProcAddress(QLatin1String("glGenBuffersEXT")); + } + if (!funcs->genBuffers) { + funcs->genBuffers = (type_glGenBuffers) + context->getProcAddress(QLatin1String("glGenBuffersARB")); + } + + if (funcs->genBuffers) + funcs->genBuffers(n, buffers); + else + funcs->genBuffers = qglfResolveGenBuffers; +} + +static void qglfResolveGenerateMipmap(GLenum target) +{ + typedef void (QGLF_APIENTRYP type_glGenerateMipmap)(GLenum target); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->generateMipmap = (type_glGenerateMipmap) + context->getProcAddress(QLatin1String("glGenerateMipmap")); +#ifdef QT_OPENGL_ES + if (!funcs->generateMipmap) { + funcs->generateMipmap = (type_glGenerateMipmap) + context->getProcAddress(QLatin1String("glGenerateMipmapOES")); + } +#endif + if (!funcs->generateMipmap) { + funcs->generateMipmap = (type_glGenerateMipmap) + context->getProcAddress(QLatin1String("glGenerateMipmapEXT")); + } + if (!funcs->generateMipmap) { + funcs->generateMipmap = (type_glGenerateMipmap) + context->getProcAddress(QLatin1String("glGenerateMipmapARB")); + } + + if (funcs->generateMipmap) + funcs->generateMipmap(target); + else + funcs->generateMipmap = qglfResolveGenerateMipmap; +} + +static void qglfResolveGenFramebuffers(GLsizei n, GLuint* framebuffers) +{ + typedef void (QGLF_APIENTRYP type_glGenFramebuffers)(GLsizei n, GLuint* framebuffers); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->genFramebuffers = (type_glGenFramebuffers) + context->getProcAddress(QLatin1String("glGenFramebuffers")); +#ifdef QT_OPENGL_ES + if (!funcs->genFramebuffers) { + funcs->genFramebuffers = (type_glGenFramebuffers) + context->getProcAddress(QLatin1String("glGenFramebuffersOES")); + } +#endif + if (!funcs->genFramebuffers) { + funcs->genFramebuffers = (type_glGenFramebuffers) + context->getProcAddress(QLatin1String("glGenFramebuffersEXT")); + } + if (!funcs->genFramebuffers) { + funcs->genFramebuffers = (type_glGenFramebuffers) + context->getProcAddress(QLatin1String("glGenFramebuffersARB")); + } + + if (funcs->genFramebuffers) + funcs->genFramebuffers(n, framebuffers); + else + funcs->genFramebuffers = qglfResolveGenFramebuffers; +} + +static void qglfResolveGenRenderbuffers(GLsizei n, GLuint* renderbuffers) +{ + typedef void (QGLF_APIENTRYP type_glGenRenderbuffers)(GLsizei n, GLuint* renderbuffers); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->genRenderbuffers = (type_glGenRenderbuffers) + context->getProcAddress(QLatin1String("glGenRenderbuffers")); +#ifdef QT_OPENGL_ES + if (!funcs->genRenderbuffers) { + funcs->genRenderbuffers = (type_glGenRenderbuffers) + context->getProcAddress(QLatin1String("glGenRenderbuffersOES")); + } +#endif + if (!funcs->genRenderbuffers) { + funcs->genRenderbuffers = (type_glGenRenderbuffers) + context->getProcAddress(QLatin1String("glGenRenderbuffersEXT")); + } + if (!funcs->genRenderbuffers) { + funcs->genRenderbuffers = (type_glGenRenderbuffers) + context->getProcAddress(QLatin1String("glGenRenderbuffersARB")); + } + + if (funcs->genRenderbuffers) + funcs->genRenderbuffers(n, renderbuffers); + else + funcs->genRenderbuffers = qglfResolveGenRenderbuffers; +} + +static void qglfResolveGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +{ + typedef void (QGLF_APIENTRYP type_glGetActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getActiveAttrib = (type_glGetActiveAttrib) + context->getProcAddress(QLatin1String("glGetActiveAttrib")); + if (!funcs->getActiveAttrib) { + funcs->getActiveAttrib = (type_glGetActiveAttrib) + context->getProcAddress(QLatin1String("glGetActiveAttribARB")); + } + + if (funcs->getActiveAttrib) + funcs->getActiveAttrib(program, index, bufsize, length, size, type, name); + else + funcs->getActiveAttrib = qglfResolveGetActiveAttrib; +} + +static void qglfResolveGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +{ + typedef void (QGLF_APIENTRYP type_glGetActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getActiveUniform = (type_glGetActiveUniform) + context->getProcAddress(QLatin1String("glGetActiveUniform")); + if (!funcs->getActiveUniform) { + funcs->getActiveUniform = (type_glGetActiveUniform) + context->getProcAddress(QLatin1String("glGetActiveUniformARB")); + } + + if (funcs->getActiveUniform) + funcs->getActiveUniform(program, index, bufsize, length, size, type, name); + else + funcs->getActiveUniform = qglfResolveGetActiveUniform; +} + +static void qglfResolveGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +{ + typedef void (QGLF_APIENTRYP type_glGetAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getAttachedShaders = (type_glGetAttachedShaders) + context->getProcAddress(QLatin1String("glGetAttachedShaders")); + if (!funcs->getAttachedShaders) { + funcs->getAttachedShaders = (type_glGetAttachedShaders) + context->getProcAddress(QLatin1String("glGetAttachedObjectsARB")); + } + + if (funcs->getAttachedShaders) + funcs->getAttachedShaders(program, maxcount, count, shaders); + else + funcs->getAttachedShaders = qglfResolveGetAttachedShaders; +} + +static int qglfResolveGetAttribLocation(GLuint program, const char* name) +{ + typedef int (QGLF_APIENTRYP type_glGetAttribLocation)(GLuint program, const char* name); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getAttribLocation = (type_glGetAttribLocation) + context->getProcAddress(QLatin1String("glGetAttribLocation")); + if (!funcs->getAttribLocation) { + funcs->getAttribLocation = (type_glGetAttribLocation) + context->getProcAddress(QLatin1String("glGetAttribLocationARB")); + } + + if (funcs->getAttribLocation) + return funcs->getAttribLocation(program, name); + funcs->getAttribLocation = qglfResolveGetAttribLocation; + return int(0); +} + +static void qglfResolveGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetBufferParameteriv)(GLenum target, GLenum pname, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getBufferParameteriv = (type_glGetBufferParameteriv) + context->getProcAddress(QLatin1String("glGetBufferParameteriv")); +#ifdef QT_OPENGL_ES + if (!funcs->getBufferParameteriv) { + funcs->getBufferParameteriv = (type_glGetBufferParameteriv) + context->getProcAddress(QLatin1String("glGetBufferParameterivOES")); + } +#endif + if (!funcs->getBufferParameteriv) { + funcs->getBufferParameteriv = (type_glGetBufferParameteriv) + context->getProcAddress(QLatin1String("glGetBufferParameterivEXT")); + } + if (!funcs->getBufferParameteriv) { + funcs->getBufferParameteriv = (type_glGetBufferParameteriv) + context->getProcAddress(QLatin1String("glGetBufferParameterivARB")); + } + + if (funcs->getBufferParameteriv) + funcs->getBufferParameteriv(target, pname, params); + else + funcs->getBufferParameteriv = qglfResolveGetBufferParameteriv; +} + +static void qglfResolveGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv) + context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameteriv")); +#ifdef QT_OPENGL_ES + if (!funcs->getFramebufferAttachmentParameteriv) { + funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv) + context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivOES")); + } +#endif + if (!funcs->getFramebufferAttachmentParameteriv) { + funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv) + context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivEXT")); + } + if (!funcs->getFramebufferAttachmentParameteriv) { + funcs->getFramebufferAttachmentParameteriv = (type_glGetFramebufferAttachmentParameteriv) + context->getProcAddress(QLatin1String("glGetFramebufferAttachmentParameterivARB")); + } + + if (funcs->getFramebufferAttachmentParameteriv) + funcs->getFramebufferAttachmentParameteriv(target, attachment, pname, params); + else + funcs->getFramebufferAttachmentParameteriv = qglfResolveGetFramebufferAttachmentParameteriv; +} + +static void qglfResolveGetProgramiv(GLuint program, GLenum pname, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetProgramiv)(GLuint program, GLenum pname, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getProgramiv = (type_glGetProgramiv) + context->getProcAddress(QLatin1String("glGetProgramiv")); + if (!funcs->getProgramiv) { + funcs->getProgramiv = (type_glGetProgramiv) + context->getProcAddress(QLatin1String("glGetObjectParameterivARB")); + } + + if (funcs->getProgramiv) + funcs->getProgramiv(program, pname, params); + else + funcs->getProgramiv = qglfResolveGetProgramiv; +} + +static void qglfResolveGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) +{ + typedef void (QGLF_APIENTRYP type_glGetProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getProgramInfoLog = (type_glGetProgramInfoLog) + context->getProcAddress(QLatin1String("glGetProgramInfoLog")); + if (!funcs->getProgramInfoLog) { + funcs->getProgramInfoLog = (type_glGetProgramInfoLog) + context->getProcAddress(QLatin1String("glGetInfoLogARB")); + } + + if (funcs->getProgramInfoLog) + funcs->getProgramInfoLog(program, bufsize, length, infolog); + else + funcs->getProgramInfoLog = qglfResolveGetProgramInfoLog; +} + +static void qglfResolveGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv) + context->getProcAddress(QLatin1String("glGetRenderbufferParameteriv")); +#ifdef QT_OPENGL_ES + if (!funcs->getRenderbufferParameteriv) { + funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv) + context->getProcAddress(QLatin1String("glGetRenderbufferParameterivOES")); + } +#endif + if (!funcs->getRenderbufferParameteriv) { + funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv) + context->getProcAddress(QLatin1String("glGetRenderbufferParameterivEXT")); + } + if (!funcs->getRenderbufferParameteriv) { + funcs->getRenderbufferParameteriv = (type_glGetRenderbufferParameteriv) + context->getProcAddress(QLatin1String("glGetRenderbufferParameterivARB")); + } + + if (funcs->getRenderbufferParameteriv) + funcs->getRenderbufferParameteriv(target, pname, params); + else + funcs->getRenderbufferParameteriv = qglfResolveGetRenderbufferParameteriv; +} + +static void qglfResolveGetShaderiv(GLuint shader, GLenum pname, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetShaderiv)(GLuint shader, GLenum pname, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getShaderiv = (type_glGetShaderiv) + context->getProcAddress(QLatin1String("glGetShaderiv")); + if (!funcs->getShaderiv) { + funcs->getShaderiv = (type_glGetShaderiv) + context->getProcAddress(QLatin1String("glGetObjectParameterivARB")); + } + + if (funcs->getShaderiv) + funcs->getShaderiv(shader, pname, params); + else + funcs->getShaderiv = qglfResolveGetShaderiv; +} + +static void qglfResolveGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) +{ + typedef void (QGLF_APIENTRYP type_glGetShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getShaderInfoLog = (type_glGetShaderInfoLog) + context->getProcAddress(QLatin1String("glGetShaderInfoLog")); + if (!funcs->getShaderInfoLog) { + funcs->getShaderInfoLog = (type_glGetShaderInfoLog) + context->getProcAddress(QLatin1String("glGetInfoLogARB")); + } + + if (funcs->getShaderInfoLog) + funcs->getShaderInfoLog(shader, bufsize, length, infolog); + else + funcs->getShaderInfoLog = qglfResolveGetShaderInfoLog; +} + +static void qglfSpecialGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ + Q_UNUSED(shadertype); + Q_UNUSED(precisiontype); + range[0] = range[1] = precision[0] = 0; +} + +static void qglfResolveGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ + typedef void (QGLF_APIENTRYP type_glGetShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat) + context->getProcAddress(QLatin1String("glGetShaderPrecisionFormat")); +#ifdef QT_OPENGL_ES + if (!funcs->getShaderPrecisionFormat) { + funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat) + context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatOES")); + } +#endif + if (!funcs->getShaderPrecisionFormat) { + funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat) + context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatEXT")); + } + if (!funcs->getShaderPrecisionFormat) { + funcs->getShaderPrecisionFormat = (type_glGetShaderPrecisionFormat) + context->getProcAddress(QLatin1String("glGetShaderPrecisionFormatARB")); + } + + if (!funcs->getShaderPrecisionFormat) + funcs->getShaderPrecisionFormat = qglfSpecialGetShaderPrecisionFormat; + + funcs->getShaderPrecisionFormat(shadertype, precisiontype, range, precision); +} + +static void qglfResolveGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) +{ + typedef void (QGLF_APIENTRYP type_glGetShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getShaderSource = (type_glGetShaderSource) + context->getProcAddress(QLatin1String("glGetShaderSource")); + if (!funcs->getShaderSource) { + funcs->getShaderSource = (type_glGetShaderSource) + context->getProcAddress(QLatin1String("glGetShaderSourceARB")); + } + + if (funcs->getShaderSource) + funcs->getShaderSource(shader, bufsize, length, source); + else + funcs->getShaderSource = qglfResolveGetShaderSource; +} + +static void qglfResolveGetUniformfv(GLuint program, GLint location, GLfloat* params) +{ + typedef void (QGLF_APIENTRYP type_glGetUniformfv)(GLuint program, GLint location, GLfloat* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getUniformfv = (type_glGetUniformfv) + context->getProcAddress(QLatin1String("glGetUniformfv")); + if (!funcs->getUniformfv) { + funcs->getUniformfv = (type_glGetUniformfv) + context->getProcAddress(QLatin1String("glGetUniformfvARB")); + } + + if (funcs->getUniformfv) + funcs->getUniformfv(program, location, params); + else + funcs->getUniformfv = qglfResolveGetUniformfv; +} + +static void qglfResolveGetUniformiv(GLuint program, GLint location, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetUniformiv)(GLuint program, GLint location, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getUniformiv = (type_glGetUniformiv) + context->getProcAddress(QLatin1String("glGetUniformiv")); + if (!funcs->getUniformiv) { + funcs->getUniformiv = (type_glGetUniformiv) + context->getProcAddress(QLatin1String("glGetUniformivARB")); + } + + if (funcs->getUniformiv) + funcs->getUniformiv(program, location, params); + else + funcs->getUniformiv = qglfResolveGetUniformiv; +} + +static int qglfResolveGetUniformLocation(GLuint program, const char* name) +{ + typedef int (QGLF_APIENTRYP type_glGetUniformLocation)(GLuint program, const char* name); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getUniformLocation = (type_glGetUniformLocation) + context->getProcAddress(QLatin1String("glGetUniformLocation")); + if (!funcs->getUniformLocation) { + funcs->getUniformLocation = (type_glGetUniformLocation) + context->getProcAddress(QLatin1String("glGetUniformLocationARB")); + } + + if (funcs->getUniformLocation) + return funcs->getUniformLocation(program, name); + funcs->getUniformLocation = qglfResolveGetUniformLocation; + return int(0); +} + +static void qglfResolveGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) +{ + typedef void (QGLF_APIENTRYP type_glGetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getVertexAttribfv = (type_glGetVertexAttribfv) + context->getProcAddress(QLatin1String("glGetVertexAttribfv")); + if (!funcs->getVertexAttribfv) { + funcs->getVertexAttribfv = (type_glGetVertexAttribfv) + context->getProcAddress(QLatin1String("glGetVertexAttribfvARB")); + } + + if (funcs->getVertexAttribfv) + funcs->getVertexAttribfv(index, pname, params); + else + funcs->getVertexAttribfv = qglfResolveGetVertexAttribfv; +} + +static void qglfResolveGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) +{ + typedef void (QGLF_APIENTRYP type_glGetVertexAttribiv)(GLuint index, GLenum pname, GLint* params); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getVertexAttribiv = (type_glGetVertexAttribiv) + context->getProcAddress(QLatin1String("glGetVertexAttribiv")); + if (!funcs->getVertexAttribiv) { + funcs->getVertexAttribiv = (type_glGetVertexAttribiv) + context->getProcAddress(QLatin1String("glGetVertexAttribivARB")); + } + + if (funcs->getVertexAttribiv) + funcs->getVertexAttribiv(index, pname, params); + else + funcs->getVertexAttribiv = qglfResolveGetVertexAttribiv; +} + +static void qglfResolveGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) +{ + typedef void (QGLF_APIENTRYP type_glGetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->getVertexAttribPointerv = (type_glGetVertexAttribPointerv) + context->getProcAddress(QLatin1String("glGetVertexAttribPointerv")); + if (!funcs->getVertexAttribPointerv) { + funcs->getVertexAttribPointerv = (type_glGetVertexAttribPointerv) + context->getProcAddress(QLatin1String("glGetVertexAttribPointervARB")); + } + + if (funcs->getVertexAttribPointerv) + funcs->getVertexAttribPointerv(index, pname, pointer); + else + funcs->getVertexAttribPointerv = qglfResolveGetVertexAttribPointerv; +} + +static GLboolean qglfResolveIsBuffer(GLuint buffer) +{ + typedef GLboolean (QGLF_APIENTRYP type_glIsBuffer)(GLuint buffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->isBuffer = (type_glIsBuffer) + context->getProcAddress(QLatin1String("glIsBuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->isBuffer) { + funcs->isBuffer = (type_glIsBuffer) + context->getProcAddress(QLatin1String("glIsBufferOES")); + } +#endif + if (!funcs->isBuffer) { + funcs->isBuffer = (type_glIsBuffer) + context->getProcAddress(QLatin1String("glIsBufferEXT")); + } + if (!funcs->isBuffer) { + funcs->isBuffer = (type_glIsBuffer) + context->getProcAddress(QLatin1String("glIsBufferARB")); + } + + if (funcs->isBuffer) + return funcs->isBuffer(buffer); + funcs->isBuffer = qglfResolveIsBuffer; + return GLboolean(0); +} + +static GLboolean qglfResolveIsFramebuffer(GLuint framebuffer) +{ + typedef GLboolean (QGLF_APIENTRYP type_glIsFramebuffer)(GLuint framebuffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->isFramebuffer = (type_glIsFramebuffer) + context->getProcAddress(QLatin1String("glIsFramebuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->isFramebuffer) { + funcs->isFramebuffer = (type_glIsFramebuffer) + context->getProcAddress(QLatin1String("glIsFramebufferOES")); + } +#endif + if (!funcs->isFramebuffer) { + funcs->isFramebuffer = (type_glIsFramebuffer) + context->getProcAddress(QLatin1String("glIsFramebufferEXT")); + } + if (!funcs->isFramebuffer) { + funcs->isFramebuffer = (type_glIsFramebuffer) + context->getProcAddress(QLatin1String("glIsFramebufferARB")); + } + + if (funcs->isFramebuffer) + return funcs->isFramebuffer(framebuffer); + funcs->isFramebuffer = qglfResolveIsFramebuffer; + return GLboolean(0); +} + +static GLboolean qglfSpecialIsProgram(GLuint program) +{ + return program != 0; +} + +static GLboolean qglfResolveIsProgram(GLuint program) +{ + typedef GLboolean (QGLF_APIENTRYP type_glIsProgram)(GLuint program); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->isProgram = (type_glIsProgram) + context->getProcAddress(QLatin1String("glIsProgram")); + if (!funcs->isProgram) { + funcs->isProgram = (type_glIsProgram) + context->getProcAddress(QLatin1String("glIsProgramARB")); + } + + if (!funcs->isProgram) + funcs->isProgram = qglfSpecialIsProgram; + + return funcs->isProgram(program); +} + +static GLboolean qglfResolveIsRenderbuffer(GLuint renderbuffer) +{ + typedef GLboolean (QGLF_APIENTRYP type_glIsRenderbuffer)(GLuint renderbuffer); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->isRenderbuffer = (type_glIsRenderbuffer) + context->getProcAddress(QLatin1String("glIsRenderbuffer")); +#ifdef QT_OPENGL_ES + if (!funcs->isRenderbuffer) { + funcs->isRenderbuffer = (type_glIsRenderbuffer) + context->getProcAddress(QLatin1String("glIsRenderbufferOES")); + } +#endif + if (!funcs->isRenderbuffer) { + funcs->isRenderbuffer = (type_glIsRenderbuffer) + context->getProcAddress(QLatin1String("glIsRenderbufferEXT")); + } + if (!funcs->isRenderbuffer) { + funcs->isRenderbuffer = (type_glIsRenderbuffer) + context->getProcAddress(QLatin1String("glIsRenderbufferARB")); + } + + if (funcs->isRenderbuffer) + return funcs->isRenderbuffer(renderbuffer); + funcs->isRenderbuffer = qglfResolveIsRenderbuffer; + return GLboolean(0); +} + +static GLboolean qglfSpecialIsShader(GLuint shader) +{ + return shader != 0; +} + +static GLboolean qglfResolveIsShader(GLuint shader) +{ + typedef GLboolean (QGLF_APIENTRYP type_glIsShader)(GLuint shader); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->isShader = (type_glIsShader) + context->getProcAddress(QLatin1String("glIsShader")); + if (!funcs->isShader) { + funcs->isShader = (type_glIsShader) + context->getProcAddress(QLatin1String("glIsShaderARB")); + } + + if (!funcs->isShader) + funcs->isShader = qglfSpecialIsShader; + + return funcs->isShader(shader); +} + +static void qglfResolveLinkProgram(GLuint program) +{ + typedef void (QGLF_APIENTRYP type_glLinkProgram)(GLuint program); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->linkProgram = (type_glLinkProgram) + context->getProcAddress(QLatin1String("glLinkProgram")); + if (!funcs->linkProgram) { + funcs->linkProgram = (type_glLinkProgram) + context->getProcAddress(QLatin1String("glLinkProgramARB")); + } + + if (funcs->linkProgram) + funcs->linkProgram(program); + else + funcs->linkProgram = qglfResolveLinkProgram; +} + +static void qglfSpecialReleaseShaderCompiler() +{ +} + +static void qglfResolveReleaseShaderCompiler() +{ + typedef void (QGLF_APIENTRYP type_glReleaseShaderCompiler)(); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->releaseShaderCompiler = (type_glReleaseShaderCompiler) + context->getProcAddress(QLatin1String("glReleaseShaderCompiler")); + if (!funcs->releaseShaderCompiler) { + funcs->releaseShaderCompiler = (type_glReleaseShaderCompiler) + context->getProcAddress(QLatin1String("glReleaseShaderCompilerARB")); + } + + if (!funcs->releaseShaderCompiler) + funcs->releaseShaderCompiler = qglfSpecialReleaseShaderCompiler; + + funcs->releaseShaderCompiler(); +} + +static void qglfResolveRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + typedef void (QGLF_APIENTRYP type_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->renderbufferStorage = (type_glRenderbufferStorage) + context->getProcAddress(QLatin1String("glRenderbufferStorage")); +#ifdef QT_OPENGL_ES + if (!funcs->renderbufferStorage) { + funcs->renderbufferStorage = (type_glRenderbufferStorage) + context->getProcAddress(QLatin1String("glRenderbufferStorageOES")); + } +#endif + if (!funcs->renderbufferStorage) { + funcs->renderbufferStorage = (type_glRenderbufferStorage) + context->getProcAddress(QLatin1String("glRenderbufferStorageEXT")); + } + if (!funcs->renderbufferStorage) { + funcs->renderbufferStorage = (type_glRenderbufferStorage) + context->getProcAddress(QLatin1String("glRenderbufferStorageARB")); + } + + if (funcs->renderbufferStorage) + funcs->renderbufferStorage(target, internalformat, width, height); + else + funcs->renderbufferStorage = qglfResolveRenderbufferStorage; +} + +static void qglfResolveSampleCoverage(GLclampf value, GLboolean invert) +{ + typedef void (QGLF_APIENTRYP type_glSampleCoverage)(GLclampf value, GLboolean invert); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->sampleCoverage = (type_glSampleCoverage) + context->getProcAddress(QLatin1String("glSampleCoverage")); +#ifdef QT_OPENGL_ES + if (!funcs->sampleCoverage) { + funcs->sampleCoverage = (type_glSampleCoverage) + context->getProcAddress(QLatin1String("glSampleCoverageOES")); + } +#endif + if (!funcs->sampleCoverage) { + funcs->sampleCoverage = (type_glSampleCoverage) + context->getProcAddress(QLatin1String("glSampleCoverageEXT")); + } + if (!funcs->sampleCoverage) { + funcs->sampleCoverage = (type_glSampleCoverage) + context->getProcAddress(QLatin1String("glSampleCoverageARB")); + } + + if (funcs->sampleCoverage) + funcs->sampleCoverage(value, invert); + else + funcs->sampleCoverage = qglfResolveSampleCoverage; +} + +static void qglfResolveShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length) +{ + typedef void (QGLF_APIENTRYP type_glShaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->shaderBinary = (type_glShaderBinary) + context->getProcAddress(QLatin1String("glShaderBinary")); + if (!funcs->shaderBinary) { + funcs->shaderBinary = (type_glShaderBinary) + context->getProcAddress(QLatin1String("glShaderBinaryARB")); + } + + if (funcs->shaderBinary) + funcs->shaderBinary(n, shaders, binaryformat, binary, length); + else + funcs->shaderBinary = qglfResolveShaderBinary; +} + +static void qglfResolveShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) +{ + typedef void (QGLF_APIENTRYP type_glShaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->shaderSource = (type_glShaderSource) + context->getProcAddress(QLatin1String("glShaderSource")); + if (!funcs->shaderSource) { + funcs->shaderSource = (type_glShaderSource) + context->getProcAddress(QLatin1String("glShaderSourceARB")); + } + + if (funcs->shaderSource) + funcs->shaderSource(shader, count, string, length); + else + funcs->shaderSource = qglfResolveShaderSource; +} + +static void qglfResolveStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + typedef void (QGLF_APIENTRYP type_glStencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->stencilFuncSeparate = (type_glStencilFuncSeparate) + context->getProcAddress(QLatin1String("glStencilFuncSeparate")); +#ifdef QT_OPENGL_ES + if (!funcs->stencilFuncSeparate) { + funcs->stencilFuncSeparate = (type_glStencilFuncSeparate) + context->getProcAddress(QLatin1String("glStencilFuncSeparateOES")); + } +#endif + if (!funcs->stencilFuncSeparate) { + funcs->stencilFuncSeparate = (type_glStencilFuncSeparate) + context->getProcAddress(QLatin1String("glStencilFuncSeparateEXT")); + } + if (!funcs->stencilFuncSeparate) { + funcs->stencilFuncSeparate = (type_glStencilFuncSeparate) + context->getProcAddress(QLatin1String("glStencilFuncSeparateARB")); + } + + if (funcs->stencilFuncSeparate) + funcs->stencilFuncSeparate(face, func, ref, mask); + else + funcs->stencilFuncSeparate = qglfResolveStencilFuncSeparate; +} + +static void qglfResolveStencilMaskSeparate(GLenum face, GLuint mask) +{ + typedef void (QGLF_APIENTRYP type_glStencilMaskSeparate)(GLenum face, GLuint mask); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->stencilMaskSeparate = (type_glStencilMaskSeparate) + context->getProcAddress(QLatin1String("glStencilMaskSeparate")); +#ifdef QT_OPENGL_ES + if (!funcs->stencilMaskSeparate) { + funcs->stencilMaskSeparate = (type_glStencilMaskSeparate) + context->getProcAddress(QLatin1String("glStencilMaskSeparateOES")); + } +#endif + if (!funcs->stencilMaskSeparate) { + funcs->stencilMaskSeparate = (type_glStencilMaskSeparate) + context->getProcAddress(QLatin1String("glStencilMaskSeparateEXT")); + } + if (!funcs->stencilMaskSeparate) { + funcs->stencilMaskSeparate = (type_glStencilMaskSeparate) + context->getProcAddress(QLatin1String("glStencilMaskSeparateARB")); + } + + if (funcs->stencilMaskSeparate) + funcs->stencilMaskSeparate(face, mask); + else + funcs->stencilMaskSeparate = qglfResolveStencilMaskSeparate; +} + +static void qglfResolveStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + typedef void (QGLF_APIENTRYP type_glStencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->stencilOpSeparate = (type_glStencilOpSeparate) + context->getProcAddress(QLatin1String("glStencilOpSeparate")); +#ifdef QT_OPENGL_ES + if (!funcs->stencilOpSeparate) { + funcs->stencilOpSeparate = (type_glStencilOpSeparate) + context->getProcAddress(QLatin1String("glStencilOpSeparateOES")); + } +#endif + if (!funcs->stencilOpSeparate) { + funcs->stencilOpSeparate = (type_glStencilOpSeparate) + context->getProcAddress(QLatin1String("glStencilOpSeparateEXT")); + } + if (!funcs->stencilOpSeparate) { + funcs->stencilOpSeparate = (type_glStencilOpSeparate) + context->getProcAddress(QLatin1String("glStencilOpSeparateARB")); + } + + if (funcs->stencilOpSeparate) + funcs->stencilOpSeparate(face, fail, zfail, zpass); + else + funcs->stencilOpSeparate = qglfResolveStencilOpSeparate; +} + +static void qglfResolveUniform1f(GLint location, GLfloat x) +{ + typedef void (QGLF_APIENTRYP type_glUniform1f)(GLint location, GLfloat x); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform1f = (type_glUniform1f) + context->getProcAddress(QLatin1String("glUniform1f")); + if (!funcs->uniform1f) { + funcs->uniform1f = (type_glUniform1f) + context->getProcAddress(QLatin1String("glUniform1fARB")); + } + + if (funcs->uniform1f) + funcs->uniform1f(location, x); + else + funcs->uniform1f = qglfResolveUniform1f; +} + +static void qglfResolveUniform1fv(GLint location, GLsizei count, const GLfloat* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform1fv)(GLint location, GLsizei count, const GLfloat* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform1fv = (type_glUniform1fv) + context->getProcAddress(QLatin1String("glUniform1fv")); + if (!funcs->uniform1fv) { + funcs->uniform1fv = (type_glUniform1fv) + context->getProcAddress(QLatin1String("glUniform1fvARB")); + } + + if (funcs->uniform1fv) + funcs->uniform1fv(location, count, v); + else + funcs->uniform1fv = qglfResolveUniform1fv; +} + +static void qglfResolveUniform1i(GLint location, GLint x) +{ + typedef void (QGLF_APIENTRYP type_glUniform1i)(GLint location, GLint x); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform1i = (type_glUniform1i) + context->getProcAddress(QLatin1String("glUniform1i")); + if (!funcs->uniform1i) { + funcs->uniform1i = (type_glUniform1i) + context->getProcAddress(QLatin1String("glUniform1iARB")); + } + + if (funcs->uniform1i) + funcs->uniform1i(location, x); + else + funcs->uniform1i = qglfResolveUniform1i; +} + +static void qglfResolveUniform1iv(GLint location, GLsizei count, const GLint* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform1iv)(GLint location, GLsizei count, const GLint* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform1iv = (type_glUniform1iv) + context->getProcAddress(QLatin1String("glUniform1iv")); + if (!funcs->uniform1iv) { + funcs->uniform1iv = (type_glUniform1iv) + context->getProcAddress(QLatin1String("glUniform1ivARB")); + } + + if (funcs->uniform1iv) + funcs->uniform1iv(location, count, v); + else + funcs->uniform1iv = qglfResolveUniform1iv; +} + +static void qglfResolveUniform2f(GLint location, GLfloat x, GLfloat y) +{ + typedef void (QGLF_APIENTRYP type_glUniform2f)(GLint location, GLfloat x, GLfloat y); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform2f = (type_glUniform2f) + context->getProcAddress(QLatin1String("glUniform2f")); + if (!funcs->uniform2f) { + funcs->uniform2f = (type_glUniform2f) + context->getProcAddress(QLatin1String("glUniform2fARB")); + } + + if (funcs->uniform2f) + funcs->uniform2f(location, x, y); + else + funcs->uniform2f = qglfResolveUniform2f; +} + +static void qglfResolveUniform2fv(GLint location, GLsizei count, const GLfloat* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform2fv)(GLint location, GLsizei count, const GLfloat* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform2fv = (type_glUniform2fv) + context->getProcAddress(QLatin1String("glUniform2fv")); + if (!funcs->uniform2fv) { + funcs->uniform2fv = (type_glUniform2fv) + context->getProcAddress(QLatin1String("glUniform2fvARB")); + } + + if (funcs->uniform2fv) + funcs->uniform2fv(location, count, v); + else + funcs->uniform2fv = qglfResolveUniform2fv; +} + +static void qglfResolveUniform2i(GLint location, GLint x, GLint y) +{ + typedef void (QGLF_APIENTRYP type_glUniform2i)(GLint location, GLint x, GLint y); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform2i = (type_glUniform2i) + context->getProcAddress(QLatin1String("glUniform2i")); + if (!funcs->uniform2i) { + funcs->uniform2i = (type_glUniform2i) + context->getProcAddress(QLatin1String("glUniform2iARB")); + } + + if (funcs->uniform2i) + funcs->uniform2i(location, x, y); + else + funcs->uniform2i = qglfResolveUniform2i; +} + +static void qglfResolveUniform2iv(GLint location, GLsizei count, const GLint* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform2iv)(GLint location, GLsizei count, const GLint* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform2iv = (type_glUniform2iv) + context->getProcAddress(QLatin1String("glUniform2iv")); + if (!funcs->uniform2iv) { + funcs->uniform2iv = (type_glUniform2iv) + context->getProcAddress(QLatin1String("glUniform2ivARB")); + } + + if (funcs->uniform2iv) + funcs->uniform2iv(location, count, v); + else + funcs->uniform2iv = qglfResolveUniform2iv; +} + +static void qglfResolveUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ + typedef void (QGLF_APIENTRYP type_glUniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform3f = (type_glUniform3f) + context->getProcAddress(QLatin1String("glUniform3f")); + if (!funcs->uniform3f) { + funcs->uniform3f = (type_glUniform3f) + context->getProcAddress(QLatin1String("glUniform3fARB")); + } + + if (funcs->uniform3f) + funcs->uniform3f(location, x, y, z); + else + funcs->uniform3f = qglfResolveUniform3f; +} + +static void qglfResolveUniform3fv(GLint location, GLsizei count, const GLfloat* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform3fv)(GLint location, GLsizei count, const GLfloat* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform3fv = (type_glUniform3fv) + context->getProcAddress(QLatin1String("glUniform3fv")); + if (!funcs->uniform3fv) { + funcs->uniform3fv = (type_glUniform3fv) + context->getProcAddress(QLatin1String("glUniform3fvARB")); + } + + if (funcs->uniform3fv) + funcs->uniform3fv(location, count, v); + else + funcs->uniform3fv = qglfResolveUniform3fv; +} + +static void qglfResolveUniform3i(GLint location, GLint x, GLint y, GLint z) +{ + typedef void (QGLF_APIENTRYP type_glUniform3i)(GLint location, GLint x, GLint y, GLint z); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform3i = (type_glUniform3i) + context->getProcAddress(QLatin1String("glUniform3i")); + if (!funcs->uniform3i) { + funcs->uniform3i = (type_glUniform3i) + context->getProcAddress(QLatin1String("glUniform3iARB")); + } + + if (funcs->uniform3i) + funcs->uniform3i(location, x, y, z); + else + funcs->uniform3i = qglfResolveUniform3i; +} + +static void qglfResolveUniform3iv(GLint location, GLsizei count, const GLint* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform3iv)(GLint location, GLsizei count, const GLint* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform3iv = (type_glUniform3iv) + context->getProcAddress(QLatin1String("glUniform3iv")); + if (!funcs->uniform3iv) { + funcs->uniform3iv = (type_glUniform3iv) + context->getProcAddress(QLatin1String("glUniform3ivARB")); + } + + if (funcs->uniform3iv) + funcs->uniform3iv(location, count, v); + else + funcs->uniform3iv = qglfResolveUniform3iv; +} + +static void qglfResolveUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + typedef void (QGLF_APIENTRYP type_glUniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform4f = (type_glUniform4f) + context->getProcAddress(QLatin1String("glUniform4f")); + if (!funcs->uniform4f) { + funcs->uniform4f = (type_glUniform4f) + context->getProcAddress(QLatin1String("glUniform4fARB")); + } + + if (funcs->uniform4f) + funcs->uniform4f(location, x, y, z, w); + else + funcs->uniform4f = qglfResolveUniform4f; +} + +static void qglfResolveUniform4fv(GLint location, GLsizei count, const GLfloat* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform4fv)(GLint location, GLsizei count, const GLfloat* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform4fv = (type_glUniform4fv) + context->getProcAddress(QLatin1String("glUniform4fv")); + if (!funcs->uniform4fv) { + funcs->uniform4fv = (type_glUniform4fv) + context->getProcAddress(QLatin1String("glUniform4fvARB")); + } + + if (funcs->uniform4fv) + funcs->uniform4fv(location, count, v); + else + funcs->uniform4fv = qglfResolveUniform4fv; +} + +static void qglfResolveUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) +{ + typedef void (QGLF_APIENTRYP type_glUniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform4i = (type_glUniform4i) + context->getProcAddress(QLatin1String("glUniform4i")); + if (!funcs->uniform4i) { + funcs->uniform4i = (type_glUniform4i) + context->getProcAddress(QLatin1String("glUniform4iARB")); + } + + if (funcs->uniform4i) + funcs->uniform4i(location, x, y, z, w); + else + funcs->uniform4i = qglfResolveUniform4i; +} + +static void qglfResolveUniform4iv(GLint location, GLsizei count, const GLint* v) +{ + typedef void (QGLF_APIENTRYP type_glUniform4iv)(GLint location, GLsizei count, const GLint* v); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniform4iv = (type_glUniform4iv) + context->getProcAddress(QLatin1String("glUniform4iv")); + if (!funcs->uniform4iv) { + funcs->uniform4iv = (type_glUniform4iv) + context->getProcAddress(QLatin1String("glUniform4ivARB")); + } + + if (funcs->uniform4iv) + funcs->uniform4iv(location, count, v); + else + funcs->uniform4iv = qglfResolveUniform4iv; +} + +static void qglfResolveUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + typedef void (QGLF_APIENTRYP type_glUniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniformMatrix2fv = (type_glUniformMatrix2fv) + context->getProcAddress(QLatin1String("glUniformMatrix2fv")); + if (!funcs->uniformMatrix2fv) { + funcs->uniformMatrix2fv = (type_glUniformMatrix2fv) + context->getProcAddress(QLatin1String("glUniformMatrix2fvARB")); + } + + if (funcs->uniformMatrix2fv) + funcs->uniformMatrix2fv(location, count, transpose, value); + else + funcs->uniformMatrix2fv = qglfResolveUniformMatrix2fv; +} + +static void qglfResolveUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + typedef void (QGLF_APIENTRYP type_glUniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniformMatrix3fv = (type_glUniformMatrix3fv) + context->getProcAddress(QLatin1String("glUniformMatrix3fv")); + if (!funcs->uniformMatrix3fv) { + funcs->uniformMatrix3fv = (type_glUniformMatrix3fv) + context->getProcAddress(QLatin1String("glUniformMatrix3fvARB")); + } + + if (funcs->uniformMatrix3fv) + funcs->uniformMatrix3fv(location, count, transpose, value); + else + funcs->uniformMatrix3fv = qglfResolveUniformMatrix3fv; +} + +static void qglfResolveUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ + typedef void (QGLF_APIENTRYP type_glUniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->uniformMatrix4fv = (type_glUniformMatrix4fv) + context->getProcAddress(QLatin1String("glUniformMatrix4fv")); + if (!funcs->uniformMatrix4fv) { + funcs->uniformMatrix4fv = (type_glUniformMatrix4fv) + context->getProcAddress(QLatin1String("glUniformMatrix4fvARB")); + } + + if (funcs->uniformMatrix4fv) + funcs->uniformMatrix4fv(location, count, transpose, value); + else + funcs->uniformMatrix4fv = qglfResolveUniformMatrix4fv; +} + +static void qglfResolveUseProgram(GLuint program) +{ + typedef void (QGLF_APIENTRYP type_glUseProgram)(GLuint program); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->useProgram = (type_glUseProgram) + context->getProcAddress(QLatin1String("glUseProgram")); + if (!funcs->useProgram) { + funcs->useProgram = (type_glUseProgram) + context->getProcAddress(QLatin1String("glUseProgramObjectARB")); + } + + if (funcs->useProgram) + funcs->useProgram(program); + else + funcs->useProgram = qglfResolveUseProgram; +} + +static void qglfResolveValidateProgram(GLuint program) +{ + typedef void (QGLF_APIENTRYP type_glValidateProgram)(GLuint program); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->validateProgram = (type_glValidateProgram) + context->getProcAddress(QLatin1String("glValidateProgram")); + if (!funcs->validateProgram) { + funcs->validateProgram = (type_glValidateProgram) + context->getProcAddress(QLatin1String("glValidateProgramARB")); + } + + if (funcs->validateProgram) + funcs->validateProgram(program); + else + funcs->validateProgram = qglfResolveValidateProgram; +} + +static void qglfResolveVertexAttrib1f(GLuint indx, GLfloat x) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib1f)(GLuint indx, GLfloat x); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib1f = (type_glVertexAttrib1f) + context->getProcAddress(QLatin1String("glVertexAttrib1f")); + if (!funcs->vertexAttrib1f) { + funcs->vertexAttrib1f = (type_glVertexAttrib1f) + context->getProcAddress(QLatin1String("glVertexAttrib1fARB")); + } + + if (funcs->vertexAttrib1f) + funcs->vertexAttrib1f(indx, x); + else + funcs->vertexAttrib1f = qglfResolveVertexAttrib1f; +} + +static void qglfResolveVertexAttrib1fv(GLuint indx, const GLfloat* values) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib1fv)(GLuint indx, const GLfloat* values); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib1fv = (type_glVertexAttrib1fv) + context->getProcAddress(QLatin1String("glVertexAttrib1fv")); + if (!funcs->vertexAttrib1fv) { + funcs->vertexAttrib1fv = (type_glVertexAttrib1fv) + context->getProcAddress(QLatin1String("glVertexAttrib1fvARB")); + } + + if (funcs->vertexAttrib1fv) + funcs->vertexAttrib1fv(indx, values); + else + funcs->vertexAttrib1fv = qglfResolveVertexAttrib1fv; +} + +static void qglfResolveVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib2f = (type_glVertexAttrib2f) + context->getProcAddress(QLatin1String("glVertexAttrib2f")); + if (!funcs->vertexAttrib2f) { + funcs->vertexAttrib2f = (type_glVertexAttrib2f) + context->getProcAddress(QLatin1String("glVertexAttrib2fARB")); + } + + if (funcs->vertexAttrib2f) + funcs->vertexAttrib2f(indx, x, y); + else + funcs->vertexAttrib2f = qglfResolveVertexAttrib2f; +} + +static void qglfResolveVertexAttrib2fv(GLuint indx, const GLfloat* values) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib2fv)(GLuint indx, const GLfloat* values); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib2fv = (type_glVertexAttrib2fv) + context->getProcAddress(QLatin1String("glVertexAttrib2fv")); + if (!funcs->vertexAttrib2fv) { + funcs->vertexAttrib2fv = (type_glVertexAttrib2fv) + context->getProcAddress(QLatin1String("glVertexAttrib2fvARB")); + } + + if (funcs->vertexAttrib2fv) + funcs->vertexAttrib2fv(indx, values); + else + funcs->vertexAttrib2fv = qglfResolveVertexAttrib2fv; +} + +static void qglfResolveVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib3f = (type_glVertexAttrib3f) + context->getProcAddress(QLatin1String("glVertexAttrib3f")); + if (!funcs->vertexAttrib3f) { + funcs->vertexAttrib3f = (type_glVertexAttrib3f) + context->getProcAddress(QLatin1String("glVertexAttrib3fARB")); + } + + if (funcs->vertexAttrib3f) + funcs->vertexAttrib3f(indx, x, y, z); + else + funcs->vertexAttrib3f = qglfResolveVertexAttrib3f; +} + +static void qglfResolveVertexAttrib3fv(GLuint indx, const GLfloat* values) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib3fv)(GLuint indx, const GLfloat* values); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib3fv = (type_glVertexAttrib3fv) + context->getProcAddress(QLatin1String("glVertexAttrib3fv")); + if (!funcs->vertexAttrib3fv) { + funcs->vertexAttrib3fv = (type_glVertexAttrib3fv) + context->getProcAddress(QLatin1String("glVertexAttrib3fvARB")); + } + + if (funcs->vertexAttrib3fv) + funcs->vertexAttrib3fv(indx, values); + else + funcs->vertexAttrib3fv = qglfResolveVertexAttrib3fv; +} + +static void qglfResolveVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib4f = (type_glVertexAttrib4f) + context->getProcAddress(QLatin1String("glVertexAttrib4f")); + if (!funcs->vertexAttrib4f) { + funcs->vertexAttrib4f = (type_glVertexAttrib4f) + context->getProcAddress(QLatin1String("glVertexAttrib4fARB")); + } + + if (funcs->vertexAttrib4f) + funcs->vertexAttrib4f(indx, x, y, z, w); + else + funcs->vertexAttrib4f = qglfResolveVertexAttrib4f; +} + +static void qglfResolveVertexAttrib4fv(GLuint indx, const GLfloat* values) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttrib4fv)(GLuint indx, const GLfloat* values); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttrib4fv = (type_glVertexAttrib4fv) + context->getProcAddress(QLatin1String("glVertexAttrib4fv")); + if (!funcs->vertexAttrib4fv) { + funcs->vertexAttrib4fv = (type_glVertexAttrib4fv) + context->getProcAddress(QLatin1String("glVertexAttrib4fvARB")); + } + + if (funcs->vertexAttrib4fv) + funcs->vertexAttrib4fv(indx, values); + else + funcs->vertexAttrib4fv = qglfResolveVertexAttrib4fv; +} + +static void qglfResolveVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) +{ + typedef void (QGLF_APIENTRYP type_glVertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); + + const QGLContext *context = QGLContext::currentContext(); + QGLFunctionsPrivate *funcs = qt_gl_functions(context); + + funcs->vertexAttribPointer = (type_glVertexAttribPointer) + context->getProcAddress(QLatin1String("glVertexAttribPointer")); + if (!funcs->vertexAttribPointer) { + funcs->vertexAttribPointer = (type_glVertexAttribPointer) + context->getProcAddress(QLatin1String("glVertexAttribPointerARB")); + } + + if (funcs->vertexAttribPointer) + funcs->vertexAttribPointer(indx, size, type, normalized, stride, ptr); + else + funcs->vertexAttribPointer = qglfResolveVertexAttribPointer; +} + +#endif // !QT_OPENGL_ES_2 + +QGLFunctionsPrivate::QGLFunctionsPrivate(const QGLContext *) +{ +#ifndef QT_OPENGL_ES_2 + activeTexture = qglfResolveActiveTexture; + attachShader = qglfResolveAttachShader; + bindAttribLocation = qglfResolveBindAttribLocation; + bindBuffer = qglfResolveBindBuffer; + bindFramebuffer = qglfResolveBindFramebuffer; + bindRenderbuffer = qglfResolveBindRenderbuffer; + blendColor = qglfResolveBlendColor; + blendEquation = qglfResolveBlendEquation; + blendEquationSeparate = qglfResolveBlendEquationSeparate; + blendFuncSeparate = qglfResolveBlendFuncSeparate; + bufferData = qglfResolveBufferData; + bufferSubData = qglfResolveBufferSubData; + checkFramebufferStatus = qglfResolveCheckFramebufferStatus; + compileShader = qglfResolveCompileShader; + compressedTexImage2D = qglfResolveCompressedTexImage2D; + compressedTexSubImage2D = qglfResolveCompressedTexSubImage2D; + createProgram = qglfResolveCreateProgram; + createShader = qglfResolveCreateShader; + deleteBuffers = qglfResolveDeleteBuffers; + deleteFramebuffers = qglfResolveDeleteFramebuffers; + deleteProgram = qglfResolveDeleteProgram; + deleteRenderbuffers = qglfResolveDeleteRenderbuffers; + deleteShader = qglfResolveDeleteShader; + detachShader = qglfResolveDetachShader; + disableVertexAttribArray = qglfResolveDisableVertexAttribArray; + enableVertexAttribArray = qglfResolveEnableVertexAttribArray; + framebufferRenderbuffer = qglfResolveFramebufferRenderbuffer; + framebufferTexture2D = qglfResolveFramebufferTexture2D; + genBuffers = qglfResolveGenBuffers; + generateMipmap = qglfResolveGenerateMipmap; + genFramebuffers = qglfResolveGenFramebuffers; + genRenderbuffers = qglfResolveGenRenderbuffers; + getActiveAttrib = qglfResolveGetActiveAttrib; + getActiveUniform = qglfResolveGetActiveUniform; + getAttachedShaders = qglfResolveGetAttachedShaders; + getAttribLocation = qglfResolveGetAttribLocation; + getBufferParameteriv = qglfResolveGetBufferParameteriv; + getFramebufferAttachmentParameteriv = qglfResolveGetFramebufferAttachmentParameteriv; + getProgramiv = qglfResolveGetProgramiv; + getProgramInfoLog = qglfResolveGetProgramInfoLog; + getRenderbufferParameteriv = qglfResolveGetRenderbufferParameteriv; + getShaderiv = qglfResolveGetShaderiv; + getShaderInfoLog = qglfResolveGetShaderInfoLog; + getShaderPrecisionFormat = qglfResolveGetShaderPrecisionFormat; + getShaderSource = qglfResolveGetShaderSource; + getUniformfv = qglfResolveGetUniformfv; + getUniformiv = qglfResolveGetUniformiv; + getUniformLocation = qglfResolveGetUniformLocation; + getVertexAttribfv = qglfResolveGetVertexAttribfv; + getVertexAttribiv = qglfResolveGetVertexAttribiv; + getVertexAttribPointerv = qglfResolveGetVertexAttribPointerv; + isBuffer = qglfResolveIsBuffer; + isFramebuffer = qglfResolveIsFramebuffer; + isProgram = qglfResolveIsProgram; + isRenderbuffer = qglfResolveIsRenderbuffer; + isShader = qglfResolveIsShader; + linkProgram = qglfResolveLinkProgram; + releaseShaderCompiler = qglfResolveReleaseShaderCompiler; + renderbufferStorage = qglfResolveRenderbufferStorage; + sampleCoverage = qglfResolveSampleCoverage; + shaderBinary = qglfResolveShaderBinary; + shaderSource = qglfResolveShaderSource; + stencilFuncSeparate = qglfResolveStencilFuncSeparate; + stencilMaskSeparate = qglfResolveStencilMaskSeparate; + stencilOpSeparate = qglfResolveStencilOpSeparate; + uniform1f = qglfResolveUniform1f; + uniform1fv = qglfResolveUniform1fv; + uniform1i = qglfResolveUniform1i; + uniform1iv = qglfResolveUniform1iv; + uniform2f = qglfResolveUniform2f; + uniform2fv = qglfResolveUniform2fv; + uniform2i = qglfResolveUniform2i; + uniform2iv = qglfResolveUniform2iv; + uniform3f = qglfResolveUniform3f; + uniform3fv = qglfResolveUniform3fv; + uniform3i = qglfResolveUniform3i; + uniform3iv = qglfResolveUniform3iv; + uniform4f = qglfResolveUniform4f; + uniform4fv = qglfResolveUniform4fv; + uniform4i = qglfResolveUniform4i; + uniform4iv = qglfResolveUniform4iv; + uniformMatrix2fv = qglfResolveUniformMatrix2fv; + uniformMatrix3fv = qglfResolveUniformMatrix3fv; + uniformMatrix4fv = qglfResolveUniformMatrix4fv; + useProgram = qglfResolveUseProgram; + validateProgram = qglfResolveValidateProgram; + vertexAttrib1f = qglfResolveVertexAttrib1f; + vertexAttrib1fv = qglfResolveVertexAttrib1fv; + vertexAttrib2f = qglfResolveVertexAttrib2f; + vertexAttrib2fv = qglfResolveVertexAttrib2fv; + vertexAttrib3f = qglfResolveVertexAttrib3f; + vertexAttrib3fv = qglfResolveVertexAttrib3fv; + vertexAttrib4f = qglfResolveVertexAttrib4f; + vertexAttrib4fv = qglfResolveVertexAttrib4fv; + vertexAttribPointer = qglfResolveVertexAttribPointer; +#endif // !QT_OPENGL_ES_2 +} + +QT_END_NAMESPACE diff --git a/src/opengl/qglfunctions.h b/src/opengl/qglfunctions.h new file mode 100644 index 0000000..e06de7f --- /dev/null +++ b/src/opengl/qglfunctions.h @@ -0,0 +1,2290 @@ +/**************************************************************************** +** +** 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 QGLFUNCTIONS_H +#define QGLFUNCTIONS_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(OpenGL) + +// Types that aren't defined in all system's gl.h files. +typedef ptrdiff_t qgl_GLintptr; +typedef ptrdiff_t qgl_GLsizeiptr; + +#ifndef Q_WS_MAC +# ifndef QGLF_APIENTRYP +# ifdef QGLF_APIENTRY +# define QGLF_APIENTRYP QGLF_APIENTRY * +# else +# define QGLF_APIENTRY +# define QGLF_APIENTRYP * +# endif +# endif +#else +# define QGLF_APIENTRY +# define QGLF_APIENTRYP * +#endif + +struct QGLFunctionsPrivate; + +// Undefine any macros from GLEW, qglextensions_p.h, etc that +// may interfere with the definition of QGLFunctions. +#undef glActiveTexture +#undef glAttachShader +#undef glBindAttribLocation +#undef glBindBuffer +#undef glBindFramebuffer +#undef glBindRenderbuffer +#undef glBlendColor +#undef glBlendEquation +#undef glBlendEquationSeparate +#undef glBlendFuncSeparate +#undef glBufferData +#undef glBufferSubData +#undef glCheckFramebufferStatus +#undef glClearDepthf +#undef glCompileShader +#undef glCompressedTexImage2D +#undef glCompressedTexSubImage2D +#undef glCreateProgram +#undef glCreateShader +#undef glDeleteBuffers +#undef glDeleteFramebuffers +#undef glDeleteProgram +#undef glDeleteRenderbuffers +#undef glDeleteShader +#undef glDepthRangef +#undef glDetachShader +#undef glDisableVertexAttribArray +#undef glEnableVertexAttribArray +#undef glFramebufferRenderbuffer +#undef glFramebufferTexture2D +#undef glGenBuffers +#undef glGenerateMipmap +#undef glGenFramebuffers +#undef glGenRenderbuffers +#undef glGetActiveAttrib +#undef glGetActiveUniform +#undef glGetAttachedShaders +#undef glGetAttribLocation +#undef glGetBufferParameteriv +#undef glGetFramebufferAttachmentParameteriv +#undef glGetProgramiv +#undef glGetProgramInfoLog +#undef glGetRenderbufferParameteriv +#undef glGetShaderiv +#undef glGetShaderInfoLog +#undef glGetShaderPrecisionFormat +#undef glGetShaderSource +#undef glGetUniformfv +#undef glGetUniformiv +#undef glGetUniformLocation +#undef glGetVertexAttribfv +#undef glGetVertexAttribiv +#undef glGetVertexAttribPointerv +#undef glIsBuffer +#undef glIsFramebuffer +#undef glIsProgram +#undef glIsRenderbuffer +#undef glIsShader +#undef glLinkProgram +#undef glReleaseShaderCompiler +#undef glRenderbufferStorage +#undef glSampleCoverage +#undef glShaderBinary +#undef glShaderSource +#undef glStencilFuncSeparate +#undef glStencilMaskSeparate +#undef glStencilOpSeparate +#undef glUniform1f +#undef glUniform1fv +#undef glUniform1i +#undef glUniform1iv +#undef glUniform2f +#undef glUniform2fv +#undef glUniform2i +#undef glUniform2iv +#undef glUniform3f +#undef glUniform3fv +#undef glUniform3i +#undef glUniform3iv +#undef glUniform4f +#undef glUniform4fv +#undef glUniform4i +#undef glUniform4iv +#undef glUniformMatrix2fv +#undef glUniformMatrix3fv +#undef glUniformMatrix4fv +#undef glUseProgram +#undef glValidateProgram +#undef glVertexAttrib1f +#undef glVertexAttrib1fv +#undef glVertexAttrib2f +#undef glVertexAttrib2fv +#undef glVertexAttrib3f +#undef glVertexAttrib3fv +#undef glVertexAttrib4f +#undef glVertexAttrib4fv +#undef glVertexAttribPointer + +class Q_OPENGL_EXPORT QGLFunctions +{ +public: + QGLFunctions(); + explicit QGLFunctions(const QGLContext *context); + ~QGLFunctions() {} + + enum OpenGLFeature + { + Multitexture = 0x0001, + Shaders = 0x0002, + Buffers = 0x0004, + Framebuffers = 0x0008, + BlendColor = 0x0010, + BlendEquation = 0x0020, + BlendEquationSeparate = 0x0040, + BlendFuncSeparate = 0x0080, + BlendSubtract = 0x0100, + CompressedTextures = 0x0200, + Multisample = 0x0400, + StencilSeparate = 0x0800, + NPOTTextures = 0x1000 + }; + Q_DECLARE_FLAGS(OpenGLFeatures, OpenGLFeature) + + QGLFunctions::OpenGLFeatures openGLFeatures() const; + bool hasOpenGLFeature(QGLFunctions::OpenGLFeature feature) const; + + void initializeGLFunctions(const QGLContext *context = 0); + + void glActiveTexture(GLenum texture); + void glAttachShader(GLuint program, GLuint shader); + void glBindAttribLocation(GLuint program, GLuint index, const char* name); + void glBindBuffer(GLenum target, GLuint buffer); + void glBindFramebuffer(GLenum target, GLuint framebuffer); + void glBindRenderbuffer(GLenum target, GLuint renderbuffer); + void glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void glBlendEquation(GLenum mode); + void glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); + void glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + void glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage); + void glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data); + GLenum glCheckFramebufferStatus(GLenum target); + void glClearDepthf(GLclampf depth); + void glCompileShader(GLuint shader); + void glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); + void glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); + GLuint glCreateProgram(); + GLuint glCreateShader(GLenum type); + void glDeleteBuffers(GLsizei n, const GLuint* buffers); + void glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers); + void glDeleteProgram(GLuint program); + void glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers); + void glDeleteShader(GLuint shader); + void glDepthRangef(GLclampf zNear, GLclampf zFar); + void glDetachShader(GLuint program, GLuint shader); + void glDisableVertexAttribArray(GLuint index); + void glEnableVertexAttribArray(GLuint index); + void glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void glGenBuffers(GLsizei n, GLuint* buffers); + void glGenerateMipmap(GLenum target); + void glGenFramebuffers(GLsizei n, GLuint* framebuffers); + void glGenRenderbuffers(GLsizei n, GLuint* renderbuffers); + void glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); + void glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); + void glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); + int glGetAttribLocation(GLuint program, const char* name); + void glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params); + void glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params); + void glGetProgramiv(GLuint program, GLenum pname, GLint* params); + void glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); + void glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params); + void glGetShaderiv(GLuint shader, GLenum pname, GLint* params); + void glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); + void glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); + void glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source); + void glGetUniformfv(GLuint program, GLint location, GLfloat* params); + void glGetUniformiv(GLuint program, GLint location, GLint* params); + int glGetUniformLocation(GLuint program, const char* name); + void glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params); + void glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params); + void glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer); + GLboolean glIsBuffer(GLuint buffer); + GLboolean glIsFramebuffer(GLuint framebuffer); + GLboolean glIsProgram(GLuint program); + GLboolean glIsRenderbuffer(GLuint renderbuffer); + GLboolean glIsShader(GLuint shader); + void glLinkProgram(GLuint program); + void glReleaseShaderCompiler(); + void glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void glSampleCoverage(GLclampf value, GLboolean invert); + void glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length); + void glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length); + void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask); + void glStencilMaskSeparate(GLenum face, GLuint mask); + void glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void glUniform1f(GLint location, GLfloat x); + void glUniform1fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform1i(GLint location, GLint x); + void glUniform1iv(GLint location, GLsizei count, const GLint* v); + void glUniform2f(GLint location, GLfloat x, GLfloat y); + void glUniform2fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform2i(GLint location, GLint x, GLint y); + void glUniform2iv(GLint location, GLsizei count, const GLint* v); + void glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z); + void glUniform3fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform3i(GLint location, GLint x, GLint y, GLint z); + void glUniform3iv(GLint location, GLsizei count, const GLint* v); + void glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glUniform4fv(GLint location, GLsizei count, const GLfloat* v); + void glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w); + void glUniform4iv(GLint location, GLsizei count, const GLint* v); + void glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void glUseProgram(GLuint program); + void glValidateProgram(GLuint program); + void glVertexAttrib1f(GLuint indx, GLfloat x); + void glVertexAttrib1fv(GLuint indx, const GLfloat* values); + void glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y); + void glVertexAttrib2fv(GLuint indx, const GLfloat* values); + void glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z); + void glVertexAttrib3fv(GLuint indx, const GLfloat* values); + void glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void glVertexAttrib4fv(GLuint indx, const GLfloat* values); + void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); + +private: + QGLFunctionsPrivate *d_ptr; + static bool isInitialized(const QGLFunctionsPrivate *d) { return d != 0; } +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QGLFunctions::OpenGLFeatures) + +struct QGLFunctionsPrivate +{ + QGLFunctionsPrivate(const QGLContext *context = 0); + +#ifndef QT_OPENGL_ES_2 + void (QGLF_APIENTRYP activeTexture)(GLenum texture); + void (QGLF_APIENTRYP attachShader)(GLuint program, GLuint shader); + void (QGLF_APIENTRYP bindAttribLocation)(GLuint program, GLuint index, const char* name); + void (QGLF_APIENTRYP bindBuffer)(GLenum target, GLuint buffer); + void (QGLF_APIENTRYP bindFramebuffer)(GLenum target, GLuint framebuffer); + void (QGLF_APIENTRYP bindRenderbuffer)(GLenum target, GLuint renderbuffer); + void (QGLF_APIENTRYP blendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); + void (QGLF_APIENTRYP blendEquation)(GLenum mode); + void (QGLF_APIENTRYP blendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha); + void (QGLF_APIENTRYP blendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); + void (QGLF_APIENTRYP bufferData)(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage); + void (QGLF_APIENTRYP bufferSubData)(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data); + GLenum (QGLF_APIENTRYP checkFramebufferStatus)(GLenum target); + void (QGLF_APIENTRYP compileShader)(GLuint shader); + void (QGLF_APIENTRYP compressedTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data); + void (QGLF_APIENTRYP compressedTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data); + GLuint (QGLF_APIENTRYP createProgram)(); + GLuint (QGLF_APIENTRYP createShader)(GLenum type); + void (QGLF_APIENTRYP deleteBuffers)(GLsizei n, const GLuint* buffers); + void (QGLF_APIENTRYP deleteFramebuffers)(GLsizei n, const GLuint* framebuffers); + void (QGLF_APIENTRYP deleteProgram)(GLuint program); + void (QGLF_APIENTRYP deleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers); + void (QGLF_APIENTRYP deleteShader)(GLuint shader); + void (QGLF_APIENTRYP detachShader)(GLuint program, GLuint shader); + void (QGLF_APIENTRYP disableVertexAttribArray)(GLuint index); + void (QGLF_APIENTRYP enableVertexAttribArray)(GLuint index); + void (QGLF_APIENTRYP framebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); + void (QGLF_APIENTRYP framebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); + void (QGLF_APIENTRYP genBuffers)(GLsizei n, GLuint* buffers); + void (QGLF_APIENTRYP generateMipmap)(GLenum target); + void (QGLF_APIENTRYP genFramebuffers)(GLsizei n, GLuint* framebuffers); + void (QGLF_APIENTRYP genRenderbuffers)(GLsizei n, GLuint* renderbuffers); + void (QGLF_APIENTRYP getActiveAttrib)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); + void (QGLF_APIENTRYP getActiveUniform)(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name); + void (QGLF_APIENTRYP getAttachedShaders)(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); + int (QGLF_APIENTRYP getAttribLocation)(GLuint program, const char* name); + void (QGLF_APIENTRYP getBufferParameteriv)(GLenum target, GLenum pname, GLint* params); + void (QGLF_APIENTRYP getFramebufferAttachmentParameteriv)(GLenum target, GLenum attachment, GLenum pname, GLint* params); + void (QGLF_APIENTRYP getProgramiv)(GLuint program, GLenum pname, GLint* params); + void (QGLF_APIENTRYP getProgramInfoLog)(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog); + void (QGLF_APIENTRYP getRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params); + void (QGLF_APIENTRYP getShaderiv)(GLuint shader, GLenum pname, GLint* params); + void (QGLF_APIENTRYP getShaderInfoLog)(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog); + void (QGLF_APIENTRYP getShaderPrecisionFormat)(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); + void (QGLF_APIENTRYP getShaderSource)(GLuint shader, GLsizei bufsize, GLsizei* length, char* source); + void (QGLF_APIENTRYP getUniformfv)(GLuint program, GLint location, GLfloat* params); + void (QGLF_APIENTRYP getUniformiv)(GLuint program, GLint location, GLint* params); + int (QGLF_APIENTRYP getUniformLocation)(GLuint program, const char* name); + void (QGLF_APIENTRYP getVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params); + void (QGLF_APIENTRYP getVertexAttribiv)(GLuint index, GLenum pname, GLint* params); + void (QGLF_APIENTRYP getVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer); + GLboolean (QGLF_APIENTRYP isBuffer)(GLuint buffer); + GLboolean (QGLF_APIENTRYP isFramebuffer)(GLuint framebuffer); + GLboolean (QGLF_APIENTRYP isProgram)(GLuint program); + GLboolean (QGLF_APIENTRYP isRenderbuffer)(GLuint renderbuffer); + GLboolean (QGLF_APIENTRYP isShader)(GLuint shader); + void (QGLF_APIENTRYP linkProgram)(GLuint program); + void (QGLF_APIENTRYP releaseShaderCompiler)(); + void (QGLF_APIENTRYP renderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + void (QGLF_APIENTRYP sampleCoverage)(GLclampf value, GLboolean invert); + void (QGLF_APIENTRYP shaderBinary)(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length); + void (QGLF_APIENTRYP shaderSource)(GLuint shader, GLsizei count, const char** string, const GLint* length); + void (QGLF_APIENTRYP stencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); + void (QGLF_APIENTRYP stencilMaskSeparate)(GLenum face, GLuint mask); + void (QGLF_APIENTRYP stencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); + void (QGLF_APIENTRYP uniform1f)(GLint location, GLfloat x); + void (QGLF_APIENTRYP uniform1fv)(GLint location, GLsizei count, const GLfloat* v); + void (QGLF_APIENTRYP uniform1i)(GLint location, GLint x); + void (QGLF_APIENTRYP uniform1iv)(GLint location, GLsizei count, const GLint* v); + void (QGLF_APIENTRYP uniform2f)(GLint location, GLfloat x, GLfloat y); + void (QGLF_APIENTRYP uniform2fv)(GLint location, GLsizei count, const GLfloat* v); + void (QGLF_APIENTRYP uniform2i)(GLint location, GLint x, GLint y); + void (QGLF_APIENTRYP uniform2iv)(GLint location, GLsizei count, const GLint* v); + void (QGLF_APIENTRYP uniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z); + void (QGLF_APIENTRYP uniform3fv)(GLint location, GLsizei count, const GLfloat* v); + void (QGLF_APIENTRYP uniform3i)(GLint location, GLint x, GLint y, GLint z); + void (QGLF_APIENTRYP uniform3iv)(GLint location, GLsizei count, const GLint* v); + void (QGLF_APIENTRYP uniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void (QGLF_APIENTRYP uniform4fv)(GLint location, GLsizei count, const GLfloat* v); + void (QGLF_APIENTRYP uniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w); + void (QGLF_APIENTRYP uniform4iv)(GLint location, GLsizei count, const GLint* v); + void (QGLF_APIENTRYP uniformMatrix2fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void (QGLF_APIENTRYP uniformMatrix3fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void (QGLF_APIENTRYP uniformMatrix4fv)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); + void (QGLF_APIENTRYP useProgram)(GLuint program); + void (QGLF_APIENTRYP validateProgram)(GLuint program); + void (QGLF_APIENTRYP vertexAttrib1f)(GLuint indx, GLfloat x); + void (QGLF_APIENTRYP vertexAttrib1fv)(GLuint indx, const GLfloat* values); + void (QGLF_APIENTRYP vertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y); + void (QGLF_APIENTRYP vertexAttrib2fv)(GLuint indx, const GLfloat* values); + void (QGLF_APIENTRYP vertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z); + void (QGLF_APIENTRYP vertexAttrib3fv)(GLuint indx, const GLfloat* values); + void (QGLF_APIENTRYP vertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); + void (QGLF_APIENTRYP vertexAttrib4fv)(GLuint indx, const GLfloat* values); + void (QGLF_APIENTRYP vertexAttribPointer)(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr); +#endif +}; + +inline void QGLFunctions::glActiveTexture(GLenum texture) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glActiveTexture(texture); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->activeTexture(texture); +#endif +} + +inline void QGLFunctions::glAttachShader(GLuint program, GLuint shader) +{ +#if defined(QT_OPENGL_ES_2) + ::glAttachShader(program, shader); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->attachShader(program, shader); +#endif +} + +inline void QGLFunctions::glBindAttribLocation(GLuint program, GLuint index, const char* name) +{ +#if defined(QT_OPENGL_ES_2) + ::glBindAttribLocation(program, index, name); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->bindAttribLocation(program, index, name); +#endif +} + +inline void QGLFunctions::glBindBuffer(GLenum target, GLuint buffer) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glBindBuffer(target, buffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->bindBuffer(target, buffer); +#endif +} + +inline void QGLFunctions::glBindFramebuffer(GLenum target, GLuint framebuffer) +{ +#if defined(QT_OPENGL_ES_2) + ::glBindFramebuffer(target, framebuffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->bindFramebuffer(target, framebuffer); +#endif +} + +inline void QGLFunctions::glBindRenderbuffer(GLenum target, GLuint renderbuffer) +{ +#if defined(QT_OPENGL_ES_2) + ::glBindRenderbuffer(target, renderbuffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->bindRenderbuffer(target, renderbuffer); +#endif +} + +inline void QGLFunctions::glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ +#if defined(QT_OPENGL_ES_2) + ::glBlendColor(red, green, blue, alpha); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->blendColor(red, green, blue, alpha); +#endif +} + +inline void QGLFunctions::glBlendEquation(GLenum mode) +{ +#if defined(QT_OPENGL_ES_2) + ::glBlendEquation(mode); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->blendEquation(mode); +#endif +} + +inline void QGLFunctions::glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +{ +#if defined(QT_OPENGL_ES_2) + ::glBlendEquationSeparate(modeRGB, modeAlpha); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->blendEquationSeparate(modeRGB, modeAlpha); +#endif +} + +inline void QGLFunctions::glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) +{ +#if defined(QT_OPENGL_ES_2) + ::glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +#endif +} + +inline void QGLFunctions::glBufferData(GLenum target, qgl_GLsizeiptr size, const void* data, GLenum usage) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glBufferData(target, size, data, usage); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->bufferData(target, size, data, usage); +#endif +} + +inline void QGLFunctions::glBufferSubData(GLenum target, qgl_GLintptr offset, qgl_GLsizeiptr size, const void* data) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glBufferSubData(target, offset, size, data); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->bufferSubData(target, offset, size, data); +#endif +} + +inline GLenum QGLFunctions::glCheckFramebufferStatus(GLenum target) +{ +#if defined(QT_OPENGL_ES_2) + return ::glCheckFramebufferStatus(target); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->checkFramebufferStatus(target); +#endif +} + +inline void QGLFunctions::glClearDepthf(GLclampf depth) +{ +#ifndef QT_OPENGL_ES + ::glClearDepth(depth); +#else + ::glClearDepthf(depth); +#endif +} + +inline void QGLFunctions::glCompileShader(GLuint shader) +{ +#if defined(QT_OPENGL_ES_2) + ::glCompileShader(shader); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->compileShader(shader); +#endif +} + +inline void QGLFunctions::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void* data) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->compressedTexImage2D(target, level, internalformat, width, height, border, imageSize, data); +#endif +} + +inline void QGLFunctions::glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void* data) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data); +#endif +} + +inline GLuint QGLFunctions::glCreateProgram() +{ +#if defined(QT_OPENGL_ES_2) + return ::glCreateProgram(); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->createProgram(); +#endif +} + +inline GLuint QGLFunctions::glCreateShader(GLenum type) +{ +#if defined(QT_OPENGL_ES_2) + return ::glCreateShader(type); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->createShader(type); +#endif +} + +inline void QGLFunctions::glDeleteBuffers(GLsizei n, const GLuint* buffers) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glDeleteBuffers(n, buffers); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->deleteBuffers(n, buffers); +#endif +} + +inline void QGLFunctions::glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers) +{ +#if defined(QT_OPENGL_ES_2) + ::glDeleteFramebuffers(n, framebuffers); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->deleteFramebuffers(n, framebuffers); +#endif +} + +inline void QGLFunctions::glDeleteProgram(GLuint program) +{ +#if defined(QT_OPENGL_ES_2) + ::glDeleteProgram(program); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->deleteProgram(program); +#endif +} + +inline void QGLFunctions::glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) +{ +#if defined(QT_OPENGL_ES_2) + ::glDeleteRenderbuffers(n, renderbuffers); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->deleteRenderbuffers(n, renderbuffers); +#endif +} + +inline void QGLFunctions::glDeleteShader(GLuint shader) +{ +#if defined(QT_OPENGL_ES_2) + ::glDeleteShader(shader); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->deleteShader(shader); +#endif +} + +inline void QGLFunctions::glDepthRangef(GLclampf zNear, GLclampf zFar) +{ +#ifndef QT_OPENGL_ES + ::glDepthRange(zNear, zFar); +#else + ::glDepthRangef(zNear, zFar); +#endif +} + +inline void QGLFunctions::glDetachShader(GLuint program, GLuint shader) +{ +#if defined(QT_OPENGL_ES_2) + ::glDetachShader(program, shader); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->detachShader(program, shader); +#endif +} + +inline void QGLFunctions::glDisableVertexAttribArray(GLuint index) +{ +#if defined(QT_OPENGL_ES_2) + ::glDisableVertexAttribArray(index); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->disableVertexAttribArray(index); +#endif +} + +inline void QGLFunctions::glEnableVertexAttribArray(GLuint index) +{ +#if defined(QT_OPENGL_ES_2) + ::glEnableVertexAttribArray(index); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->enableVertexAttribArray(index); +#endif +} + +inline void QGLFunctions::glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ +#if defined(QT_OPENGL_ES_2) + ::glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); +#endif +} + +inline void QGLFunctions::glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ +#if defined(QT_OPENGL_ES_2) + ::glFramebufferTexture2D(target, attachment, textarget, texture, level); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->framebufferTexture2D(target, attachment, textarget, texture, level); +#endif +} + +inline void QGLFunctions::glGenBuffers(GLsizei n, GLuint* buffers) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glGenBuffers(n, buffers); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->genBuffers(n, buffers); +#endif +} + +inline void QGLFunctions::glGenerateMipmap(GLenum target) +{ +#if defined(QT_OPENGL_ES_2) + ::glGenerateMipmap(target); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->generateMipmap(target); +#endif +} + +inline void QGLFunctions::glGenFramebuffers(GLsizei n, GLuint* framebuffers) +{ +#if defined(QT_OPENGL_ES_2) + ::glGenFramebuffers(n, framebuffers); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->genFramebuffers(n, framebuffers); +#endif +} + +inline void QGLFunctions::glGenRenderbuffers(GLsizei n, GLuint* renderbuffers) +{ +#if defined(QT_OPENGL_ES_2) + ::glGenRenderbuffers(n, renderbuffers); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->genRenderbuffers(n, renderbuffers); +#endif +} + +inline void QGLFunctions::glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetActiveAttrib(program, index, bufsize, length, size, type, name); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getActiveAttrib(program, index, bufsize, length, size, type, name); +#endif +} + +inline void QGLFunctions::glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetActiveUniform(program, index, bufsize, length, size, type, name); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getActiveUniform(program, index, bufsize, length, size, type, name); +#endif +} + +inline void QGLFunctions::glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetAttachedShaders(program, maxcount, count, shaders); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getAttachedShaders(program, maxcount, count, shaders); +#endif +} + +inline int QGLFunctions::glGetAttribLocation(GLuint program, const char* name) +{ +#if defined(QT_OPENGL_ES_2) + return ::glGetAttribLocation(program, name); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->getAttribLocation(program, name); +#endif +} + +inline void QGLFunctions::glGetBufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetBufferParameteriv(target, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getBufferParameteriv(target, pname, params); +#endif +} + +inline void QGLFunctions::glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getFramebufferAttachmentParameteriv(target, attachment, pname, params); +#endif +} + +inline void QGLFunctions::glGetProgramiv(GLuint program, GLenum pname, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetProgramiv(program, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getProgramiv(program, pname, params); +#endif +} + +inline void QGLFunctions::glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetProgramInfoLog(program, bufsize, length, infolog); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getProgramInfoLog(program, bufsize, length, infolog); +#endif +} + +inline void QGLFunctions::glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetRenderbufferParameteriv(target, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getRenderbufferParameteriv(target, pname, params); +#endif +} + +inline void QGLFunctions::glGetShaderiv(GLuint shader, GLenum pname, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetShaderiv(shader, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getShaderiv(shader, pname, params); +#endif +} + +inline void QGLFunctions::glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetShaderInfoLog(shader, bufsize, length, infolog); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getShaderInfoLog(shader, bufsize, length, infolog); +#endif +} + +inline void QGLFunctions::glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getShaderPrecisionFormat(shadertype, precisiontype, range, precision); +#endif +} + +inline void QGLFunctions::glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, char* source) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetShaderSource(shader, bufsize, length, source); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getShaderSource(shader, bufsize, length, source); +#endif +} + +inline void QGLFunctions::glGetUniformfv(GLuint program, GLint location, GLfloat* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetUniformfv(program, location, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getUniformfv(program, location, params); +#endif +} + +inline void QGLFunctions::glGetUniformiv(GLuint program, GLint location, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetUniformiv(program, location, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getUniformiv(program, location, params); +#endif +} + +inline int QGLFunctions::glGetUniformLocation(GLuint program, const char* name) +{ +#if defined(QT_OPENGL_ES_2) + return ::glGetUniformLocation(program, name); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->getUniformLocation(program, name); +#endif +} + +inline void QGLFunctions::glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetVertexAttribfv(index, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getVertexAttribfv(index, pname, params); +#endif +} + +inline void QGLFunctions::glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetVertexAttribiv(index, pname, params); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getVertexAttribiv(index, pname, params); +#endif +} + +inline void QGLFunctions::glGetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) +{ +#if defined(QT_OPENGL_ES_2) + ::glGetVertexAttribPointerv(index, pname, pointer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->getVertexAttribPointerv(index, pname, pointer); +#endif +} + +inline GLboolean QGLFunctions::glIsBuffer(GLuint buffer) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + return ::glIsBuffer(buffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->isBuffer(buffer); +#endif +} + +inline GLboolean QGLFunctions::glIsFramebuffer(GLuint framebuffer) +{ +#if defined(QT_OPENGL_ES_2) + return ::glIsFramebuffer(framebuffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->isFramebuffer(framebuffer); +#endif +} + +inline GLboolean QGLFunctions::glIsProgram(GLuint program) +{ +#if defined(QT_OPENGL_ES_2) + return ::glIsProgram(program); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->isProgram(program); +#endif +} + +inline GLboolean QGLFunctions::glIsRenderbuffer(GLuint renderbuffer) +{ +#if defined(QT_OPENGL_ES_2) + return ::glIsRenderbuffer(renderbuffer); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->isRenderbuffer(renderbuffer); +#endif +} + +inline GLboolean QGLFunctions::glIsShader(GLuint shader) +{ +#if defined(QT_OPENGL_ES_2) + return ::glIsShader(shader); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + return d_ptr->isShader(shader); +#endif +} + +inline void QGLFunctions::glLinkProgram(GLuint program) +{ +#if defined(QT_OPENGL_ES_2) + ::glLinkProgram(program); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->linkProgram(program); +#endif +} + +inline void QGLFunctions::glReleaseShaderCompiler() +{ +#if defined(QT_OPENGL_ES_2) + ::glReleaseShaderCompiler(); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->releaseShaderCompiler(); +#endif +} + +inline void QGLFunctions::glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ +#if defined(QT_OPENGL_ES_2) + ::glRenderbufferStorage(target, internalformat, width, height); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->renderbufferStorage(target, internalformat, width, height); +#endif +} + +inline void QGLFunctions::glSampleCoverage(GLclampf value, GLboolean invert) +{ +#if defined(QT_OPENGL_ES_1) || defined(QT_OPENGL_ES_2) + ::glSampleCoverage(value, invert); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->sampleCoverage(value, invert); +#endif +} + +inline void QGLFunctions::glShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length) +{ +#if defined(QT_OPENGL_ES_2) + ::glShaderBinary(n, shaders, binaryformat, binary, length); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->shaderBinary(n, shaders, binaryformat, binary, length); +#endif +} + +inline void QGLFunctions::glShaderSource(GLuint shader, GLsizei count, const char** string, const GLint* length) +{ +#if defined(QT_OPENGL_ES_2) + ::glShaderSource(shader, count, string, length); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->shaderSource(shader, count, string, length); +#endif +} + +inline void QGLFunctions::glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ +#if defined(QT_OPENGL_ES_2) + ::glStencilFuncSeparate(face, func, ref, mask); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->stencilFuncSeparate(face, func, ref, mask); +#endif +} + +inline void QGLFunctions::glStencilMaskSeparate(GLenum face, GLuint mask) +{ +#if defined(QT_OPENGL_ES_2) + ::glStencilMaskSeparate(face, mask); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->stencilMaskSeparate(face, mask); +#endif +} + +inline void QGLFunctions::glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ +#if defined(QT_OPENGL_ES_2) + ::glStencilOpSeparate(face, fail, zfail, zpass); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->stencilOpSeparate(face, fail, zfail, zpass); +#endif +} + +inline void QGLFunctions::glUniform1f(GLint location, GLfloat x) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform1f(location, x); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform1f(location, x); +#endif +} + +inline void QGLFunctions::glUniform1fv(GLint location, GLsizei count, const GLfloat* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform1fv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform1fv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform1i(GLint location, GLint x) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform1i(location, x); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform1i(location, x); +#endif +} + +inline void QGLFunctions::glUniform1iv(GLint location, GLsizei count, const GLint* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform1iv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform1iv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform2f(GLint location, GLfloat x, GLfloat y) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform2f(location, x, y); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform2f(location, x, y); +#endif +} + +inline void QGLFunctions::glUniform2fv(GLint location, GLsizei count, const GLfloat* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform2fv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform2fv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform2i(GLint location, GLint x, GLint y) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform2i(location, x, y); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform2i(location, x, y); +#endif +} + +inline void QGLFunctions::glUniform2iv(GLint location, GLsizei count, const GLint* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform2iv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform2iv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform3f(location, x, y, z); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform3f(location, x, y, z); +#endif +} + +inline void QGLFunctions::glUniform3fv(GLint location, GLsizei count, const GLfloat* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform3fv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform3fv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform3i(GLint location, GLint x, GLint y, GLint z) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform3i(location, x, y, z); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform3i(location, x, y, z); +#endif +} + +inline void QGLFunctions::glUniform3iv(GLint location, GLsizei count, const GLint* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform3iv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform3iv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform4f(location, x, y, z, w); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform4f(location, x, y, z, w); +#endif +} + +inline void QGLFunctions::glUniform4fv(GLint location, GLsizei count, const GLfloat* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform4fv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform4fv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform4i(location, x, y, z, w); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform4i(location, x, y, z, w); +#endif +} + +inline void QGLFunctions::glUniform4iv(GLint location, GLsizei count, const GLint* v) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniform4iv(location, count, v); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniform4iv(location, count, v); +#endif +} + +inline void QGLFunctions::glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniformMatrix2fv(location, count, transpose, value); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniformMatrix2fv(location, count, transpose, value); +#endif +} + +inline void QGLFunctions::glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniformMatrix3fv(location, count, transpose, value); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniformMatrix3fv(location, count, transpose, value); +#endif +} + +inline void QGLFunctions::glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) +{ +#if defined(QT_OPENGL_ES_2) + ::glUniformMatrix4fv(location, count, transpose, value); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->uniformMatrix4fv(location, count, transpose, value); +#endif +} + +inline void QGLFunctions::glUseProgram(GLuint program) +{ +#if defined(QT_OPENGL_ES_2) + ::glUseProgram(program); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->useProgram(program); +#endif +} + +inline void QGLFunctions::glValidateProgram(GLuint program) +{ +#if defined(QT_OPENGL_ES_2) + ::glValidateProgram(program); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->validateProgram(program); +#endif +} + +inline void QGLFunctions::glVertexAttrib1f(GLuint indx, GLfloat x) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib1f(indx, x); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib1f(indx, x); +#endif +} + +inline void QGLFunctions::glVertexAttrib1fv(GLuint indx, const GLfloat* values) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib1fv(indx, values); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib1fv(indx, values); +#endif +} + +inline void QGLFunctions::glVertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib2f(indx, x, y); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib2f(indx, x, y); +#endif +} + +inline void QGLFunctions::glVertexAttrib2fv(GLuint indx, const GLfloat* values) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib2fv(indx, values); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib2fv(indx, values); +#endif +} + +inline void QGLFunctions::glVertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib3f(indx, x, y, z); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib3f(indx, x, y, z); +#endif +} + +inline void QGLFunctions::glVertexAttrib3fv(GLuint indx, const GLfloat* values) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib3fv(indx, values); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib3fv(indx, values); +#endif +} + +inline void QGLFunctions::glVertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib4f(indx, x, y, z, w); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib4f(indx, x, y, z, w); +#endif +} + +inline void QGLFunctions::glVertexAttrib4fv(GLuint indx, const GLfloat* values) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttrib4fv(indx, values); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttrib4fv(indx, values); +#endif +} + +inline void QGLFunctions::glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) +{ +#if defined(QT_OPENGL_ES_2) + ::glVertexAttribPointer(indx, size, type, normalized, stride, ptr); +#else + Q_ASSERT(QGLFunctions::isInitialized(d_ptr)); + d_ptr->vertexAttribPointer(indx, size, type, normalized, stride, ptr); +#endif +} + +#ifndef GL_ACTIVE_ATTRIBUTE_MAX_LENGTH +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#endif +#ifndef GL_ACTIVE_ATTRIBUTES +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#endif +#ifndef GL_ACTIVE_TEXTURE +#define GL_ACTIVE_TEXTURE 0x84E0 +#endif +#ifndef GL_ACTIVE_UNIFORM_MAX_LENGTH +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#endif +#ifndef GL_ACTIVE_UNIFORMS +#define GL_ACTIVE_UNIFORMS 0x8B86 +#endif +#ifndef GL_ALIASED_LINE_WIDTH_RANGE +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif +#ifndef GL_ALIASED_POINT_SIZE_RANGE +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif +#ifndef GL_ALPHA +#define GL_ALPHA 0x1906 +#endif +#ifndef GL_ALPHA_BITS +#define GL_ALPHA_BITS 0x0D55 +#endif +#ifndef GL_ALWAYS +#define GL_ALWAYS 0x0207 +#endif +#ifndef GL_ARRAY_BUFFER +#define GL_ARRAY_BUFFER 0x8892 +#endif +#ifndef GL_ARRAY_BUFFER_BINDING +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#endif +#ifndef GL_ATTACHED_SHADERS +#define GL_ATTACHED_SHADERS 0x8B85 +#endif +#ifndef GL_BACK +#define GL_BACK 0x0405 +#endif +#ifndef GL_BLEND +#define GL_BLEND 0x0BE2 +#endif +#ifndef GL_BLEND_COLOR +#define GL_BLEND_COLOR 0x8005 +#endif +#ifndef GL_BLEND_DST_ALPHA +#define GL_BLEND_DST_ALPHA 0x80CA +#endif +#ifndef GL_BLEND_DST_RGB +#define GL_BLEND_DST_RGB 0x80C8 +#endif +#ifndef GL_BLEND_EQUATION +#define GL_BLEND_EQUATION 0x8009 +#endif +#ifndef GL_BLEND_EQUATION_ALPHA +#define GL_BLEND_EQUATION_ALPHA 0x883D +#endif +#ifndef GL_BLEND_EQUATION_RGB +#define GL_BLEND_EQUATION_RGB 0x8009 +#endif +#ifndef GL_BLEND_SRC_ALPHA +#define GL_BLEND_SRC_ALPHA 0x80CB +#endif +#ifndef GL_BLEND_SRC_RGB +#define GL_BLEND_SRC_RGB 0x80C9 +#endif +#ifndef GL_BLUE_BITS +#define GL_BLUE_BITS 0x0D54 +#endif +#ifndef GL_BOOL +#define GL_BOOL 0x8B56 +#endif +#ifndef GL_BOOL_VEC2 +#define GL_BOOL_VEC2 0x8B57 +#endif +#ifndef GL_BOOL_VEC3 +#define GL_BOOL_VEC3 0x8B58 +#endif +#ifndef GL_BOOL_VEC4 +#define GL_BOOL_VEC4 0x8B59 +#endif +#ifndef GL_BUFFER_SIZE +#define GL_BUFFER_SIZE 0x8764 +#endif +#ifndef GL_BUFFER_USAGE +#define GL_BUFFER_USAGE 0x8765 +#endif +#ifndef GL_BYTE +#define GL_BYTE 0x1400 +#endif +#ifndef GL_CCW +#define GL_CCW 0x0901 +#endif +#ifndef GL_CLAMP_TO_EDGE +#define GL_CLAMP_TO_EDGE 0x812F +#endif +#ifndef GL_COLOR_ATTACHMENT0 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#endif +#ifndef GL_COLOR_BUFFER_BIT +#define GL_COLOR_BUFFER_BIT 0x00004000 +#endif +#ifndef GL_COLOR_CLEAR_VALUE +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#endif +#ifndef GL_COLOR_WRITEMASK +#define GL_COLOR_WRITEMASK 0x0C23 +#endif +#ifndef GL_COMPILE_STATUS +#define GL_COMPILE_STATUS 0x8B81 +#endif +#ifndef GL_COMPRESSED_TEXTURE_FORMATS +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#endif +#ifndef GL_CONSTANT_ALPHA +#define GL_CONSTANT_ALPHA 0x8003 +#endif +#ifndef GL_CONSTANT_COLOR +#define GL_CONSTANT_COLOR 0x8001 +#endif +#ifndef GL_CULL_FACE +#define GL_CULL_FACE 0x0B44 +#endif +#ifndef GL_CULL_FACE_MODE +#define GL_CULL_FACE_MODE 0x0B45 +#endif +#ifndef GL_CURRENT_PROGRAM +#define GL_CURRENT_PROGRAM 0x8B8D +#endif +#ifndef GL_CURRENT_VERTEX_ATTRIB +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#endif +#ifndef GL_CW +#define GL_CW 0x0900 +#endif +#ifndef GL_DECR +#define GL_DECR 0x1E03 +#endif +#ifndef GL_DECR_WRAP +#define GL_DECR_WRAP 0x8508 +#endif +#ifndef GL_DELETE_STATUS +#define GL_DELETE_STATUS 0x8B80 +#endif +#ifndef GL_DEPTH_ATTACHMENT +#define GL_DEPTH_ATTACHMENT 0x8D00 +#endif +#ifndef GL_DEPTH_BITS +#define GL_DEPTH_BITS 0x0D56 +#endif +#ifndef GL_DEPTH_BUFFER_BIT +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#endif +#ifndef GL_DEPTH_CLEAR_VALUE +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#endif +#ifndef GL_DEPTH_COMPONENT +#define GL_DEPTH_COMPONENT 0x1902 +#endif +#ifndef GL_DEPTH_COMPONENT16 +#define GL_DEPTH_COMPONENT16 0x81A5 +#endif +#ifndef GL_DEPTH_FUNC +#define GL_DEPTH_FUNC 0x0B74 +#endif +#ifndef GL_DEPTH_RANGE +#define GL_DEPTH_RANGE 0x0B70 +#endif +#ifndef GL_DEPTH_TEST +#define GL_DEPTH_TEST 0x0B71 +#endif +#ifndef GL_DEPTH_WRITEMASK +#define GL_DEPTH_WRITEMASK 0x0B72 +#endif +#ifndef GL_DITHER +#define GL_DITHER 0x0BD0 +#endif +#ifndef GL_DONT_CARE +#define GL_DONT_CARE 0x1100 +#endif +#ifndef GL_DST_ALPHA +#define GL_DST_ALPHA 0x0304 +#endif +#ifndef GL_DST_COLOR +#define GL_DST_COLOR 0x0306 +#endif +#ifndef GL_DYNAMIC_DRAW +#define GL_DYNAMIC_DRAW 0x88E8 +#endif +#ifndef GL_ELEMENT_ARRAY_BUFFER +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#endif +#ifndef GL_ELEMENT_ARRAY_BUFFER_BINDING +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#endif +#ifndef GL_EQUAL +#define GL_EQUAL 0x0202 +#endif +#ifndef GL_EXTENSIONS +#define GL_EXTENSIONS 0x1F03 +#endif +#ifndef GL_FALSE +#define GL_FALSE 0 +#endif +#ifndef GL_FASTEST +#define GL_FASTEST 0x1101 +#endif +#ifndef GL_FIXED +#define GL_FIXED 0x140C +#endif +#ifndef GL_FLOAT +#define GL_FLOAT 0x1406 +#endif +#ifndef GL_FLOAT_MAT2 +#define GL_FLOAT_MAT2 0x8B5A +#endif +#ifndef GL_FLOAT_MAT3 +#define GL_FLOAT_MAT3 0x8B5B +#endif +#ifndef GL_FLOAT_MAT4 +#define GL_FLOAT_MAT4 0x8B5C +#endif +#ifndef GL_FLOAT_VEC2 +#define GL_FLOAT_VEC2 0x8B50 +#endif +#ifndef GL_FLOAT_VEC3 +#define GL_FLOAT_VEC3 0x8B51 +#endif +#ifndef GL_FLOAT_VEC4 +#define GL_FLOAT_VEC4 0x8B52 +#endif +#ifndef GL_FRAGMENT_SHADER +#define GL_FRAGMENT_SHADER 0x8B30 +#endif +#ifndef GL_FRAMEBUFFER +#define GL_FRAMEBUFFER 0x8D40 +#endif +#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#endif +#ifndef GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#endif +#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#endif +#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#endif +#ifndef GL_FRAMEBUFFER_BINDING +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#endif +#ifndef GL_FRAMEBUFFER_COMPLETE +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#endif +#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#endif +#ifndef GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#endif +#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#endif +#ifndef GL_FRAMEBUFFER_UNSUPPORTED +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#endif +#ifndef GL_FRONT +#define GL_FRONT 0x0404 +#endif +#ifndef GL_FRONT_AND_BACK +#define GL_FRONT_AND_BACK 0x0408 +#endif +#ifndef GL_FRONT_FACE +#define GL_FRONT_FACE 0x0B46 +#endif +#ifndef GL_FUNC_ADD +#define GL_FUNC_ADD 0x8006 +#endif +#ifndef GL_FUNC_REVERSE_SUBTRACT +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif +#ifndef GL_FUNC_SUBTRACT +#define GL_FUNC_SUBTRACT 0x800A +#endif +#ifndef GL_GENERATE_MIPMAP_HINT +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#endif +#ifndef GL_GEQUAL +#define GL_GEQUAL 0x0206 +#endif +#ifndef GL_GREATER +#define GL_GREATER 0x0204 +#endif +#ifndef GL_GREEN_BITS +#define GL_GREEN_BITS 0x0D53 +#endif +#ifndef GL_HIGH_FLOAT +#define GL_HIGH_FLOAT 0x8DF2 +#endif +#ifndef GL_HIGH_INT +#define GL_HIGH_INT 0x8DF5 +#endif +#ifndef GL_IMPLEMENTATION_COLOR_READ_FORMAT +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#endif +#ifndef GL_IMPLEMENTATION_COLOR_READ_TYPE +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#endif +#ifndef GL_INCR +#define GL_INCR 0x1E02 +#endif +#ifndef GL_INCR_WRAP +#define GL_INCR_WRAP 0x8507 +#endif +#ifndef GL_INFO_LOG_LENGTH +#define GL_INFO_LOG_LENGTH 0x8B84 +#endif +#ifndef GL_INT +#define GL_INT 0x1404 +#endif +#ifndef GL_INT_VEC2 +#define GL_INT_VEC2 0x8B53 +#endif +#ifndef GL_INT_VEC3 +#define GL_INT_VEC3 0x8B54 +#endif +#ifndef GL_INT_VEC4 +#define GL_INT_VEC4 0x8B55 +#endif +#ifndef GL_INVALID_ENUM +#define GL_INVALID_ENUM 0x0500 +#endif +#ifndef GL_INVALID_FRAMEBUFFER_OPERATION +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#endif +#ifndef GL_INVALID_OPERATION +#define GL_INVALID_OPERATION 0x0502 +#endif +#ifndef GL_INVALID_VALUE +#define GL_INVALID_VALUE 0x0501 +#endif +#ifndef GL_INVERT +#define GL_INVERT 0x150A +#endif +#ifndef GL_KEEP +#define GL_KEEP 0x1E00 +#endif +#ifndef GL_LEQUAL +#define GL_LEQUAL 0x0203 +#endif +#ifndef GL_LESS +#define GL_LESS 0x0201 +#endif +#ifndef GL_LINEAR +#define GL_LINEAR 0x2601 +#endif +#ifndef GL_LINEAR_MIPMAP_LINEAR +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#endif +#ifndef GL_LINEAR_MIPMAP_NEAREST +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#endif +#ifndef GL_LINE_LOOP +#define GL_LINE_LOOP 0x0002 +#endif +#ifndef GL_LINES +#define GL_LINES 0x0001 +#endif +#ifndef GL_LINE_STRIP +#define GL_LINE_STRIP 0x0003 +#endif +#ifndef GL_LINE_WIDTH +#define GL_LINE_WIDTH 0x0B21 +#endif +#ifndef GL_LINK_STATUS +#define GL_LINK_STATUS 0x8B82 +#endif +#ifndef GL_LOW_FLOAT +#define GL_LOW_FLOAT 0x8DF0 +#endif +#ifndef GL_LOW_INT +#define GL_LOW_INT 0x8DF3 +#endif +#ifndef GL_LUMINANCE +#define GL_LUMINANCE 0x1909 +#endif +#ifndef GL_LUMINANCE_ALPHA +#define GL_LUMINANCE_ALPHA 0x190A +#endif +#ifndef GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#endif +#ifndef GL_MAX_CUBE_MAP_TEXTURE_SIZE +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#endif +#ifndef GL_MAX_FRAGMENT_UNIFORM_VECTORS +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#endif +#ifndef GL_MAX_RENDERBUFFER_SIZE +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#endif +#ifndef GL_MAX_TEXTURE_IMAGE_UNITS +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#endif +#ifndef GL_MAX_TEXTURE_SIZE +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#endif +#ifndef GL_MAX_VARYING_VECTORS +#define GL_MAX_VARYING_VECTORS 0x8DFC +#endif +#ifndef GL_MAX_VERTEX_ATTRIBS +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#endif +#ifndef GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#endif +#ifndef GL_MAX_VERTEX_UNIFORM_VECTORS +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#endif +#ifndef GL_MAX_VIEWPORT_DIMS +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#endif +#ifndef GL_MEDIUM_FLOAT +#define GL_MEDIUM_FLOAT 0x8DF1 +#endif +#ifndef GL_MEDIUM_INT +#define GL_MEDIUM_INT 0x8DF4 +#endif +#ifndef GL_MIRRORED_REPEAT +#define GL_MIRRORED_REPEAT 0x8370 +#endif +#ifndef GL_NEAREST +#define GL_NEAREST 0x2600 +#endif +#ifndef GL_NEAREST_MIPMAP_LINEAR +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#endif +#ifndef GL_NEAREST_MIPMAP_NEAREST +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#endif +#ifndef GL_NEVER +#define GL_NEVER 0x0200 +#endif +#ifndef GL_NICEST +#define GL_NICEST 0x1102 +#endif +#ifndef GL_NO_ERROR +#define GL_NO_ERROR 0 +#endif +#ifndef GL_NONE +#define GL_NONE 0 +#endif +#ifndef GL_NOTEQUAL +#define GL_NOTEQUAL 0x0205 +#endif +#ifndef GL_NUM_COMPRESSED_TEXTURE_FORMATS +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#endif +#ifndef GL_NUM_SHADER_BINARY_FORMATS +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#endif +#ifndef GL_ONE +#define GL_ONE 1 +#endif +#ifndef GL_ONE_MINUS_CONSTANT_ALPHA +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#endif +#ifndef GL_ONE_MINUS_CONSTANT_COLOR +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#endif +#ifndef GL_ONE_MINUS_DST_ALPHA +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#endif +#ifndef GL_ONE_MINUS_DST_COLOR +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#endif +#ifndef GL_ONE_MINUS_SRC_ALPHA +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#endif +#ifndef GL_ONE_MINUS_SRC_COLOR +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#endif +#ifndef GL_OUT_OF_MEMORY +#define GL_OUT_OF_MEMORY 0x0505 +#endif +#ifndef GL_PACK_ALIGNMENT +#define GL_PACK_ALIGNMENT 0x0D05 +#endif +#ifndef GL_POINTS +#define GL_POINTS 0x0000 +#endif +#ifndef GL_POLYGON_OFFSET_FACTOR +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#endif +#ifndef GL_POLYGON_OFFSET_FILL +#define GL_POLYGON_OFFSET_FILL 0x8037 +#endif +#ifndef GL_POLYGON_OFFSET_UNITS +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#endif +#ifndef GL_RED_BITS +#define GL_RED_BITS 0x0D52 +#endif +#ifndef GL_RENDERBUFFER +#define GL_RENDERBUFFER 0x8D41 +#endif +#ifndef GL_RENDERBUFFER_ALPHA_SIZE +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#endif +#ifndef GL_RENDERBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#endif +#ifndef GL_RENDERBUFFER_BLUE_SIZE +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#endif +#ifndef GL_RENDERBUFFER_DEPTH_SIZE +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#endif +#ifndef GL_RENDERBUFFER_GREEN_SIZE +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#endif +#ifndef GL_RENDERBUFFER_HEIGHT +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#endif +#ifndef GL_RENDERBUFFER_INTERNAL_FORMAT +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#endif +#ifndef GL_RENDERBUFFER_RED_SIZE +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#endif +#ifndef GL_RENDERBUFFER_STENCIL_SIZE +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#endif +#ifndef GL_RENDERBUFFER_WIDTH +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#endif +#ifndef GL_RENDERER +#define GL_RENDERER 0x1F01 +#endif +#ifndef GL_REPEAT +#define GL_REPEAT 0x2901 +#endif +#ifndef GL_REPLACE +#define GL_REPLACE 0x1E01 +#endif +#ifndef GL_RGB +#define GL_RGB 0x1907 +#endif +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif +#ifndef GL_RGB5_A1 +#define GL_RGB5_A1 0x8057 +#endif +#ifndef GL_RGBA +#define GL_RGBA 0x1908 +#endif +#ifndef GL_RGBA4 +#define GL_RGBA4 0x8056 +#endif +#ifndef GL_SAMPLE_ALPHA_TO_COVERAGE +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#endif +#ifndef GL_SAMPLE_BUFFERS +#define GL_SAMPLE_BUFFERS 0x80A8 +#endif +#ifndef GL_SAMPLE_COVERAGE +#define GL_SAMPLE_COVERAGE 0x80A0 +#endif +#ifndef GL_SAMPLE_COVERAGE_INVERT +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#endif +#ifndef GL_SAMPLE_COVERAGE_VALUE +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#endif +#ifndef GL_SAMPLER_2D +#define GL_SAMPLER_2D 0x8B5E +#endif +#ifndef GL_SAMPLER_CUBE +#define GL_SAMPLER_CUBE 0x8B60 +#endif +#ifndef GL_SAMPLES +#define GL_SAMPLES 0x80A9 +#endif +#ifndef GL_SCISSOR_BOX +#define GL_SCISSOR_BOX 0x0C10 +#endif +#ifndef GL_SCISSOR_TEST +#define GL_SCISSOR_TEST 0x0C11 +#endif +#ifndef GL_SHADER_BINARY_FORMATS +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#endif +#ifndef GL_SHADER_COMPILER +#define GL_SHADER_COMPILER 0x8DFA +#endif +#ifndef GL_SHADER_SOURCE_LENGTH +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#endif +#ifndef GL_SHADER_TYPE +#define GL_SHADER_TYPE 0x8B4F +#endif +#ifndef GL_SHADING_LANGUAGE_VERSION +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#endif +#ifndef GL_SHORT +#define GL_SHORT 0x1402 +#endif +#ifndef GL_SRC_ALPHA +#define GL_SRC_ALPHA 0x0302 +#endif +#ifndef GL_SRC_ALPHA_SATURATE +#define GL_SRC_ALPHA_SATURATE 0x0308 +#endif +#ifndef GL_SRC_COLOR +#define GL_SRC_COLOR 0x0300 +#endif +#ifndef GL_STATIC_DRAW +#define GL_STATIC_DRAW 0x88E4 +#endif +#ifndef GL_STENCIL_ATTACHMENT +#define GL_STENCIL_ATTACHMENT 0x8D20 +#endif +#ifndef GL_STENCIL_BACK_FAIL +#define GL_STENCIL_BACK_FAIL 0x8801 +#endif +#ifndef GL_STENCIL_BACK_FUNC +#define GL_STENCIL_BACK_FUNC 0x8800 +#endif +#ifndef GL_STENCIL_BACK_PASS_DEPTH_FAIL +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#endif +#ifndef GL_STENCIL_BACK_PASS_DEPTH_PASS +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#endif +#ifndef GL_STENCIL_BACK_REF +#define GL_STENCIL_BACK_REF 0x8CA3 +#endif +#ifndef GL_STENCIL_BACK_VALUE_MASK +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#endif +#ifndef GL_STENCIL_BACK_WRITEMASK +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif +#ifndef GL_STENCIL_BITS +#define GL_STENCIL_BITS 0x0D57 +#endif +#ifndef GL_STENCIL_BUFFER_BIT +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#endif +#ifndef GL_STENCIL_CLEAR_VALUE +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#endif +#ifndef GL_STENCIL_FAIL +#define GL_STENCIL_FAIL 0x0B94 +#endif +#ifndef GL_STENCIL_FUNC +#define GL_STENCIL_FUNC 0x0B92 +#endif +#ifndef GL_STENCIL_INDEX +#define GL_STENCIL_INDEX 0x1901 +#endif +#ifndef GL_STENCIL_INDEX8 +#define GL_STENCIL_INDEX8 0x8D48 +#endif +#ifndef GL_STENCIL_PASS_DEPTH_FAIL +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#endif +#ifndef GL_STENCIL_PASS_DEPTH_PASS +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#endif +#ifndef GL_STENCIL_REF +#define GL_STENCIL_REF 0x0B97 +#endif +#ifndef GL_STENCIL_TEST +#define GL_STENCIL_TEST 0x0B90 +#endif +#ifndef GL_STENCIL_VALUE_MASK +#define GL_STENCIL_VALUE_MASK 0x0B93 +#endif +#ifndef GL_STENCIL_WRITEMASK +#define GL_STENCIL_WRITEMASK 0x0B98 +#endif +#ifndef GL_STREAM_DRAW +#define GL_STREAM_DRAW 0x88E0 +#endif +#ifndef GL_SUBPIXEL_BITS +#define GL_SUBPIXEL_BITS 0x0D50 +#endif +#ifndef GL_TEXTURE0 +#define GL_TEXTURE0 0x84C0 +#endif +#ifndef GL_TEXTURE +#define GL_TEXTURE 0x1702 +#endif +#ifndef GL_TEXTURE10 +#define GL_TEXTURE10 0x84CA +#endif +#ifndef GL_TEXTURE1 +#define GL_TEXTURE1 0x84C1 +#endif +#ifndef GL_TEXTURE11 +#define GL_TEXTURE11 0x84CB +#endif +#ifndef GL_TEXTURE12 +#define GL_TEXTURE12 0x84CC +#endif +#ifndef GL_TEXTURE13 +#define GL_TEXTURE13 0x84CD +#endif +#ifndef GL_TEXTURE14 +#define GL_TEXTURE14 0x84CE +#endif +#ifndef GL_TEXTURE15 +#define GL_TEXTURE15 0x84CF +#endif +#ifndef GL_TEXTURE16 +#define GL_TEXTURE16 0x84D0 +#endif +#ifndef GL_TEXTURE17 +#define GL_TEXTURE17 0x84D1 +#endif +#ifndef GL_TEXTURE18 +#define GL_TEXTURE18 0x84D2 +#endif +#ifndef GL_TEXTURE19 +#define GL_TEXTURE19 0x84D3 +#endif +#ifndef GL_TEXTURE20 +#define GL_TEXTURE20 0x84D4 +#endif +#ifndef GL_TEXTURE2 +#define GL_TEXTURE2 0x84C2 +#endif +#ifndef GL_TEXTURE21 +#define GL_TEXTURE21 0x84D5 +#endif +#ifndef GL_TEXTURE22 +#define GL_TEXTURE22 0x84D6 +#endif +#ifndef GL_TEXTURE23 +#define GL_TEXTURE23 0x84D7 +#endif +#ifndef GL_TEXTURE24 +#define GL_TEXTURE24 0x84D8 +#endif +#ifndef GL_TEXTURE25 +#define GL_TEXTURE25 0x84D9 +#endif +#ifndef GL_TEXTURE26 +#define GL_TEXTURE26 0x84DA +#endif +#ifndef GL_TEXTURE27 +#define GL_TEXTURE27 0x84DB +#endif +#ifndef GL_TEXTURE28 +#define GL_TEXTURE28 0x84DC +#endif +#ifndef GL_TEXTURE29 +#define GL_TEXTURE29 0x84DD +#endif +#ifndef GL_TEXTURE_2D +#define GL_TEXTURE_2D 0x0DE1 +#endif +#ifndef GL_TEXTURE30 +#define GL_TEXTURE30 0x84DE +#endif +#ifndef GL_TEXTURE3 +#define GL_TEXTURE3 0x84C3 +#endif +#ifndef GL_TEXTURE31 +#define GL_TEXTURE31 0x84DF +#endif +#ifndef GL_TEXTURE4 +#define GL_TEXTURE4 0x84C4 +#endif +#ifndef GL_TEXTURE5 +#define GL_TEXTURE5 0x84C5 +#endif +#ifndef GL_TEXTURE6 +#define GL_TEXTURE6 0x84C6 +#endif +#ifndef GL_TEXTURE7 +#define GL_TEXTURE7 0x84C7 +#endif +#ifndef GL_TEXTURE8 +#define GL_TEXTURE8 0x84C8 +#endif +#ifndef GL_TEXTURE9 +#define GL_TEXTURE9 0x84C9 +#endif +#ifndef GL_TEXTURE_BINDING_2D +#define GL_TEXTURE_BINDING_2D 0x8069 +#endif +#ifndef GL_TEXTURE_BINDING_CUBE_MAP +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#endif +#ifndef GL_TEXTURE_CUBE_MAP +#define GL_TEXTURE_CUBE_MAP 0x8513 +#endif +#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_X +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#endif +#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Y +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#endif +#ifndef GL_TEXTURE_CUBE_MAP_NEGATIVE_Z +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#endif +#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_X +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#endif +#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Y +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#endif +#ifndef GL_TEXTURE_CUBE_MAP_POSITIVE_Z +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#endif +#ifndef GL_TEXTURE_MAG_FILTER +#define GL_TEXTURE_MAG_FILTER 0x2800 +#endif +#ifndef GL_TEXTURE_MIN_FILTER +#define GL_TEXTURE_MIN_FILTER 0x2801 +#endif +#ifndef GL_TEXTURE_WRAP_S +#define GL_TEXTURE_WRAP_S 0x2802 +#endif +#ifndef GL_TEXTURE_WRAP_T +#define GL_TEXTURE_WRAP_T 0x2803 +#endif +#ifndef GL_TRIANGLE_FAN +#define GL_TRIANGLE_FAN 0x0006 +#endif +#ifndef GL_TRIANGLES +#define GL_TRIANGLES 0x0004 +#endif +#ifndef GL_TRIANGLE_STRIP +#define GL_TRIANGLE_STRIP 0x0005 +#endif +#ifndef GL_TRUE +#define GL_TRUE 1 +#endif +#ifndef GL_UNPACK_ALIGNMENT +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#endif +#ifndef GL_UNSIGNED_BYTE +#define GL_UNSIGNED_BYTE 0x1401 +#endif +#ifndef GL_UNSIGNED_INT +#define GL_UNSIGNED_INT 0x1405 +#endif +#ifndef GL_UNSIGNED_SHORT +#define GL_UNSIGNED_SHORT 0x1403 +#endif +#ifndef GL_UNSIGNED_SHORT_4_4_4_4 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#endif +#ifndef GL_UNSIGNED_SHORT_5_5_5_1 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#endif +#ifndef GL_UNSIGNED_SHORT_5_6_5 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#endif +#ifndef GL_VALIDATE_STATUS +#define GL_VALIDATE_STATUS 0x8B83 +#endif +#ifndef GL_VENDOR +#define GL_VENDOR 0x1F00 +#endif +#ifndef GL_VERSION +#define GL_VERSION 0x1F02 +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_ENABLED +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_NORMALIZED +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_POINTER +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_SIZE +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_STRIDE +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#endif +#ifndef GL_VERTEX_ATTRIB_ARRAY_TYPE +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#endif +#ifndef GL_VERTEX_SHADER +#define GL_VERTEX_SHADER 0x8B31 +#endif +#ifndef GL_VIEWPORT +#define GL_VIEWPORT 0x0BA2 +#endif +#ifndef GL_ZERO +#define GL_ZERO 0 +#endif + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif diff --git a/tests/auto/opengl.pro b/tests/auto/opengl.pro index 9b59cd1..6c8e4ca 100644 --- a/tests/auto/opengl.pro +++ b/tests/auto/opengl.pro @@ -3,4 +3,5 @@ SUBDIRS=\ qgl \ qglthreads \ qglbuffer \ + qglfunctions \ diff --git a/tests/auto/qglfunctions/qglfunctions.pro b/tests/auto/qglfunctions/qglfunctions.pro new file mode 100644 index 0000000..aa81547 --- /dev/null +++ b/tests/auto/qglfunctions/qglfunctions.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +requires(contains(QT_CONFIG,opengl)) +QT += opengl + +win32:!wince*: DEFINES += QT_NO_EGL + +SOURCES += tst_qglfunctions.cpp diff --git a/tests/auto/qglfunctions/tst_qglfunctions.cpp b/tests/auto/qglfunctions/tst_qglfunctions.cpp new file mode 100644 index 0000000..8d6be73 --- /dev/null +++ b/tests/auto/qglfunctions/tst_qglfunctions.cpp @@ -0,0 +1,238 @@ +/**************************************************************************** +** +** 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 + +class tst_QGLFunctions : public QObject +{ + Q_OBJECT +public: + tst_QGLFunctions() {} + ~tst_QGLFunctions() {} + +private slots: + void features(); + void multitexture(); + void blendColor(); + +private: + static bool hasExtension(const char *name); +}; + +bool tst_QGLFunctions::hasExtension(const char *name) +{ + QString extensions = + QString::fromLatin1 + (reinterpret_cast(glGetString(GL_EXTENSIONS))); + return extensions.split(QLatin1Char(' ')).contains + (QString::fromLatin1(name)); +} + +// Check that the reported features are consistent with the platform. +void tst_QGLFunctions::features() +{ + // Before being associated with a context, there should be + // no features enabled. + QGLFunctions funcs; + QVERIFY(!funcs.openGLFeatures()); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Multitexture)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Shaders)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Buffers)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Framebuffers)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendColor)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendEquation)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Multisample)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures)); + + // Make a context current. + QGLWidget glw; + glw.makeCurrent(); + funcs.initializeGLFunctions(); + + // Validate the features against what we expect for this platform. +#if defined(QT_OPENGL_ES_2) + QGLFunctions::OpenGLFeatures allFeatures = + (QGLFunctions::Multitexture | + QGLFunctions::Shaders | + QGLFunctions::Buffers | + QGLFunctions::Framebuffers | + QGLFunctions::BlendColor | + QGLFunctions::BlendEquation | + QGLFunctions::BlendEquationSeparate | + QGLFunctions::BlendFuncSeparate | + QGLFunctions::BlendSubtract | + QGLFunctions::CompressedTextures | + QGLFunctions::Multisample | + QGLFunctions::StencilSeparate | + QGLFunctions::NPOTTextures); + QVERIFY((funcs.openGLFeatures() & allFeatures) == allFeatures); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multitexture)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Shaders)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Buffers)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Framebuffers)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendColor)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendEquation)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multisample)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures)); +#elif defined(QT_OPENGL_ES) + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multitexture)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Buffers)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures)); + QVERIFY(funcs.hasOpenGLFeature(QGLFunctions::Multisample)); + + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::Shaders)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::BlendColor)); + QVERIFY(!funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate)); + + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Framebuffers), + hasExtension("GL_OES_framebuffer_object")); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate), + hasExtension("GL_OES_blend_equation_separate")); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate), + hasExtension("GL_OES_blend_func_separate")); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract), + hasExtension("GL_OES_blend_subtract")); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures), + hasExtension("GL_OES_texture_npot")); +#else + // We check for both the extension name and the minimum OpenGL version + // for the feature. This will help us catch situations where a platform + // doesn't list an extension by name but does have the feature by virtue + // of its version number. + QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags(); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Multitexture), + hasExtension("GL_ARB_multitexture") || + (versions & QGLFormat::OpenGL_Version_1_3) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Shaders), + hasExtension("GL_ARB_shader_objects") || + (versions & QGLFormat::OpenGL_Version_2_0) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Buffers), + (versions & QGLFormat::OpenGL_Version_1_5) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Framebuffers), + hasExtension("GL_EXT_framebuffer_object") || + hasExtension("GL_ARB_framebuffer_object")); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendColor), + hasExtension("GL_EXT_blend_color") || + (versions & QGLFormat::OpenGL_Version_1_2) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendEquation), + (versions & QGLFormat::OpenGL_Version_1_2) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendEquationSeparate), + hasExtension("GL_EXT_blend_equation_separate") || + (versions & QGLFormat::OpenGL_Version_2_0) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendFuncSeparate), + hasExtension("GL_EXT_blend_func_separate") || + (versions & QGLFormat::OpenGL_Version_1_4) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::BlendSubtract), + hasExtension("GL_EXT_blend_subtract")); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::CompressedTextures), + hasExtension("GL_ARB_texture_compression") || + (versions & QGLFormat::OpenGL_Version_1_3) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::Multisample), + hasExtension("GL_ARB_multisample") || + (versions & QGLFormat::OpenGL_Version_1_3) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::StencilSeparate), + (versions & QGLFormat::OpenGL_Version_2_0) != 0); + QCOMPARE(funcs.hasOpenGLFeature(QGLFunctions::NPOTTextures), + hasExtension("GL_ARB_texture_non_power_of_two") || + (versions & QGLFormat::OpenGL_Version_2_0) != 0); +#endif +} + +// Verify that the multitexture functions appear to resolve and work. +void tst_QGLFunctions::multitexture() +{ + QGLFunctions funcs; + QGLWidget glw; + glw.makeCurrent(); + funcs.initializeGLFunctions(); + + if (!funcs.hasOpenGLFeature(QGLFunctions::Multitexture)) + QSKIP("Multitexture functions are not supported", SkipSingle); + + funcs.glActiveTexture(GL_TEXTURE1); + + GLint active = 0; + glGetIntegerv(GL_ACTIVE_TEXTURE, &active); + QVERIFY(active == GL_TEXTURE1); + + funcs.glActiveTexture(GL_TEXTURE0); + + active = 0; + glGetIntegerv(GL_ACTIVE_TEXTURE, &active); + QVERIFY(active == GL_TEXTURE0); +} + +// Verify that the glBlendColor() function appears to resolve and work. +void tst_QGLFunctions::blendColor() +{ + QGLFunctions funcs; + QGLWidget glw; + glw.makeCurrent(); + funcs.initializeGLFunctions(); + + if (!funcs.hasOpenGLFeature(QGLFunctions::BlendColor)) + QSKIP("glBlendColor() is not supported", SkipSingle); + + funcs.glBlendColor(0.0f, 1.0f, 0.0f, 1.0f); + + GLfloat colors[4] = {0.5f, 0.5f, 0.5f, 0.5f}; + glGetFloatv(GL_BLEND_COLOR, colors); + + QCOMPARE(colors[0], 0.0f); + QCOMPARE(colors[1], 1.0f); + QCOMPARE(colors[2], 0.0f); + QCOMPARE(colors[3], 1.0f); +} + +QTEST_MAIN(tst_QGLFunctions) + +#include "tst_qglfunctions.moc" -- cgit v0.12 From 1efed3f163164a9c98b4ea7d747507b6fdc52d63 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Fri, 13 Aug 2010 12:18:50 +1000 Subject: Don't run QGLFunctions tests if cannot create context --- tests/auto/qglfunctions/tst_qglfunctions.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/auto/qglfunctions/tst_qglfunctions.cpp b/tests/auto/qglfunctions/tst_qglfunctions.cpp index 8d6be73..73e63b5 100644 --- a/tests/auto/qglfunctions/tst_qglfunctions.cpp +++ b/tests/auto/qglfunctions/tst_qglfunctions.cpp @@ -90,6 +90,8 @@ void tst_QGLFunctions::features() // Make a context current. QGLWidget glw; + if (!glw.isValid()) + QSKIP("Could not create a GL context", SkipAll); glw.makeCurrent(); funcs.initializeGLFunctions(); @@ -192,6 +194,8 @@ void tst_QGLFunctions::multitexture() { QGLFunctions funcs; QGLWidget glw; + if (!glw.isValid()) + QSKIP("Could not create a GL context", SkipAll); glw.makeCurrent(); funcs.initializeGLFunctions(); @@ -216,6 +220,8 @@ void tst_QGLFunctions::blendColor() { QGLFunctions funcs; QGLWidget glw; + if (!glw.isValid()) + QSKIP("Could not create a GL context", SkipAll); glw.makeCurrent(); funcs.initializeGLFunctions(); -- cgit v0.12 From 6c2662c9d4d0813622ee5a9783911dbe2e48e72c Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 13 Aug 2010 14:51:13 +0200 Subject: QNAM HTTP: Remove eatWhitespace() hack After the Unbuffered TCP rewrite this brought more trouble than it helped. Better fix the chunked decoder soon. Reviewed-by: Peter Hartmann --- .../access/qhttpnetworkconnectionchannel.cpp | 36 +++++----------------- .../access/qhttpnetworkconnectionchannel_p.h | 2 -- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index c0b5928..b06b2d3 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -631,7 +631,6 @@ bool QHttpNetworkConnectionChannel::expand(bool dataComplete) void QHttpNetworkConnectionChannel::allDone() { - eatWhitespace(); // FIXME HACK! #ifndef QT_NO_COMPRESS // expand the whole data. if (reply->d_func()->expectContent() && reply->d_func()->autoDecompress && !reply->d_func()->streamEnd) @@ -693,10 +692,15 @@ void QHttpNetworkConnectionChannel::allDone() // this was wrong, allDone gets called from that function anyway. } } else if (alreadyPipelinedRequests.isEmpty() && socket->bytesAvailable() > 0) { - eatWhitespace(); // this is weird. we had nothing pipelined but still bytes available. better close it. - if (socket->bytesAvailable() > 0) - close(); + //if (socket->bytesAvailable() > 0) + // close(); + // + // FIXME + // We do not close it anymore now, but should introduce this again after having fixed + // the chunked decoder in QHttpNetworkReply to read the whitespace after the last chunk. + // (Currently this is worked around by readStatus in the QHttpNetworkReply ignoring + // leading whitespace. QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } else if (alreadyPipelinedRequests.isEmpty()) { if (qobject_cast(connection)) @@ -743,30 +747,6 @@ void QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests() QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection); } -void QHttpNetworkConnectionChannel::eatWhitespace() -{ - char c; - do { - qint64 ret = socket->peek(&c, 1); - - // nothing read, fine. - if (ret == 0) - return; - - // EOF from socket? - if (ret == -1) - return; // FIXME, we need to stop processing. however the next stuff done will also do that. - - // read all whitespace and line endings - if (c == 11 || c == '\n' || c == '\r' || c == ' ' || c == 31) { - socket->read(&c, 1); - continue; - } else { - break; - } - } while(true); -} - void QHttpNetworkConnectionChannel::handleStatus() { Q_ASSERT(socket); diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h index e384e9d..4f3a65c 100644 --- a/src/network/access/qhttpnetworkconnectionchannel_p.h +++ b/src/network/access/qhttpnetworkconnectionchannel_p.h @@ -153,8 +153,6 @@ public: void handleUnexpectedEOF(); void closeAndResendCurrentRequest(); - void eatWhitespace(); - bool isSocketBusy() const; bool isSocketWriting() const; bool isSocketWaiting() const; -- cgit v0.12 From 3411ac72ffcbd8152342603152193aa7283bd149 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Fri, 13 Aug 2010 16:42:16 +0200 Subject: Cannot enter text through character viewer on Mac (Cocoa) This text is delivered through the NSTextInput protocol. Since it was not initiated from a keyDown message, we were ignoring the insertText: message. Reviewed-by: Denis --- src/gui/kernel/qcocoaview_mac.mm | 8 +++++++- src/gui/kernel/qcocoaview_mac_p.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 3229e71..0282c79 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -207,6 +207,7 @@ static int qCocoaViewCount = 0; composing = false; sendKeyEvents = true; + fromKeyDownEvent = false; [self setHidden:YES]; return self; } @@ -1215,7 +1216,9 @@ static int qCocoaViewCount = 0; && !(widgetToGetKey->inputMethodHints() & Qt::ImhDigitsOnly || widgetToGetKey->inputMethodHints() & Qt::ImhFormattedNumbersOnly || widgetToGetKey->inputMethodHints() & Qt::ImhHiddenText)) { + fromKeyDownEvent = true; [qt_mac_nativeview_for(widgetToGetKey) interpretKeyEvents:[NSArray arrayWithObject: theEvent]]; + fromKeyDownEvent = false; } if (sendKeyEvents && !composing) { bool keyOK = qt_dispatchKeyEvent(theEvent, widgetToGetKey); @@ -1285,7 +1288,10 @@ static int qCocoaViewCount = 0; }; } - if ([aString length] && composing) { + // When entering characters through Character Viewer or Keyboard Viewer, the text is passed + // through this insertText method. Since we dont receive a keyDown Event in such cases, the + // composing flag will be false. + if (([aString length] && composing) || !fromKeyDownEvent) { // Send the commit string to the widget. composing = false; sendKeyEvents = false; diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h index b6b63ca..511423357 100644 --- a/src/gui/kernel/qcocoaview_mac_p.h +++ b/src/gui/kernel/qcocoaview_mac_p.h @@ -86,6 +86,7 @@ Q_GUI_EXPORT bool composing; int composingLength; bool sendKeyEvents; + bool fromKeyDownEvent; QString *composingText; NSInteger dragEnterSequence; } -- cgit v0.12 From 69fc9e594e6d5da87bff42707973683f84b67c93 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 9 Aug 2010 21:16:27 +0300 Subject: Fix how subpixel positions are intepreted in an aliased grid. With this change we break with the traditional X11 and GDI way of rasterzing aliased polygons, but we become consistent across integer and sub-pixel positions. The new model uses the same rules as the antialised rasterizer which means that a primitive edge on 0.4 becomes 0.0, 0.5 becomes 1 and 0.9 becomes one, which is also in line with how one normally thinks of rounding rules. --- src/gui/painting/qoutlinemapper.cpp | 9 ---- src/gui/painting/qoutlinemapper_p.h | 8 +--- src/gui/painting/qpaintengine_raster.cpp | 70 ++++++++++++-------------------- src/gui/painting/qrasterizer.cpp | 6 +-- 4 files changed, 31 insertions(+), 62 deletions(-) diff --git a/src/gui/painting/qoutlinemapper.cpp b/src/gui/painting/qoutlinemapper.cpp index bf03545..72e5833 100644 --- a/src/gui/painting/qoutlinemapper.cpp +++ b/src/gui/painting/qoutlinemapper.cpp @@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE -static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; - #define qreal_to_fixed_26_6(f) (int(f * 64)) @@ -216,13 +214,6 @@ void QOutlineMapper::endOutline() elements = m_elements_dev.data(); } - if (m_round_coords) { - // round coordinates to match outlines drawn with drawLine_midpoint_i - for (int i = 0; i < m_elements.size(); ++i) - elements[i] = QPointF(qFloor(elements[i].x() + aliasedCoordinateDelta), - qFloor(elements[i].y() + aliasedCoordinateDelta)); - } - controlPointRect = boundingRect(elements, element_count); #ifdef QT_DEBUG_CONVERT diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h index d534f76..fcfc9bf 100644 --- a/src/gui/painting/qoutlinemapper_p.h +++ b/src/gui/painting/qoutlinemapper_p.h @@ -95,8 +95,7 @@ public: m_tags(0), m_contours(0), m_polygon_dev(0), - m_in_clip_elements(false), - m_round_coords(false) + m_in_clip_elements(false) { } @@ -202,8 +201,6 @@ public: QT_FT_Outline *convertPath(const QPainterPath &path); QT_FT_Outline *convertPath(const QVectorPath &path); - void setCoordinateRounding(bool coordinateRounding) { m_round_coords = coordinateRounding; } - inline QPainterPath::ElementType *elementTypes() const { return m_element_types.size() == 0 ? 0 : m_element_types.data(); } public: @@ -237,9 +234,6 @@ public: bool m_valid; bool m_in_clip_elements; - -private: - bool m_round_coords; }; QT_END_NAMESPACE diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 6847e37..fadf917 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -123,9 +123,6 @@ void dumpClip(int width, int height, const QClipData *clip); // 4 pixels. #define int_dim(pos, dim) (int(pos+dim) - int(pos)) -// use the same rounding as in qrasterizer.cpp (6 bit fixed point) -static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; - #ifdef Q_WS_WIN extern bool qt_cleartype_enabled; #endif @@ -1508,6 +1505,8 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); + printf("drawRects (I)\n"); + // Fill ensureBrush(); if (s->brushData.blend) { @@ -1517,6 +1516,9 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) int offset_x = int(s->matrix.dx()); int offset_y = int(s->matrix.dy()); + + printf("drawing rect: %d %d %d %d, offset=%d %d\n", + r->x(), r->y(), r->width(), r->height(), offset_x, offset_y); while (r < lastRect) { QRect rect = r->normalized(); QRect rr = rect.translated(offset_x, offset_y); @@ -1753,10 +1755,10 @@ void QRasterPaintEngine::stroke(const QVectorPath &path, const QPen &pen) static inline QRect toNormalizedFillRect(const QRectF &rect) { - int x1 = qRound(rect.x() + aliasedCoordinateDelta); - int y1 = qRound(rect.y() + aliasedCoordinateDelta); - int x2 = qRound(rect.right() + aliasedCoordinateDelta); - int y2 = qRound(rect.bottom() + aliasedCoordinateDelta); + int x1 = qRound(rect.x()); + int y1 = qRound(rect.y()); + int x2 = qRound(rect.right()); + int y2 = qRound(rect.bottom()); if (x2 < x1) qSwap(x1, x2); @@ -2025,7 +2027,6 @@ void QRasterPaintEngine::fillPolygon(const QPointF *points, int pointCount, Poly */ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) { - Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); #ifdef QT_DEBUG_DRAW @@ -2046,9 +2047,7 @@ void QRasterPaintEngine::drawPolygon(const QPointF *points, int pointCount, Poly if (mode != PolylineMode) { // Do the fill... if (s->brushData.blend) { - d->outlineMapper->setCoordinateRounding(s->penData.blend && s->flags.fast_pen && s->lastPen.brush().isOpaque()); fillPolygon(points, pointCount, mode); - d->outlineMapper->setCoordinateRounding(false); } } @@ -2100,7 +2099,6 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg if (s->brushData.blend) { // Compose polygon fill.., ensureOutlineMapper(); - d->outlineMapper->setCoordinateRounding(s->penData.blend != 0); d->outlineMapper->beginOutline(mode == WindingMode ? Qt::WindingFill : Qt::OddEvenFill); d->outlineMapper->moveTo(*points); const QPoint *p = points; @@ -2114,7 +2112,6 @@ void QRasterPaintEngine::drawPolygon(const QPoint *points, int pointCount, Polyg ProcessSpans brushBlend = d->getBrushFunc(d->outlineMapper->controlPointRect, &s->brushData); d->rasterize(d->outlineMapper->outline(), brushBlend, &s->brushData, d->rasterBuffer.data()); - d->outlineMapper->setCoordinateRounding(false); } } @@ -2162,13 +2159,11 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPointF *points, int pointC : LineDrawNormal); int dashOffset = int(s->lastPen.dashOffset()); - const QPointF offs(aliasedCoordinateDelta, aliasedCoordinateDelta); - // Draw all the line segments. for (int i=1; imatrix + offs; - QPointF lp2 = points[i] * s->matrix + offs; + QPointF lp1 = points[i-1] * s->matrix; + QPointF lp2 = points[i] * s->matrix; const QRectF brect(lp1, lp2); ProcessSpans penBlend = d->getPenFunc(brect, &s->penData); @@ -2190,8 +2185,8 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPointF *points, int pointC // Polygons are implicitly closed. if (needs_closing) { - QPointF lp1 = points[pointCount-1] * s->matrix + offs; - QPointF lp2 = points[0] * s->matrix + offs; + QPointF lp1 = points[pointCount-1] * s->matrix; + QPointF lp2 = points[0] * s->matrix; const QRectF brect(lp1, lp2); ProcessSpans penBlend = d->getPenFunc(brect, &s->penData); @@ -2579,10 +2574,7 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe int sr_b = qCeil(sr.bottom()) - 1; if (s->matrix.type() <= QTransform::TxScale && !s->flags.antialiased && sr_l == sr_r && sr_t == sr_b) { - // as fillRect will apply the aliased coordinate delta we need to - // subtract it here as we don't use it for image drawing QTransform old = s->matrix; - s->matrix = s->matrix * QTransform::fromTranslate(-aliasedCoordinateDelta, -aliasedCoordinateDelta); // Do whatever fillRect() does, but without premultiplying the color if it's already premultiplied. QRgb color = img.pixel(sr_l, sr_t); @@ -2726,11 +2718,9 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe d->initializeRasterizer(&d->image_filler_xform); d->rasterizer->setAntialiased(s->flags.antialiased); - const QPointF offs = s->flags.antialiased ? QPointF() : QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta); - const QRectF &rect = r.normalized(); - const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f) - offs; - const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f) - offs; + const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f); + const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f); if (s->flags.tx_noshear) d->rasterizer->rasterizeLine(a, b, rect.height() / rect.width()); @@ -2739,13 +2729,12 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe return; } #endif - const qreal offs = s->flags.antialiased ? qreal(0) : aliasedCoordinateDelta; QPainterPath path; path.addRect(r); QTransform m = s->matrix; s->matrix = QTransform(m.m11(), m.m12(), m.m13(), m.m21(), m.m22(), m.m23(), - m.m31() - offs, m.m32() - offs, m.m33()); + m.m31(), m.m32(), m.m33()); fillPath(path, &d->image_filler_xform); s->matrix = m; } else { @@ -3114,13 +3103,11 @@ void QRasterPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, int margin = cache->glyphMargin(); - const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta); - const uchar *bits = image.bits(); for (int i=0; icoords.value(glyphs[i]); - int x = qFloor(positions[i].x + offs) + c.baseLineX - margin; - int y = qFloor(positions[i].y + offs) - c.baseLineY - margin; + int x = qFloor(positions[i].x) + c.baseLineX - margin; + int y = qFloor(positions[i].y) - c.baseLineY - margin; // printf("drawing [%d %d %d %d] baseline [%d %d], glyph: %d, to: %d %d, pos: %d %d\n", // c.x, c.y, @@ -3158,16 +3145,14 @@ void QRasterPaintEngine::drawGlyphsS60(const QPointF &p, const QTextItemInt &ti) fe->setFontScale(matrix.m11()); ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); - const QFixed aliasDelta = QFixed::fromReal(aliasedCoordinateDelta); - for (int i=0; igetCharacterData(glyphs[i], tmetrics, glyphBitmapBytes, glyphBitmapSize); const glyph_metrics_t metrics = ti.fontEngine->boundingBox(glyphs[i]); - const int x = qFloor(positions[i].x + metrics.x + aliasDelta); - const int y = qFloor(positions[i].y + metrics.y + aliasDelta); + const int x = qFloor(positions[i].x + metrics.x); + const int y = qFloor(positions[i].y + metrics.y); alphaPenBlt(glyphBitmapBytes, glyphBitmapSize.iWidth, 8, x, y, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight); } @@ -3381,7 +3366,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte #if defined(Q_WS_QWS) if (fontEngine->type() == QFontEngine::Box) { - fontEngine->draw(this, qFloor(p.x() + aliasedCoordinateDelta), qFloor(p.y() + aliasedCoordinateDelta), ti); + fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti); return; } @@ -3390,7 +3375,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte || (fontEngine->type() == QFontEngine::Proxy && !(static_cast(fontEngine)->drawAsOutline())) )) { - fontEngine->draw(this, qFloor(p.x() + aliasedCoordinateDelta), qFloor(p.y() + aliasedCoordinateDelta), ti); + fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti); return; } #endif // Q_WS_QWS @@ -3451,7 +3436,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte return; } - QFixed offs = QFixed::fromReal(aliasedCoordinateDelta); FT_Face lockedFace = 0; int depth; @@ -3499,8 +3483,8 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte }; alphaPenBlt(glyph->data, pitch, depth, - qFloor(positions[i].x + offs) + glyph->x, - qFloor(positions[i].y + offs) - glyph->y, + qFloor(positions[i].x) + glyph->x, + qFloor(positions[i].y) - glyph->y, glyph->width, glyph->height); } if (lockedFace) @@ -3637,8 +3621,8 @@ void QRasterPaintEngine::drawLines(const QLine *lines, int lineCount) int m11 = int(s->matrix.m11()); int m22 = int(s->matrix.m22()); - int dx = qFloor(s->matrix.dx() + aliasedCoordinateDelta); - int dy = qFloor(s->matrix.dy() + aliasedCoordinateDelta); + int dx = qFloor(s->matrix.dx()); + int dy = qFloor(s->matrix.dy()); for (int i=0; ilastPen.dashOffset()); if (s->flags.int_xform) { @@ -3742,7 +3726,7 @@ void QRasterPaintEngine::drawLines(const QLineF *lines, int lineCount) for (int i=0; ilastPen.dashOffset()); - QLineF line = (lines[i] * s->matrix).translated(aliasedCoordinateDelta, aliasedCoordinateDelta); + QLineF line = lines[i] * s->matrix; const QRectF brect(QPointF(line.x1(), line.y1()), QPointF(line.x2(), line.y2())); ProcessSpans penBlend = d->getPenFunc(brect, &s->penData); diff --git a/src/gui/painting/qrasterizer.cpp b/src/gui/painting/qrasterizer.cpp index f8f8afb..c92d8d5 100644 --- a/src/gui/painting/qrasterizer.cpp +++ b/src/gui/painting/qrasterizer.cpp @@ -62,8 +62,8 @@ typedef int Q16Dot16; #define SPAN_BUFFER_SIZE 256 -#define COORD_ROUNDING 1 // 0: round up, 1: round down -#define COORD_OFFSET 32 // 26.6, 32 is half a pixel +#define COORD_ROUNDING 0 // 0: round up, 1: round down +#define COORD_OFFSET 0 // 26.6, 32 is half a pixel class QSpanBuffer { public: @@ -718,7 +718,7 @@ void QRasterizer::rasterizeLine(const QPointF &a, const QPointF &b, qreal width, QPointF pa = a; QPointF pb = b; - QPointF offs = QPointF(qAbs(b.y() - a.y()), qAbs(b.x() - a.x())) * width * 0.5; + QPointF offs = QPointF(qAbs(b.y() - a.y()), qAbs(b.x() - a.x())) * width * 0.5; if (squareCap) offs += QPointF(offs.y(), offs.x()); const QRectF clip(d->clipRect.topLeft() - offs, d->clipRect.bottomRight() + QPoint(1, 1) + offs); -- cgit v0.12 From 8afc6773067bb878020c29b3bebfe8662e3fbfdd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 16 Aug 2010 15:04:17 +0200 Subject: QMetaType: add "signed char" as builtin. According to the c++ specificaiton, 3.9.1 [basic.fundamentals] Plain char, signed char, and unsigned char are three distinct types In QMetaType, I decide that 'signed char' alias with 'char' This allow qint8 to work nice (and which is already registered as an alias to char (QMetaType::Char) Reviewed-by: Joao Task-number: QTBUG-12920 --- src/corelib/kernel/qmetatype.cpp | 1 + src/corelib/kernel/qmetatype.h | 1 + tests/auto/qmetatype/tst_qmetatype.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index fef02cf..bb77d2c 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -311,6 +311,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ QT_ADD_STATIC_METATYPE("long long", QMetaType::LongLong), QT_ADD_STATIC_METATYPE("unsigned long long", QMetaType::ULongLong), QT_ADD_STATIC_METATYPE("qint8", QMetaType::Char), + QT_ADD_STATIC_METATYPE("signed char", QMetaType::Char), QT_ADD_STATIC_METATYPE("quint8", QMetaType::UChar), QT_ADD_STATIC_METATYPE("qint16", QMetaType::Short), QT_ADD_STATIC_METATYPE("quint16", QMetaType::UShort), diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 2108b92..52efcd0 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -355,6 +355,7 @@ Q_DECLARE_BUILTIN_METATYPE(QChar, QChar) Q_DECLARE_BUILTIN_METATYPE(long, Long) Q_DECLARE_BUILTIN_METATYPE(short, Short) Q_DECLARE_BUILTIN_METATYPE(char, Char) +Q_DECLARE_BUILTIN_METATYPE(signed char, Char) Q_DECLARE_BUILTIN_METATYPE(ulong, ULong) Q_DECLARE_BUILTIN_METATYPE(ushort, UShort) Q_DECLARE_BUILTIN_METATYPE(uchar, UChar) diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp index 8558e06..eaa19d0 100644 --- a/tests/auto/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/qmetatype/tst_qmetatype.cpp @@ -160,6 +160,11 @@ void tst_QMetaType::qMetaTypeId() QCOMPARE(::qMetaTypeId(), int(QMetaType::QString)); QCOMPARE(::qMetaTypeId(), int(QMetaType::Int)); QCOMPARE(::qMetaTypeId(), QMetaType::type("TestSpace::Foo")); + + QCOMPARE(::qMetaTypeId(), QMetaType::type("char")); + QCOMPARE(::qMetaTypeId(), QMetaType::type("unsigned char")); + QCOMPARE(::qMetaTypeId(), QMetaType::type("signed char")); + QCOMPARE(::qMetaTypeId(), QMetaType::type("qint8")); } void tst_QMetaType::properties() -- cgit v0.12 From 50a53d2f7a7e12cd597dc72a08ad62b79fee4554 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Tue, 17 Aug 2010 07:27:50 +0200 Subject: fix breakages in qpainter autotests. --- src/gui/painting/qpaintengine_raster.cpp | 5 ----- tests/auto/qpainter/tst_qpainter.cpp | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index fadf917..0b76898 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -1505,8 +1505,6 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) Q_D(QRasterPaintEngine); QRasterPaintEngineState *s = state(); - printf("drawRects (I)\n"); - // Fill ensureBrush(); if (s->brushData.blend) { @@ -1516,9 +1514,6 @@ void QRasterPaintEngine::drawRects(const QRect *rects, int rectCount) int offset_x = int(s->matrix.dx()); int offset_y = int(s->matrix.dy()); - - printf("drawing rect: %d %d %d %d, offset=%d %d\n", - r->x(), r->y(), r->width(), r->height(), offset_x, offset_y); while (r < lastRect) { QRect rect = r->normalized(); QRect rr = rect.translated(offset_x, offset_y); diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp index 9ed212f..11ff319 100644 --- a/tests/auto/qpainter/tst_qpainter.cpp +++ b/tests/auto/qpainter/tst_qpainter.cpp @@ -1300,7 +1300,7 @@ void tst_QPainter::drawRect2() p.end(); QRect stroke = getPaintedSize(image, Qt::white); - QCOMPARE(stroke.adjusted(1, 1, 0, 0), fill.adjusted(0, 0, 1, 1)); + QCOMPARE(stroke, fill.adjusted(0, 0, 1, 1)); } } @@ -1397,13 +1397,13 @@ void tst_QPainter::drawPath_data() { QPainterPath p; p.addRect(2.25, 2.25, 10, 10); - QTest::newRow("non-aligned rect") << p << QRect(3, 3, 10, 10) << 10 * 10; + QTest::newRow("non-aligned rect") << p << QRect(2, 2, 10, 10) << 10 * 10; } { QPainterPath p; p.addRect(2.25, 2.25, 10.5, 10.5); - QTest::newRow("non-aligned rect 2") << p << QRect(3, 3, 10, 10) << 10 * 10; + QTest::newRow("non-aligned rect 2") << p << QRect(2, 2, 11, 11) << 11 * 11; } { -- cgit v0.12 From 08a9924cc69e0c44aae1abfd8500cd62f6e3d73a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Aug 2010 12:29:37 +0200 Subject: Designer: Add 'Simplify rich text' filter to rich text editor. Add an option to filter out style elements created by the text engine to keep the rich text simple. Acked-by: Jarek Kobus Task-number: QTBUG-10890 --- .../src/components/formeditor/formeditor.qrc | 2 + .../formeditor/images/mac/simplifyrichtext.png | Bin 0 -> 1988 bytes .../formeditor/images/win/simplifyrichtext.png | Bin 0 -> 1933 bytes tools/designer/src/lib/shared/richtexteditor.cpp | 202 ++++++++++++++++++--- tools/designer/src/lib/shared/richtexteditor_p.h | 1 + 5 files changed, 178 insertions(+), 27 deletions(-) create mode 100644 tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png create mode 100644 tools/designer/src/components/formeditor/images/win/simplifyrichtext.png diff --git a/tools/designer/src/components/formeditor/formeditor.qrc b/tools/designer/src/components/formeditor/formeditor.qrc index 6510814..ed7e40e 100644 --- a/tools/designer/src/components/formeditor/formeditor.qrc +++ b/tools/designer/src/components/formeditor/formeditor.qrc @@ -153,6 +153,7 @@ images/win/textjustify.png images/win/textsuperscript.png images/win/textsubscript.png + images/win/simplifyrichtext.png images/win/back.png images/win/forward.png images/win/down.png @@ -167,6 +168,7 @@ images/mac/textjustify.png images/mac/textsuperscript.png images/mac/textsubscript.png + images/mac/simplifyrichtext.png defaultbrushes.xml diff --git a/tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png b/tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png new file mode 100644 index 0000000..a48e974 Binary files /dev/null and b/tools/designer/src/components/formeditor/images/mac/simplifyrichtext.png differ diff --git a/tools/designer/src/components/formeditor/images/win/simplifyrichtext.png b/tools/designer/src/components/formeditor/images/win/simplifyrichtext.png new file mode 100644 index 0000000..e251cf7 Binary files /dev/null and b/tools/designer/src/components/formeditor/images/win/simplifyrichtext.png differ diff --git a/tools/designer/src/lib/shared/richtexteditor.cpp b/tools/designer/src/lib/shared/richtexteditor.cpp index ec7c2e5..b5a2618 100644 --- a/tools/designer/src/lib/shared/richtexteditor.cpp +++ b/tools/designer/src/lib/shared/richtexteditor.cpp @@ -52,6 +52,9 @@ #include #include #include +#include +#include +#include #include #include @@ -74,28 +77,129 @@ QT_BEGIN_NAMESPACE -static const char *RichTextDialogC = "RichTextDialog"; -static const char *Geometry = "Geometry"; +static const char RichTextDialogGroupC[] = "RichTextDialog"; +static const char GeometryKeyC[] = "Geometry"; +static const char TabKeyC[] = "Tab"; + +const bool simplifyRichTextDefault = true; namespace qdesigner_internal { +// Richtext simplification filter helpers: Elements to be discarded +static inline bool filterElement(const QStringRef &name) +{ + return name != QLatin1String("meta") && name != QLatin1String("style"); +} + +// Richtext simplification filter helpers: Filter attributes of elements +static inline void filterAttributes(const QStringRef &name, + QXmlStreamAttributes *atts, + bool *paragraphAlignmentFound) +{ + typedef QXmlStreamAttributes::iterator AttributeIt; + + if (atts->isEmpty()) + return; + + // No style attributes for + if (name == QLatin1String("body")) { + atts->clear(); + return; + } + + // Clean out everything except 'align' for 'p' + if (name == QLatin1String("p")) { + for (AttributeIt it = atts->begin(); it != atts->end(); ) { + if (it->name() == QLatin1String("align")) { + ++it; + *paragraphAlignmentFound = true; + } else { + it = atts->erase(it); + } + } + return; + } +} + +// Richtext simplification filter helpers: Check for blank QStringRef. +static inline bool isWhiteSpace(const QStringRef &in) +{ + const int count = in.size(); + for (int i = 0; i < count; i++) + if (!in.at(i).isSpace()) + return false; + return true; +} + +// Richtext simplification filter: Remove hard-coded font settings, +//