Ignore:
Timestamp:
Aug 22, 2011, 4:35:22 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: Fix position errors on resize of child widgets.

During complex geometry change operations (e.g. directly resizing
the child widget managed by the layout manager of its parent and
then resizing the parent) the Y position of the child within the parent
could be shifted by the double delta of the resize value because
the new parent's height (in Qt terms) was used for flipping the Y
coordinate instead of the real height of the PM window which didn't
yet reflect the height change in Qt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qwidget_pm.cpp

    r1016 r1019  
    513513#if defined(QT_DEBUGWIDGETMASK)
    514514    qDebug() << "qt_WinSetWindowPos: hwnd" << qDebugHWND(hwnd)
     515             << "behind" << qDebugFmtHex(hwndInsertBehind)
     516             << x << y << cx << cy
    515517             << "fl" << qDebugFmtHex(fl);
    516518#endif
     
    530532    SWP swpOld;
    531533    WinQueryWindowPos(hwnd, &swpOld);
     534
     535#if defined(QT_DEBUGWIDGETMASK)
     536    qDebug() << "  old pos" << swpOld;
     537    if (QWidget *w = qt_widget_from_hwnd(hwnd)) {
     538        qDebug() << "  old geo" << w->geometry();
     539        if (w->parentWidget()) {
     540            qDebug() << "  parent" << w->parentWidget();
     541            if (w->parentWidget()->internalWinId()) {
     542                SWP swp;
     543                WinQueryWindowPos(w->parentWidget()->internalWinId(), &swp);
     544                qDebug() << "    pos" << swp;
     545            }
     546            qDebug() << "    geo" << w->parentWidget()->geometry();
     547        }
     548    }
     549#endif
    532550
    533551    // do some checks
     
    15541572            qDebug() << "|Destroying window (reparent)" << q
    15551573                     << "\n|  hwnd"  << qDebugFmtHex(old_fid);
    1556             if (old_fid != data.winid)
    1557                 qDebug() << "|  hwnd" << qDebugFmtHex(data.winid) << "(client)";
    15581574#endif
    15591575        qt_WinDestroyWindow(old_fid);
     
    20712087                if (q->internalWinId() != NULLHANDLE) {
    20722088                    Q_ASSERT(parent->internalWinId() != NULLHANDLE);
    2073                     int h = parent->height();
     2089                    // important: use real parent height (it may not match crect yet)
     2090                    RECTL rcl;
     2091                    WinQueryWindowRect(parent->internalWinId(), &rcl);
    20742092                    qt_WinSetWindowPos(q->internalWinId(), 0, xrect.x(),
    20752093                                       // flip y coordinate
    2076                                        h - (xrect.y() + xrect.height()),
     2094                                       rcl.yTop - (xrect.y() + xrect.height()),
    20772095                                       xrect.width(), xrect.height(),
    20782096                                       SWP_MOVE | SWP_SIZE);
     
    21282146    // than moving mapped windows
    21292147    if (q->internalWinId() != NULLHANDLE) {
    2130         int h = parent->height();
    2131         if (parent->internalWinId() == NULLHANDLE) {
    2132             xrect.translate(parent->mapTo(q->nativeParentWidget(), QPoint(0, 0)));
    2133             h = q->nativeParentWidget()->height();
    2134         }
     2148        Q_ASSERT(parent->effectiveWinId());
     2149        // important: use real parent height (it may not match crect yet)
     2150        RECTL rcl;
     2151        WinQueryWindowRect(parent->effectiveWinId(), &rcl);
    21352152        qt_WinSetWindowPos(q->internalWinId(), 0, xrect.x(),
    21362153                           // flip y coordinate
    2137                            h - (xrect.y() + xrect.height()),
     2154                           rcl.yTop - (xrect.y() + xrect.height()),
    21382155                           xrect.width(), xrect.height(), SWP_MOVE | SWP_SIZE);
    21392156    }
Note: See TracChangeset for help on using the changeset viewer.