src/gui/kernel/qapplication_win.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
   113 #    include <bldver.h>
   113 #    include <bldver.h>
   114 #  endif
   114 #  endif
   115 #  include <winable.h>
   115 #  include <winable.h>
   116 #endif
   116 #endif
   117 
   117 
       
   118 #include "private/qwinnativepangesturerecognizer_win_p.h"
       
   119 
   118 #ifndef WM_TOUCH
   120 #ifndef WM_TOUCH
   119 #  define WM_TOUCH 0x0240
   121 #  define WM_TOUCH 0x0240
   120 
   122 
   121 #  define TOUCHEVENTF_MOVE       0x0001
   123 #  define TOUCHEVENTF_MOVE       0x0001
   122 #  define TOUCHEVENTF_DOWN       0x0002
   124 #  define TOUCHEVENTF_DOWN       0x0002
   926     int type = flags & Qt::WindowType_Mask;
   928     int type = flags & Qt::WindowType_Mask;
   927 
   929 
   928     uint style;
   930     uint style;
   929     bool icon;
   931     bool icon;
   930     QString cname;
   932     QString cname;
   931     if (flags & Qt::MSWindowsOwnDC) {
   933     if (qt_widget_private(w)->isGLWidget) {
       
   934         cname = QLatin1String("QGLWidget");
       
   935         style = CS_DBLCLKS;
       
   936         icon  = true;
       
   937     } else if (flags & Qt::MSWindowsOwnDC) {
   932         cname = QLatin1String("QWidgetOwnDC");
   938         cname = QLatin1String("QWidgetOwnDC");
   933         style = CS_DBLCLKS;
   939         style = CS_DBLCLKS;
   934 #ifndef Q_WS_WINCE
   940 #ifndef Q_WS_WINCE
   935         style |= CS_OWNDC;
   941         style |= CS_OWNDC;
   936 #endif
   942 #endif
  1019     } else {
  1025     } else {
  1020         wc.hIcon    = 0;
  1026         wc.hIcon    = 0;
  1021     }
  1027     }
  1022     wc.hCursor      = 0;
  1028     wc.hCursor      = 0;
  1023 #ifndef Q_WS_WINCE
  1029 #ifndef Q_WS_WINCE
  1024     wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
  1030     wc.hbrBackground = qt_widget_private(w)->isGLWidget ? 0 : (HBRUSH)GetSysColorBrush(COLOR_WINDOW);
  1025 #else
  1031 #else
  1026     wc.hbrBackground = 0;
  1032     wc.hbrBackground = 0;
  1027 #endif
  1033 #endif
  1028     wc.lpszMenuName  = 0;
  1034     wc.lpszMenuName  = 0;
  1029     wc.lpszClassName = (wchar_t*)cname.utf16();
  1035     wc.lpszClassName = (wchar_t*)cname.utf16();
  1899         case WM_SETTINGCHANGE:
  1905         case WM_SETTINGCHANGE:
  1900             if ( QApplication::type() == QApplication::Tty )
  1906             if ( QApplication::type() == QApplication::Tty )
  1901                 break;
  1907                 break;
  1902 
  1908 
  1903             if (!msg.wParam) {
  1909             if (!msg.wParam) {
       
  1910 #ifdef Q_WS_WINCE
       
  1911                 // On Windows CE, lParam parameter is a constant, not a char pointer.
       
  1912                 if (msg.lParam == INI_INTL) {
       
  1913 #else
  1904                 QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
  1914                 QString area = QString::fromWCharArray((wchar_t*)msg.lParam);
  1905                 if (area == QLatin1String("intl")) {
  1915                 if (area == QLatin1String("intl")) {
       
  1916 #endif
  1906                     QLocalePrivate::updateSystemPrivate();
  1917                     QLocalePrivate::updateSystemPrivate();
  1907                     if (!widget->testAttribute(Qt::WA_SetLocale))
  1918                     if (!widget->testAttribute(Qt::WA_SetLocale))
  1908                         widget->dptr()->setLocale_helper(QLocale(), true);
  1919                         widget->dptr()->setLocale_helper(QLocale(), true);
  1909                 }
  1920                 }
  1910             }
  1921             }
  2513                         SetCapture(autoCaptureWnd);
  2524                         SetCapture(autoCaptureWnd);
  2514                 }
  2525                 }
  2515             }
  2526             }
  2516             result = false;
  2527             result = false;
  2517             break;
  2528             break;
       
  2529 #if !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
  2518         case WM_GESTURE: {
  2530         case WM_GESTURE: {
  2519             GESTUREINFO gi;
  2531             GESTUREINFO gi;
  2520             memset(&gi, 0, sizeof(GESTUREINFO));
  2532             memset(&gi, 0, sizeof(GESTUREINFO));
  2521             gi.cbSize = sizeof(GESTUREINFO);
  2533             gi.cbSize = sizeof(GESTUREINFO);
  2522 
  2534 
  2545                     qWarning() << "translateGestureEvent: error = " << dwErr;
  2557                     qWarning() << "translateGestureEvent: error = " << dwErr;
  2546             }
  2558             }
  2547             result = true;
  2559             result = true;
  2548             break;
  2560             break;
  2549         }
  2561         }
       
  2562 #endif // !defined(Q_WS_WINCE) || defined(QT_WINCE_GESTURES)
  2550         default:
  2563         default:
  2551             result = false;                        // event was not processed
  2564             result = false;                        // event was not processed
  2552             break;
  2565             break;
  2553         }
  2566         }
  2554     }
  2567     }
  3614 
  3627 
  3615     if (msg.message == WM_ERASEBKGND)
  3628     if (msg.message == WM_ERASEBKGND)
  3616         return true;
  3629         return true;
  3617 
  3630 
  3618     setAttribute(Qt::WA_PendingUpdate, false);
  3631     setAttribute(Qt::WA_PendingUpdate, false);
  3619     const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
  3632 
  3620     // Make sure the invalidated region contains the region we're about to repaint.
  3633     if (d_func()->isGLWidget) {
  3621     // BeginPaint will set the clip to the invalidated region and it is impossible
  3634         if (d_func()->usesDoubleBufferedGLContext)
  3622     // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
  3635             InvalidateRect(internalWinId(), 0, false);
  3623     // as it may return an invalid context (especially on Windows Vista).
  3636     } else {
  3624     if (!dirtyInBackingStore.isEmpty())
  3637         const QRegion dirtyInBackingStore(qt_dirtyRegion(this));
  3625         InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
  3638         // Make sure the invalidated region contains the region we're about to repaint.
       
  3639         // BeginPaint will set the clip to the invalidated region and it is impossible
       
  3640         // to enlarge it afterwards (only shrink it). Using GetDCEx is not suffient
       
  3641         // as it may return an invalid context (especially on Windows Vista).
       
  3642         if (!dirtyInBackingStore.isEmpty())
       
  3643             InvalidateRgn(internalWinId(), dirtyInBackingStore.handle(), false);
       
  3644     }
  3626     PAINTSTRUCT ps;
  3645     PAINTSTRUCT ps;
  3627     d_func()->hd = BeginPaint(internalWinId(), &ps);
  3646     d_func()->hd = BeginPaint(internalWinId(), &ps);
  3628 
  3647 
  3629     const QRect updateRect(QPoint(ps.rcPaint.left, ps.rcPaint.top),
  3648     const QRect updateRect(QPoint(ps.rcPaint.left, ps.rcPaint.top),
  3630                            QPoint(ps.rcPaint.right, ps.rcPaint.bottom));
  3649                            QPoint(ps.rcPaint.right, ps.rcPaint.bottom));
  3981 }
  4000 }
  3982 
  4001 
  3983 #endif //QT_NO_SESSIONMANAGER
  4002 #endif //QT_NO_SESSIONMANAGER
  3984 
  4003 
  3985 
  4004 
       
  4005 bool QApplicationPrivate::HasTouchSupport = false;
  3986 PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0;
  4006 PtrRegisterTouchWindow QApplicationPrivate::RegisterTouchWindow = 0;
  3987 PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0;
  4007 PtrGetTouchInputInfo QApplicationPrivate::GetTouchInputInfo = 0;
  3988 PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0;
  4008 PtrCloseTouchInputHandle QApplicationPrivate::CloseTouchInputHandle = 0;
  3989 
  4009 
  3990 void QApplicationPrivate::initializeMultitouch_sys()
  4010 void QApplicationPrivate::initializeMultitouch_sys()
  3991 {
  4011 {
       
  4012     static const IID QT_IID_IInkTablets = {0x112086D9, 0x7779, 0x4535, {0xA6, 0x99, 0x86, 0x2B, 0x43, 0xAC, 0x18, 0x63} };
       
  4013     static const IID QT_IID_IInkTablet2 = {0x90c91ad2, 0xfa36, 0x49d6, {0x95, 0x16, 0xce, 0x8d, 0x57, 0x0f, 0x6f, 0x85} };
       
  4014     static const CLSID QT_CLSID_InkTablets = {0x6E4FCB12, 0x510A, 0x4d40, {0x93, 0x04, 0x1D, 0xA1, 0x0A, 0xE9, 0x14, 0x7C} };
       
  4015 
       
  4016     IInkTablets *iInkTablets = 0;
       
  4017     HRESULT hr = CoCreateInstance(QT_CLSID_InkTablets, NULL, CLSCTX_ALL, QT_IID_IInkTablets, (void**)&iInkTablets);
       
  4018     if (SUCCEEDED(hr)) {
       
  4019         long count = 0;
       
  4020         iInkTablets->get_Count(&count);
       
  4021         for (long i = 0; i < count; ++i) {
       
  4022             IInkTablet *iInkTablet = 0;
       
  4023             hr = iInkTablets->Item(i, &iInkTablet);
       
  4024             if (FAILED(hr))
       
  4025                 continue;
       
  4026             IInkTablet2 *iInkTablet2 = 0;
       
  4027             hr = iInkTablet->QueryInterface(QT_IID_IInkTablet2, (void**)&iInkTablet2);
       
  4028             iInkTablet->Release();
       
  4029             if (FAILED(hr))
       
  4030                 continue;
       
  4031             TabletDeviceKind kind;
       
  4032             hr = iInkTablet2->get_DeviceKind(&kind);
       
  4033             iInkTablet2->Release();
       
  4034             if (FAILED(hr))
       
  4035                 continue;
       
  4036             if (kind == TDK_Touch) {
       
  4037                 QApplicationPrivate::HasTouchSupport = true;
       
  4038                 break;
       
  4039             }
       
  4040         }
       
  4041         iInkTablets->Release();
       
  4042     }
       
  4043 
  3992     QLibrary library(QLatin1String("user32"));
  4044     QLibrary library(QLatin1String("user32"));
  3993     // MinGW (g++ 3.4.5) accepts only C casts.
  4045     // MinGW (g++ 3.4.5) accepts only C casts.
  3994     RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
  4046     RegisterTouchWindow = (PtrRegisterTouchWindow)(library.resolve("RegisterTouchWindow"));
  3995     GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
  4047     GetTouchInputInfo = (PtrGetTouchInputInfo)(library.resolve("GetTouchInputInfo"));
  3996     CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));
  4048     CloseTouchInputHandle = (PtrCloseTouchInputHandle)(library.resolve("CloseTouchInputHandle"));