Ignore:
Timestamp:
Aug 20, 2011, 8:26:35 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: Export qt_WinProcessWindowObstacles() as APIENTRY and document it.

This routine is necessary when 3rd-party applications paint directly to a HWND
of a Qt Widget bypassing Qt.

File:
1 edited

Legend:

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

    r1008 r1013  
    231231
    232232/*!
    233     \internal
    234 
    235     Helper function to collect all relative windows intersecting with the given
    236     \a hwnd and placed above it in z-order. The area of interest is limited to
    237     the \a prcl rectangle (in window coordinates) which may be NULL to indicate
    238     the whole window. If \a hrgn is not NULL, all found obstacles are combined
    239     with the given region using the \a op operation (CRGN_*); otherwise they are
     233    \enum PWOFlags
     234    \relates QWidget
     235
     236    Flags for qt_WinProcessWindowObstacles() that define which relative windows
     237    to process.
     238
     239    \warning This enum is only available on OS/2.
     240
     241    \value PWO_Children Child windows.
     242    \value PWO_Siblings Sibling windows.
     243    \value PWO_Ancestors Siblings of the parent window and all ancestors.
     244    \value PWO_Screen Screen area.
     245    \value PWO_TopLevel All top level windows.
     246    \value PWO_Default Default value suitable for most paint operations
     247        (equivalent to specifying all flags except PWO_TopLevel).
     248*/
     249
     250/*!
     251    \fn LONG qt_WinProcessWindowObstacles(HWND hwnd, RECTL *prcl, HRGN hrgn,
     252                                          LONG op, LONG flags)
     253    \relates QWidget
     254
     255    Collects all relative PM windows intersecting with the given \a hwnd and
     256    placed above it in Z-order. The area of interest is limited to the \a prcl
     257    rectangle (in window coordinates) which may be \c NULL to indicate the whole
     258    window. If \a hrgn is not \c NULL, all found obstacles are combined with
     259    the given region using the \a op operation (\c CRGN_*); otherwise they are
    240260    directly validated on the window. The scope of relativeness is defined by
    241     the \a flags argument which is one or more PWO_* flags OR-ed together.
     261    the \a flags argument which is one or more PWOFlags OR-ed together.
    242262
    243263    Returns the complexity of the combined region (only when \a hrgn is not
    244     NULL). Note that if no combining occurs (e.g. no relatives in the requested
    245     scope), the return value is RGN_NULL regardless of the original complexity
    246     of \a hrgn.
     264    \c NULL). Note that if no combining occurs (e.g. no relatives in the
     265    requested scope), the return value is \c RGN_NULL regardless of the original
     266    complexity of \a hrgn.
     267
     268    This function is especially useful for 3rd-party applications that embed
     269    themselves into a Qt application by painting directly on a PM window of a Qt
     270    widget (that gets created when QWidget::winId() is called), bypassing Qt
     271    completely. An example of such an application would be a video player that
     272    renders and paints frames in an external non-Qt thread or process.
     273
     274    Qt does not use the \c WS_CLIPSIBLINGS and \c WS_CLIPCHILDREN flags when
     275    creating PM windows for non-top-level widgets (because that would break
     276    support for non-rectangular widgets due to a bug in PM) and this function
     277    acts as a functional replacement for these flags. Any application that
     278    paints on the PM window of the Qt widget directy must call
     279    qt_WinProcessWindowObstacles() to correctly clip out portions of the widget
     280    covered by other widgets placed above it in Z-order and avoid unexpected
     281    painting over these widgets.
     282
     283    \snippet doc/src/snippets/code/src_gui_painting_embedded_pm.cpp 0
     284
     285    \warning This function is only available on OS/2.
    247286 */
    248 LONG qt_WinProcessWindowObstacles(HWND hwnd, RECTL *prcl, HRGN hrgn,
    249                                   LONG op, LONG flags)
     287LONG APIENTRY qt_WinProcessWindowObstacles(HWND hwnd, RECTL *prcl, HRGN hrgn,
     288                                           LONG op, LONG flags)
    250289{
    251290    Q_ASSERT(hwnd);
     291
     292    if (flags == 0)
     293        flags = PWO_Children | PWO_Siblings | PWO_Ancestors | PWO_Screen;
    252294
    253295    HPS displayPS = qt_display_ps();
     
    345387    // but only if they are not top-level windows (that cannot be
    346388    // non-rectangular and thus are always correctly clipped by the system)
    347     if ((flags & PWO_Sibings) && parent != desktop) {
     389    if ((flags & PWO_Siblings) && parent != desktop) {
    348390        for (relative = swpSelf.hwndInsertBehind;
    349391              relative != HWND_TOP; relative = swp.hwndInsertBehind) {
     
    698740                HRGN hrgnObst = GpiCreateRegion(hps, 0, NULL);
    699741                qt_WinProcessWindowObstacles(hwnd, &rclAff, hrgnObst, CRGN_OR,
    700                                              PWO_Sibings | PWO_Ancestors |
     742                                             PWO_Siblings | PWO_Ancestors |
    701743                                             PWO_Screen | PWO_TopLevel);
    702744                // shift region of obstacles and affected region back to
     
    11421184#if defined(QT_DEBUGWINCREATEDESTROY)
    11431185            qDebug() <<   "|Creating top level window (frame)" << q
    1144                      << "\n|  owner" << qDebugFmtHex(ownerw)
     1186                     << "\n|  owner" << qDebugHWND(ownerw)
    11451187                     << "\n|  title" << title
    11461188                     << "\n|  style" << qDebugFmtHex(fStyle)
     
    11911233#if defined(QT_DEBUGWINCREATEDESTROY)
    11921234            qDebug() <<   "|Creating top level window (client)" << q
    1193                      << "\n|  owner & parent" << qDebugFmtHex(fId)
     1235                     << "\n|  owner & parent" << qDebugHWND(fId)
    11941236                     << "\n|  class" << className
    11951237                     << "\n|  title" << title
     
    13251367#if defined(QT_DEBUGWINCREATEDESTROY)
    13261368        qDebug() <<   "|Creating child window" << q
    1327                  << "/n|  owner & parent" << qDebugFmtHex(parentw)
    1328                  << "/n|  class" << className
    1329                  << "/n|  title" << title
    1330                  << "/n|  style" << qDebugFmtHex(style);
     1369                 << "\n|  owner & parent" << qDebugHWND(parentw)
     1370                 << "\n|  class" << className
     1371                 << "\n|  title" << title
     1372                 << "\n|  style" << qDebugFmtHex(style);
    13311373#endif
    13321374        id = WinCreateWindow(parentw, className, title, style,
     
    13951437            qDebug() << "|Destroying window" << this
    13961438                     << "\n|  hwnd"  << qDebugFmtHex(id);
    1397             if (id != winId())
    1398                 qDebug() << "(frame) \n|  hwnd" << qDebugFmtHex(winId()) << "(client)";
     1439            if (id != internalWinId())
     1440                qDebug() << "|  hwnd" << qDebugFmtHex(internalWinId()) << "(client)";
    13991441#endif
    14001442            qt_WinDestroyWindow(id);
     
    14721514    if (old_fid != NULLHANDLE && q->windowType() != Qt::Desktop) {
    14731515        // destroy HWND
     1516#if defined(QT_DEBUGWINCREATEDESTROY)
     1517            qDebug() << "|Destroying window" << q
     1518                     << "\n|  hwnd"  << qDebugFmtHex(old_fid);
     1519            if (old_fid != data.winid)
     1520                qDebug() << "|  hwnd" << qDebugFmtHex(data.winid) << "(client)";
     1521#endif
    14741522        qt_WinDestroyWindow(old_fid);
    14751523    }
     
    25192567        if (updateRcl.xLeft != updateRcl.xRight &&
    25202568            updateRcl.yBottom != updateRcl.yTop) {
    2521             qt_WinProcessWindowObstacles(data.winid, &updateRcl, 0, 0);
     2569            qt_WinProcessWindowObstacles(data.winid, &updateRcl, 0, 0, PWO_Default);
    25222570        }
    25232571    }
Note: See TracChangeset for help on using the changeset viewer.