src/gui/kernel/qapplication_win.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
--- a/src/gui/kernel/qapplication_win.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/src/gui/kernel/qapplication_win.cpp	Wed Mar 31 11:06:36 2010 +0300
@@ -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)
 **
@@ -115,6 +115,8 @@
 #  include <winable.h>
 #endif
 
+#include "private/qwinnativepangesturerecognizer_win_p.h"
+
 #ifndef WM_TOUCH
 #  define WM_TOUCH 0x0240
 
@@ -928,7 +930,11 @@
     uint style;
     bool icon;
     QString cname;
-    if (flags & Qt::MSWindowsOwnDC) {
+    if (qt_widget_private(w)->isGLWidget) {
+        cname = QLatin1String("QGLWidget");
+        style = CS_DBLCLKS;
+        icon  = true;
+    } else if (flags & Qt::MSWindowsOwnDC) {
         cname = QLatin1String("QWidgetOwnDC");
         style = CS_DBLCLKS;
 #ifndef Q_WS_WINCE
@@ -1021,7 +1027,7 @@
     }
     wc.hCursor      = 0;
 #ifndef Q_WS_WINCE
-    wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
+    wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
 #else
     wc.hbrBackground = 0;
 #endif
@@ -1901,8 +1907,13 @@
                 break;
 
             if (!msg.wParam) {
+#ifdef Q_WS_WINCE
+                // On Windows CE, lParam parameter is a constant, not a char pointer.
+                if (msg.lParam == INI_INTL) {
+#else
                 QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
                 if (area == QLatin1String("intl")) {
+#endif
                     QLocalePrivate::updateSystemPrivate();
                     if (!widget->testAttribute(Qt::WA_SetLocale))
                         widget->dptr()->setLocale_helper(QLocale(), true);
@@ -2515,6 +2526,7 @@
             }
             result = false;
             break;
+#if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
         case WM_GESTURE: {
             GESTUREINFO gi;
             memset(&gi, 0, sizeof(GESTUREINFO));
@@ -2547,6 +2559,7 @@
             result = true;
             break;
         }
+#endif // !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
         default:
             result = false;                        // event was not processed
             break;
@@ -3616,13 +3629,19 @@
         return true;
 
     setAttribute(Qt::WA_PendingUpdate, false);
-    const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
-    // Make sure the invalidated region contains the region we're about to repaint.
-    // BeginPaint will set the clip to the invalidated region and it is impossible
-    // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
-    // as it may return an invalid context (especially on Windows Vista).
-    if (!dirtyInBackingStore.isEmpty())
-        InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
+
+    if (d_func()->isGLWidget) {
+        if (d_func()->usesDoubleBufferedGLContext)
+            InvalidateRect(internalWinId(), 0, false);
+    } else {
+        const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
+        // Make sure the invalidated region contains the region we're about to repaint.
+        // BeginPaint will set the clip to the invalidated region and it is impossible
+        // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
+        // as it may return an invalid context (especially on Windows Vista).
+        if (!dirtyInBackingStore.isEmpty())
+            InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
+    }
     PAINTSTRUCT ps;
     d_func()->hd = BeginPaint(internalWinId(), &ps);
 
@@ -3983,12 +4002,45 @@
 #endif //QT_NO_SESSIONMANAGER
 
 
+bool QApplicationPrivate::HasTouchSupport = false;
 PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0;
 PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0;
 PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0;
 
 void QApplicationPrivate::initializeMultitouch_sys()
 {
+    static const IID QT_IID_IInkTablets = {0x112086D9, 0x7779, 0x4535, {0xA6, 0x99, 0x86, 0x2B, 0x43, 0xAC, 0x18, 0x63} };
+    static const IID QT_IID_IInkTablet2 = {0x90c91ad2, 0xfa36, 0x49d6, {0x95, 0x16, 0xce, 0x8d, 0x57, 0x0f, 0x6f, 0x85} };
+    static const CLSID QT_CLSID_InkTablets = {0x6E4FCB12, 0x510A, 0x4d40, {0x93, 0x04, 0x1D, 0xA1, 0x0A, 0xE9, 0x14, 0x7C} };
+
+    IInkTablets *iInkTablets = 0;
+    HRESULT hr = CoCreateInstance(QT_CLSID_InkTablets, NULL, CLSCTX_ALL, QT_IID_IInkTablets, (void**)&iInkTablets);
+    if (SUCCEEDED(hr)) {
+        long count = 0;
+        iInkTablets->get_Count(&count);
+        for (long i = 0; i < count; ++i) {
+            IInkTablet *iInkTablet = 0;
+            hr = iInkTablets->Item(i, &iInkTablet);
+            if (FAILED(hr))
+                continue;
+            IInkTablet2 *iInkTablet2 = 0;
+            hr = iInkTablet->QueryInterface(QT_IID_IInkTablet2, (void**)&iInkTablet2);
+            iInkTablet->Release();
+            if (FAILED(hr))
+                continue;
+            TabletDeviceKind kind;
+            hr = iInkTablet2->get_DeviceKind(&kind);
+            iInkTablet2->Release();
+            if (FAILED(hr))
+                continue;
+            if (kind == TDK_Touch) {
+                QApplicationPrivate::HasTouchSupport = true;
+                break;
+            }
+        }
+        iInkTablets->Release();
+    }
+
     QLibrary library(QLatin1String("user32"));
     // MinGW (g++ 3.4.5) accepts only C casts.
     RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));