Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/kernel/qwidget_win.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5757#include "private/qwindowsurface_raster_p.h"
    5858
    59 #ifndef QT_NO_DIRECT3D
    60 #include "private/qpaintengine_d3d_p.h"
    61 #include "private/qwindowsurface_d3d_p.h"
    62 #endif
    63 
     59#include "qscrollbar.h"
     60#include "qabstractscrollarea.h"
     61#include <private/qabstractscrollarea_p.h>
    6462
    6563#include <qdebug.h>
     
    6967#include <private/qpaintengine_raster_p.h>
    7068
    71 #if defined(Q_OS_WINCE)
     69#if defined(Q_WS_WINCE)
    7270#include "qguifunctions_wince.h"
    7371QT_USE_NAMESPACE
     
    147145        return;
    148146    QLibrary library(QLatin1String("wintab32"));
    149     QT_WA({
    150         ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW");
    151         ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
    152     } , {
    153         ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenA");
    154         ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoA");
    155     });
    156 
     147    ptrWTOpen = (PtrWTOpen)library.resolve("WTOpenW");
     148    ptrWTInfo = (PtrWTInfo)library.resolve("WTInfoW");
    157149    ptrWTClose = (PtrWTClose)library.resolve("WTClose");
    158150    ptrWTQueueSizeGet = (PtrWTQueueSizeGet)library.resolve("WTQueueSizeGet");
     
    170162    qt_tablet_widget->createWinId();
    171163    qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget"));
     164    // We dont need this internal widget to appear in QApplication::topLevelWidgets()
     165    if (QWidgetPrivate::allWidgets)
     166        QWidgetPrivate::allWidgets->remove(qt_tablet_widget);
    172167    LOGCONTEXT lcMine;
    173168    qAddPostRoutine(qt_tablet_cleanup);
     
    258253 *****************************************************************************/
    259254
    260 #ifndef Q_OS_WINCE
     255#ifndef Q_WS_WINCE
    261256void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
    262257{
     
    277272    HINSTANCE appinst  = qWinAppInst();
    278273    HWND parentw, destroyw = 0;
    279     WId id;
     274    WId id = 0;
    280275
    281276    QString windowClassName = qt_reg_winclass(q);
     
    294289    if (desktop && !q->testAttribute(Qt::WA_DontShowOnScreen)) {                                // desktop widget
    295290        popup = false;                                // force this flags off
    296         if (QSysInfo::WindowsVersion != QSysInfo::WV_NT && QSysInfo::WindowsVersion != QSysInfo::WV_95)
    297             data.crect.setRect(GetSystemMetrics(76 /* SM_XVIRTUALSCREEN  */), GetSystemMetrics(77 /* SM_YVIRTUALSCREEN  */),
     291        data.crect.setRect(GetSystemMetrics(76 /* SM_XVIRTUALSCREEN  */), GetSystemMetrics(77 /* SM_YVIRTUALSCREEN  */),
    298292                           GetSystemMetrics(78 /* SM_CXVIRTUALSCREEN */), GetSystemMetrics(79 /* SM_CYVIRTUALSCREEN */));
    299         else
    300             data.crect.setRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
    301293    }
    302294
    303295    parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0;
    304296
    305 #ifdef UNICODE
    306297    QString title;
    307     const TCHAR *ttitle = 0;
    308 #endif
    309     QByteArray title95;
    310298    int style = WS_CHILD;
    311299    int exsty = 0;
    312300
    313301    if (window) {
    314         style = GetWindowLongA(window, GWL_STYLE);
     302        style = GetWindowLong(window, GWL_STYLE);
    315303        if (!style)
    316304            qErrnoWarning("QWidget::create: GetWindowLong failed");
     
    368356
    369357    if (flags & Qt::WindowTitleHint) {
    370         QT_WA({
    371             title = q->isWindow() ? qAppName() : q->objectName();
    372             ttitle = (TCHAR*)title.utf16();
    373         } , {
    374             title95 = q->isWindow() ? qAppName().toLocal8Bit() : q->objectName().toLatin1();
    375         });
     358        title = q->isWindow() ? qAppName() : q->objectName();
    376359    }
    377360
     
    386369        id = window;
    387370        setWinId(window);
    388         LONG res = SetWindowLongA(window, GWL_STYLE, style);
     371        LONG res = SetWindowLong(window, GWL_STYLE, style);
    389372        if (!res)
    390373            qErrnoWarning("QWidget::create: Failed to set window style");
    391374#ifdef _WIN64
    392         res = SetWindowLongPtrA( window, GWLP_WNDPROC, (LONG_PTR)QtWndProc );
     375        res = SetWindowLongPtr( window, GWLP_WNDPROC, (LONG_PTR)QtWndProc );
    393376#else
    394         res = SetWindowLongA( window, GWL_WNDPROC, (LONG)QtWndProc );
     377        res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc );
    395378#endif
    396379        if (!res)
     
    443426        }
    444427
    445         QT_WA({
    446             const TCHAR *cname = (TCHAR*)windowClassName.utf16();
    447             id = CreateWindowEx(exsty, cname, ttitle, style,
    448                                 x, y, w, h,
    449                                 parentw, 0, appinst, 0);
    450         } , {
    451             id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style,
    452                                  x, y, w, h,
    453                                  parentw, 0, appinst, 0);
    454         });
     428        id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
     429                            reinterpret_cast<const wchar_t *>(title.utf16()), style,
     430                            x, y, w, h,
     431                            parentw, NULL, appinst, NULL);
    455432        if (!id)
    456433            qErrnoWarning("QWidget::create: Failed to create window");
     
    464441        winUpdateIsOpaque();
    465442    } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget
    466         QT_WA({
    467             const TCHAR *cname = (TCHAR*)windowClassName.utf16();
    468             id = CreateWindowEx(exsty, cname, ttitle, style,
    469                                 data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
     443        id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
     444                            reinterpret_cast<const wchar_t *>(title.utf16()), style,
     445                            data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
    470446                            parentw, NULL, appinst, NULL);
    471         } , {
    472             id = CreateWindowExA(exsty, windowClassName.toLatin1(), title95, style,
    473                                  data.crect.left(), data.crect.top(), data.crect.width(), data.crect.height(),
    474                             parentw, NULL, appinst, NULL);
    475         });
    476447        if (!id)
    477448            qErrnoWarning("QWidget::create: Failed to create window");
     
    504475    }
    505476
     477    if (topLevel) {
     478        if (data.window_flags & Qt::CustomizeWindowHint
     479            && data.window_flags & Qt::WindowTitleHint) {
     480            HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE);
     481            if (data.window_flags & Qt::WindowCloseButtonHint)
     482                EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
     483            else
     484                EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
     485        }
     486    }
     487
    506488    q->setAttribute(Qt::WA_WState_Created);                // accept move/resize events
    507489    hd = 0;                                        // no display context
     490
     491    if (q->testAttribute(Qt::WA_AcceptTouchEvents))
     492        registerTouchWindow();
    508493
    509494    if (window) {                                // got window from outside
     
    547532}
    548533
    549 #endif //Q_OS_WINCE
     534#endif //Q_WS_WINCE
    550535
    551536
     
    554539    Q_D(QWidget);
    555540    if (!isWindow() && parentWidget())
    556         parentWidget()->d_func()->invalidateBuffer(geometry());
     541        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
    557542    d->deactivateWidgetCleanup();
    558543    if (testAttribute(Qt::WA_WState_Created)) {
     
    575560            DestroyWindow(internalWinId());
    576561        }
    577 #ifdef Q_OS_WINCE
     562#ifdef Q_WS_WINCE
    578563        if (destroyWindow && (windowType() == Qt::Desktop) && !GetDesktopWindow()) {
    579564            DestroyWindow(internalWinId());
     
    581566
    582567#endif
    583         d->setWinId(0);
     568        QT_TRY {
     569            d->setWinId(0);
     570        } QT_CATCH (const std::bad_alloc &) {
     571            // swallow - destructors must not throw
     572        }
    584573    }
    585574}
     
    616605    bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
    617606    if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
    618         q->parentWidget()->d_func()->invalidateBuffer(q->geometry());
     607        q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
    619608
    620609    WId old_winid = data.winid;
     
    672661        q->setAttribute(Qt::WA_DropSiteRegistered, true);
    673662
    674 
    675     if (data.window_flags & Qt::CustomizeWindowHint
    676         && data.window_flags & Qt::WindowTitleHint) {
    677         HMENU systemMenu = GetSystemMenu((HWND)q->internalWinId(), FALSE);
    678         if (data.window_flags & Qt::WindowCloseButtonHint)
    679             EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
    680         else
    681             EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
    682     }
    683 
    684 #ifdef Q_OS_WINCE
     663#ifdef Q_WS_WINCE
    685664    // Show borderless toplevel windows in tasklist & NavBar
    686665    if (!parent) {
    687666        QString txt = q->windowTitle().isEmpty()?qAppName():q->windowTitle();
    688         SetWindowText(q->internalWinId(), (TCHAR*)txt.utf16());
     667        SetWindowText(q->internalWinId(), (wchar_t*)txt.utf16());
    689668    }
    690669#endif
     
    699678    QWExtra *extra = parentWindow->d_func()->extra;
    700679    if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId()
    701         || (extra && extra->proxyWidget)) {
     680        || (extra
     681#ifndef QT_NO_GRAPHICSVIEW
     682            && extra->proxyWidget
     683#endif //QT_NO_GRAPHICSVIEW
     684            )) {
    702685        if (extra && extra->topextra && extra->topextra->embedded) {
    703686            QPoint pt = mapTo(parentWindow, pos);
     
    726709    QWExtra *extra = parentWindow->d_func()->extra;
    727710    if (!isVisible() || parentWindow->isMinimized() || !testAttribute(Qt::WA_WState_Created) || !internalWinId()
    728         || (extra && extra->proxyWidget)) {
     711        || (extra
     712#ifndef QT_NO_GRAPHICSVIEW
     713            && extra->proxyWidget
     714#endif //QT_NO_GRAPHICSVIEW
     715            )) {
    729716        if (extra && extra->topextra && extra->topextra->embedded) {
    730717            POINT p = {pos.x(), pos.y()};
     
    747734void QWidgetPrivate::updateSystemBackground() {}
    748735
    749 extern void qt_win_set_cursor(QWidget *, bool); // qapplication_win.cpp
    750 
    751736#ifndef QT_NO_CURSOR
    752737void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
     
    771756
    772757    Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
    773     QT_WA({
    774         SetWindowText(q->internalWinId(), (TCHAR*)caption.utf16());
    775     } , {
    776         SetWindowTextA(q->internalWinId(), caption.toLocal8Bit());
    777     });
    778 }
    779 
    780 /*
    781   Create an icon mask the way Windows wants it using CreateBitmap.
    782 */
    783 
    784 HBITMAP qt_createIconMask(const QBitmap &bitmap)
    785 {
    786     QImage bm = bitmap.toImage().convertToFormat(QImage::Format_Mono);
    787     int w = bm.width();
    788     int h = bm.height();
    789     int bpl = ((w+15)/16)*2;                        // bpl, 16 bit alignment
    790     uchar *bits = new uchar[bpl*h];
    791     bm.invertPixels();
    792     for (int y=0; y<h; y++)
    793         memcpy(bits+y*bpl, bm.scanLine(y), bpl);
    794     HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits);
    795     delete [] bits;
    796     return hbm;
     758    SetWindowText(q->internalWinId(), (wchar_t*)caption.utf16());
    797759}
    798760
     
    806768            return 0;
    807769
    808         QBitmap mask = pm.mask();
    809         if (mask.isNull()) {
    810             mask = QBitmap(pm.size());
    811             mask.fill(Qt::color1);
    812         }
    813 
    814         HBITMAP im = qt_createIconMask(mask);
    815         ICONINFO ii;
    816         ii.fIcon    = true;
    817         ii.hbmMask  = im;
    818         ii.hbmColor = pm.toWinHBITMAP(QPixmap::Alpha);
    819         ii.xHotspot = 0;
    820         ii.yHotspot = 0;
    821         result = CreateIconIndirect(&ii);
     770        result = pm.toWinHICON();
    822771
    823772        if (cache) {
     
    825774            *cache = new QPixmap(pm);;
    826775        }
    827         DeleteObject(ii.hbmColor);
    828         DeleteObject(im);
    829776    }
    830777    return result;
     
    857804                                  &(x->iconPixmap));
    858805    if (x->winIconBig) {
    859         SendMessageA(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
    860         SendMessageA(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconBig);
     806        SendMessage(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
     807        SendMessage(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconBig);
    861808    } else {
    862         SendMessageA(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
    863         SendMessageA(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconSmall);
     809        SendMessage(q->internalWinId(), WM_SETICON, 0 /* ICON_SMALL */, (LPARAM)x->winIconSmall);
     810        SendMessage(q->internalWinId(), WM_SETICON, 1 /* ICON_BIG */, (LPARAM)x->winIconSmall);
    864811    }
    865812}
     
    878825
    879826// The procedure does nothing, but is required for mousegrabbing to work
    880 #ifndef Q_OS_WINCE
     827#ifndef Q_WS_WINCE
    881828LRESULT CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)
    882829{
    883830    return CallNextHookEx(journalRec, nCode, wParam, lParam);
    884831}
    885 #endif //Q_OS_WINCE
     832#endif //Q_WS_WINCE
    886833
    887834/* Works only as long as pointer is inside the application's window,
    888835   which is good enough for QDockWidget.
    889836
    890    Doesn't call SetWindowsHookExA() - this function causes a system-wide
     837   Doesn't call SetWindowsHookEx() - this function causes a system-wide
    891838   freeze if any other app on the system installs a hook and fails to
    892839   process events. */
     
    906853}
    907854
    908 #ifndef Q_OS_WINCE
     855#ifndef Q_WS_WINCE
    909856void QWidget::grabMouse()
    910857{
     
    912859        if (mouseGrb)
    913860            mouseGrb->releaseMouse();
    914         journalRec = SetWindowsHookExA(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandleA(0), 0);
     861        journalRec = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandle(0), 0);
    915862        Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    916863        SetCapture(effectiveWinId());
    917864        mouseGrb = this;
     865#ifndef QT_NO_CURSOR
    918866        mouseGrbCur = new QCursor(mouseGrb->cursor());
    919     }
    920 }
    921 
     867#endif
     868    }
     869}
     870
     871#ifndef QT_NO_CURSOR
    922872void QWidget::grabMouse(const QCursor &cursor)
    923873{
     
    925875        if (mouseGrb)
    926876            mouseGrb->releaseMouse();
    927         journalRec = SetWindowsHookExA(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandleA(0), 0);
     877        journalRec = SetWindowsHookEx(WH_JOURNALRECORD, (HOOKPROC)qJournalRecordProc, GetModuleHandle(0), 0);
    928878        Q_ASSERT(testAttribute(Qt::WA_WState_Created));
    929879        SetCapture(effectiveWinId());
     
    933883    }
    934884}
     885#endif
    935886
    936887void QWidget::releaseMouse()
     
    983934}
    984935
    985 #ifndef Q_OS_WINCE
     936#ifndef Q_WS_WINCE
    986937void QWidget::setWindowState(Qt::WindowStates newstate)
    987938{
     
    1032983                if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
    1033984                    d->topData()->normalGeometry = geometry();
    1034                 d->topData()->savedFlags = GetWindowLongA(internalWinId(), GWL_STYLE);
     985                d->topData()->savedFlags = Qt::WindowFlags(GetWindowLong(internalWinId(), GWL_STYLE));
    1035986#ifndef Q_FLATTEN_EXPOSE
    1036987                UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
     
    1038989                UINT style = WS_POPUP;
    1039990#endif
    1040                 if (d->topData()->savedFlags & WS_SYSMENU)
     991                if (ulong(d->topData()->savedFlags) & WS_SYSMENU)
    1041992                    style |= WS_SYSMENU;
    1042993                if (isVisible())
    1043994                    style |= WS_VISIBLE;
    1044                 SetWindowLongA(internalWinId(), GWL_STYLE, style);
    1045                 QRect r = qApp->desktop()->screenGeometry(this);
     995                SetWindowLong(internalWinId(), GWL_STYLE, style);
     996                QRect r = QApplication::desktop()->screenGeometry(this);
    1046997                UINT swpf = SWP_FRAMECHANGED;
    1047998                if (newstate & Qt::WindowActive)
     
    10541005                if (isVisible())
    10551006                    style |= WS_VISIBLE;
    1056                 SetWindowLongA(internalWinId(), GWL_STYLE, style);
     1007                SetWindowLong(internalWinId(), GWL_STYLE, style);
    10571008
    10581009                UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
     
    10851036    QApplication::sendEvent(this, &e);
    10861037}
    1087 #endif //Q_OS_WINCE
     1038#endif //Q_WS_WINCE
    10881039
    10891040
     
    10981049    deactivateWidgetCleanup();
    10991050    Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
    1100 #ifdef Q_OS_WINCE
     1051#ifdef Q_WS_WINCE
    11011052    if (!qt_wince_is_mobile() && q->isFullScreen()) {
    11021053        HWND handle = FindWindow(L"HHTaskBar", L"");
     
    11271078  Platform-specific part of QWidget::show().
    11281079*/
    1129 #ifndef Q_OS_WINCE
     1080#ifndef Q_WS_WINCE
    11301081void QWidgetPrivate::show_sys()
    11311082{
     
    11931144    }
    11941145
     1146    winSetupGestures();
     1147
    11951148    invalidateBuffer(q->rect());
    11961149}
    1197 #endif //Q_OS_WINCE
     1150#endif //Q_WS_WINCE
    11981151
    11991152void QWidgetPrivate::setFocus_sys()
     
    12411194 */
    12421195
    1243 void QWidgetPrivate::setWSGeometry(bool dontShow)
     1196void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &)
    12441197{
    12451198    Q_Q(QWidget);
     
    13871340        ValidateRgn(q->internalWinId(), 0);
    13881341
     1342#ifdef Q_WS_WINCE
     1343    // On Windows CE we can't just fiddle around with the window state.
     1344    // Too much magic in setWindowState.
     1345    if (isResize && q->isMaximized())
     1346        q->setWindowState(q->windowState() & ~Qt::WindowMaximized);
     1347#else
    13891348    if (isResize)
    13901349        data.window_state &= ~Qt::WindowMaximized;
     1350#endif
    13911351
    13921352    if (data.window_state & Qt::WindowFullScreen) {
     
    13991359            if (q->isVisible())
    14001360                style |= WS_VISIBLE;
    1401             SetWindowLongA(q->internalWinId(), GWL_STYLE, style);
     1361            SetWindowLong(q->internalWinId(), GWL_STYLE, style);
    14021362
    14031363            UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
     
    14141374    const bool inTopLevelResize = tlwExtra ? tlwExtra->inTopLevelResize : false;
    14151375    const bool isTranslucentWindow = !isOpaque && ptrUpdateLayeredWindowIndirect && (data.window_flags & Qt::FramelessWindowHint)
    1416                                      && GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED;
     1376                                     && GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED;
    14171377
    14181378    if (q->testAttribute(Qt::WA_WState_ConfigPending)) {        // processing config event
     
    14531413            } else if (!q->testAttribute(Qt::WA_DontShowOnScreen)) {
    14541414                q->setAttribute(Qt::WA_OutsideWSRange, false);
    1455 #ifndef Q_OS_WINCE
     1415#ifndef Q_WS_WINCE
    14561416                // If the window is hidden and in maximized state or minimized, instead of moving the
    14571417                // window, set the normal position of the window.
     
    14651425                } else {
    14661426#else
    1467                 if (data.window_state_internal & Qt::WindowMaximized) {
     1427                if (data.window_state & Qt::WindowMaximized) {
    14681428                    qt_wince_maximize(q);
    14691429                } else {
    14701430#endif
    1471                     if (!isTranslucentWindow)
    1472                         MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true);
    1473                     else if (isMove && !isResize)
    1474                         SetWindowPos(q->internalWinId(), 0, fs.x(), fs.y(), 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
     1431                    MoveWindow(q->internalWinId(), fs.x(), fs.y(), fs.width(), fs.height(), true);
    14751432                }
    14761433                if (!q->isVisible())
     
    15621519    if (data.window_flags & Qt::MSWindowsFixedSizeDialogHint)
    15631520        return false;
     1521    // if the user explicitely asked for the maximize button, we try to add
     1522    // it even if the window has fixed size.
     1523    if (data.window_flags & Qt::CustomizeWindowHint &&
     1524        data.window_flags & Qt::WindowMaximizeButtonHint)
     1525        return true;
    15641526    if (extra) {
    15651527        if ((extra->maxw && extra->maxw != QWIDGETSIZE_MAX && extra->maxw != QLAYOUTSIZE_MAX)
     
    15721534void QWidgetPrivate::winUpdateIsOpaque()
    15731535{
    1574 #ifndef Q_OS_WINCE
     1536#ifndef Q_WS_WINCE
    15751537    Q_Q(QWidget);
    15761538
     
    15821544
    15831545    if (!isOpaque && ptrUpdateLayeredWindowIndirect) {
    1584         SetWindowLongA(q->internalWinId(), GWL_EXSTYLE,
    1585             GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) | Q_WS_EX_LAYERED);
     1546        SetWindowLong(q->internalWinId(), GWL_EXSTYLE,
     1547            GetWindowLong(q->internalWinId(), GWL_EXSTYLE) | Q_WS_EX_LAYERED);
    15861548    } else {
    1587         SetWindowLongA(q->internalWinId(), GWL_EXSTYLE,
    1588             GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED);
     1549        SetWindowLong(q->internalWinId(), GWL_EXSTYLE,
     1550            GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & ~Q_WS_EX_LAYERED);
    15891551    }
    15901552#endif
     
    15931555void QWidgetPrivate::setConstraints_sys()
    15941556{
    1595 #ifndef Q_OS_WINCE_WM
     1557#ifndef Q_WS_WINCE_WM
    15961558    Q_Q(QWidget);
    15971559    if (q->isWindow() && q->testAttribute(Qt::WA_WState_Created)) {
    1598         int style = GetWindowLongA(q->internalWinId(), GWL_STYLE);
     1560        int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
    15991561        if (shouldShowMaximizeButton())
    16001562            style |= WS_MAXIMIZEBOX;
    16011563        else
    16021564            style &= ~WS_MAXIMIZEBOX;
    1603         SetWindowLongA(q->internalWinId(), GWL_STYLE, style);
     1565        SetWindowLong(q->internalWinId(), GWL_STYLE, style);
    16041566    }
    16051567#endif
     
    17111673}
    17121674
    1713 #ifndef Q_OS_WINCE
    17141675void QWidgetPrivate::createSysExtra()
    17151676{
     
    17171678    extra->dropTarget = 0;
    17181679#endif
    1719 #ifndef QT_NO_DIRECT3D
    1720     extra->had_auto_fill_bg = 0;
    1721     extra->had_paint_on_screen = 0;
    1722     extra->had_no_system_bg = 0;
    1723 #endif
    1724 }
    1725 
     1680}
     1681
     1682#ifndef Q_WS_WINCE
    17261683void QWidgetPrivate::deleteSysExtra()
    17271684{
    17281685}
    1729 #endif //Q_OS_WINCE
     1686#endif //Q_WS_WINCE
    17301687
    17311688void QWidgetPrivate::createTLSysExtra()
    17321689{
     1690    extra->topextra->savedFlags = 0;
     1691    extra->topextra->winIconBig = 0;
    17331692    extra->topextra->winIconSmall = 0;
    1734     extra->topextra->winIconBig = 0;
    17351693}
    17361694
     
    18561814
    18571815    Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
    1858     SetWindowRgn(data.winid, wr, true);
     1816    if (!SetWindowRgn(data.winid, wr, true))
     1817        DeleteObject(wr);
    18591818}
    18601819
     
    18741833
    18751834    QTLWExtra *top = topData();
    1876     uint exstyle = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_EXSTYLE),
    1877                                 GetWindowLongA(q->internalWinId(), GWL_EXSTYLE));
    1878     uint style = QT_WA_INLINE(GetWindowLongW(q->internalWinId(), GWL_STYLE),
    1879                               GetWindowLongA(q->internalWinId(), GWL_STYLE));
    1880 #ifndef Q_OS_WINCE
     1835    uint exstyle = GetWindowLong(q->internalWinId(), GWL_EXSTYLE);
     1836    uint style = GetWindowLong(q->internalWinId(), GWL_STYLE);
     1837#ifndef Q_WS_WINCE
    18811838    if (AdjustWindowRectEx(&rect, style & ~(WS_OVERLAPPED), FALSE, exstyle)) {
    18821839#else
     
    18881845}
    18891846
    1890 #ifndef Q_OS_WINCE
     1847#ifndef Q_WS_WINCE
    18911848void QWidgetPrivate::setWindowOpacity_sys(qreal level)
    18921849{
    18931850    Q_Q(QWidget);
    18941851
    1895     if (!isOpaque && ptrUpdateLayeredWindowIndirect && (data.window_flags & Qt::FramelessWindowHint)) {
    1896         if (GetWindowLongA(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED) {
    1897             Q_BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * level), Q_AC_SRC_ALPHA};
    1898                     Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, NULL, NULL, NULL, NULL, 0, &blend, Q_ULW_ALPHA, NULL};
    1899             (*ptrUpdateLayeredWindowIndirect)(q->internalWinId(), &info);
     1852    if (!isOpaque && ptrUpdateLayeredWindow && (data.window_flags & Qt::FramelessWindowHint)) {
     1853        if (GetWindowLong(q->internalWinId(), GWL_EXSTYLE) & Q_WS_EX_LAYERED) {
     1854            BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * level), AC_SRC_ALPHA};
     1855            ptrUpdateLayeredWindow(q->internalWinId(), NULL, NULL, NULL, NULL, NULL, 0, &blend, Q_ULW_ALPHA);
    19001856        }
    19011857        return;
     
    19131869        return;
    19141870
    1915     int wl = GetWindowLongA(q->internalWinId(), GWL_EXSTYLE);
     1871    int wl = GetWindowLong(q->internalWinId(), GWL_EXSTYLE);
    19161872
    19171873    if (level != 1.0) {
    19181874        if ((wl&Q_WS_EX_LAYERED) == 0)
    1919             SetWindowLongA(q->internalWinId(), GWL_EXSTYLE, wl|Q_WS_EX_LAYERED);
     1875            SetWindowLong(q->internalWinId(), GWL_EXSTYLE, wl | Q_WS_EX_LAYERED);
    19201876    } else if (wl&Q_WS_EX_LAYERED) {
    1921         SetWindowLongA(q->internalWinId(), GWL_EXSTYLE, wl & ~Q_WS_EX_LAYERED);
    1922     }
    1923     (*ptrSetLayeredWindowAttributes)(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA);
    1924 }
    1925 #endif //Q_OS_WINCE
     1877        SetWindowLong(q->internalWinId(), GWL_EXSTYLE, wl & ~Q_WS_EX_LAYERED);
     1878    }
     1879    ptrSetLayeredWindowAttributes(q->internalWinId(), 0, (int)(level * 255), Q_LWA_ALPHA);
     1880}
     1881#endif //Q_WS_WINCE
    19261882
    19271883// class QGlobalRasterPaintEngine: public QRasterPaintEngine
     
    19321888// Q_GLOBAL_STATIC(QGlobalRasterPaintEngine, globalRasterPaintEngine)
    19331889
    1934 #ifndef QT_NO_DIRECT3D
    1935 static void cleanup_d3d_engine();
    1936 Q_GLOBAL_STATIC_WITH_INITIALIZER(QDirect3DPaintEngine, _qt_d3dEngine,
    1937                                  {
    1938                                      qAddPostRoutine(cleanup_d3d_engine);
    1939                                  })
    1940 static void cleanup_d3d_engine()
    1941 {
    1942     _qt_d3dEngine()->cleanup();
    1943 }
    1944 QDirect3DPaintEngine* qt_d3dEngine()
    1945 {
    1946     return _qt_d3dEngine();
    1947 }
    1948 #endif
    1949 
    19501890
    19511891#ifndef QT_NO_DIRECTDRAW
     
    20031943    QOnScreenRasterPaintEngine()
    20041944        : QRasterPaintEngine(new QImage(qt_primary_surface_bits,
    2005                                         qApp->desktop()->width(),
    2006                                         qApp->desktop()->height(),
     1945                                        QApplication::desktop()->width(),
     1946                                        QApplication::desktop()->height(),
    20071947                                        qt_primary_surface_stride,
    20081948                                        qt_primary_surface_format))
     
    20602000QPaintEngine *QWidget::paintEngine() const
    20612001{
    2062 #ifndef QT_NO_DIRECT3D
    2063     if ((qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault)
    2064          || testAttribute(Qt::WA_MSWindowsUseDirect3D))
    2065         && qt_d3dEngine()->hasDirect3DSupport())
    2066     {
    2067         QDirect3DPaintEngine *engine = qt_d3dEngine();
    2068         if (qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault))
    2069             engine->setFlushOnEnd(false);
    2070         else
    2071             engine->setFlushOnEnd(true);
    2072         return engine;
    2073     }
    2074 #endif
    20752002#ifndef QT_NO_DIRECTDRAW
    20762003    QOnScreenRasterPaintEngine *pe = onScreenPaintEngine();
     
    21012028{
    21022029    Q_Q(QWidget);
    2103 #ifndef QT_NO_DIRECT3D
    2104     extern QDirect3DPaintEngine *qt_d3dEngine();
    2105     if (qApp->testAttribute(Qt::AA_MSWindowsUseDirect3DByDefault) && (q->windowOpacity() == 1.0f)
    2106         && qt_d3dEngine()->hasDirect3DSupport()) {
    2107         return new QD3DWindowSurface(q);
    2108     }
    2109 #endif
    21102030    return new QRasterWindowSurface(q);
    21112031}
     
    21152035}
    21162036
    2117 
    2118 
     2037void QWidgetPrivate::registerTouchWindow()
     2038{
     2039    Q_Q(QWidget);
     2040
     2041    // enable WM_TOUCH* messages on our window
     2042    if (q->testAttribute(Qt::WA_WState_Created)
     2043        && QApplicationPrivate::RegisterTouchWindow
     2044        && q->windowType() != Qt::Desktop)
     2045        QApplicationPrivate::RegisterTouchWindow(q->effectiveWinId(), 0);
     2046}
     2047
     2048void QWidgetPrivate::winSetupGestures()
     2049{
     2050#if !defined(QT_NO_NATIVE_GESTURES)
     2051    Q_Q(QWidget);
     2052    if (!q || !q->isVisible() || !nativeGesturePanEnabled)
     2053        return;
     2054
     2055    QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
     2056    if (!qAppPriv->SetGestureConfig)
     2057        return;
     2058    WId winid = q->internalWinId();
     2059
     2060    bool needh = false;
     2061    bool needv = false;
     2062    bool singleFingerPanEnabled = false;
     2063
     2064#ifndef QT_NO_SCROLLAREA
     2065    if (QAbstractScrollArea *asa = qobject_cast<QAbstractScrollArea*>(q->parent())) {
     2066        QScrollBar *hbar = asa->horizontalScrollBar();
     2067        QScrollBar *vbar = asa->verticalScrollBar();
     2068        Qt::ScrollBarPolicy hbarpolicy = asa->horizontalScrollBarPolicy();
     2069        Qt::ScrollBarPolicy vbarpolicy = asa->verticalScrollBarPolicy();
     2070        needh = (hbarpolicy == Qt::ScrollBarAlwaysOn ||
     2071                 (hbarpolicy == Qt::ScrollBarAsNeeded && hbar->minimum() < hbar->maximum()));
     2072        needv = (vbarpolicy == Qt::ScrollBarAlwaysOn ||
     2073                 (vbarpolicy == Qt::ScrollBarAsNeeded && vbar->minimum() < vbar->maximum()));
     2074        singleFingerPanEnabled = asa->d_func()->singleFingerPanEnabled;
     2075        if (!winid) {
     2076            winid = q->winId(); // enforces the native winid on the viewport
     2077        }
     2078    }
     2079#endif //QT_NO_SCROLLAREA
     2080    if (winid) {
     2081        GESTURECONFIG gc[1];
     2082        memset(gc, 0, sizeof(gc));
     2083        gc[0].dwID = GID_PAN;
     2084        if (nativeGesturePanEnabled) {
     2085            gc[0].dwWant = GC_PAN;
     2086            if (needv && singleFingerPanEnabled)
     2087                gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
     2088            else
     2089                gc[0].dwBlock |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
     2090            if (needh && singleFingerPanEnabled)
     2091                gc[0].dwWant |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
     2092            else
     2093                gc[0].dwBlock |= GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
     2094        } else {
     2095            gc[0].dwBlock = GC_PAN;
     2096        }
     2097
     2098        qAppPriv->SetGestureConfig(winid, 0, sizeof(gc)/sizeof(gc[0]), gc, sizeof(gc[0]));
     2099    }
     2100#endif
     2101}
    21192102
    21202103QT_END_NAMESPACE
    21212104
    2122 #ifdef Q_OS_WINCE
     2105#ifdef Q_WS_WINCE
    21232106#       include "qwidget_wince.cpp"
    21242107#endif
Note: See TracChangeset for help on using the changeset viewer.