Changeset 138 for trunk/src


Ignore:
Timestamp:
Aug 29, 2009, 12:06:08 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented focus notifications.

Location:
trunk/src/gui/kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication.h

    r2 r138  
    239239    void winFocus(QWidget *, bool);
    240240    static void winMouseButtonUp();
     241#endif
     242
     243#if defined(Q_WS_PM)
     244    void pmFocus(QWidget *, bool);
    241245#endif
    242246
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r136 r138  
    469469#define SV_WORKAREA_XLEFT   54
    470470
     471/*!
     472    \internal
     473    \since 4.1
     474
     475    If \a gotFocus is true, \a widget will become the active window.
     476    Otherwise the active window is reset to 0.
     477*/
     478void QApplication::pmFocus(QWidget *widget, bool gotFocus)
     479{
     480    if (gotFocus) {
     481        setActiveWindow(widget);
     482        if (QApplicationPrivate::active_window
     483            && (QApplicationPrivate::active_window->windowType() == Qt::Dialog)) {
     484            // raise the entire application, not just the dialog
     485            QWidget* mw = QApplicationPrivate::active_window;
     486            while(mw->parentWidget() && (mw->windowType() == Qt::Dialog))
     487                mw = mw->parentWidget()->window();
     488            if (mw->testAttribute(Qt::WA_WState_Created) && mw != QApplicationPrivate::active_window)
     489                WinSetWindowPos(mw->d_func()->frameWinId(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
     490        }
     491    } else {
     492        setActiveWindow(0);
     493    }
     494}
     495
    471496// QtWndProc() receives all messages from the main event loop
    472497
     
    659684                if (widget->translateConfigEvent(qmsg))
    660685                    return (MRESULT)TRUE;
     686                break;
     687            }
     688
     689            case WM_ACTIVATE: {
     690                qApp->pmFocus(widget, SHORT1FROMMP(mp1));
     691                break;
     692            }
     693
     694            case WM_SETFOCUS: {
     695                HWND hwnd = (HWND)mp1;
     696                bool focus = SHORT1FROMMP(mp2);
     697                if (!focus) {
     698                    if (!QWidget::find(hwnd)) {
     699                        // we don't get focus, so unset it now
     700                        if (QApplication::activePopupWidget()) {
     701                            // Another application was activated while our popups are open,
     702                            // then close all popups.  In case some popup refuses to close,
     703                            // we give up after 1024 attempts (to avoid an infinite loop).
     704                            int maxiter = 1024;
     705                            QWidget *popup;
     706                            while ( (popup=QApplication::activePopupWidget()) && maxiter-- )
     707                                popup->close();
     708                        }
     709                        // non-Qt ownees of our WC_FRAME window (such as
     710                        // FID_SYSMENU) should not cause the focus to be lost.
     711                        if (WinQueryWindow(hwnd, QW_OWNER) ==
     712                                ((QETWidget*)widget->window())->dptr()->frameWinId())
     713                            break;
     714                        if (!widget->isWindow())
     715                            qApp->pmFocus(widget, focus);
     716                    }
     717                }
    661718                break;
    662719            }
     
    20112068    myCaseEnd()
    20122069
     2070    myCaseBegin(WM_ACTIVATE)
     2071        bool active = SHORT1FROMMP(qmsg.mp1);
     2072        HWND hwnd = (HWND)qmsg.mp2;
     2073        str += QCStr(" Active(") + QCStr(active ? "TRUE) " : "FALSE)");
     2074        str += QString().sprintf(" hwnd %08lX.", hwnd);
     2075        str += qWidgetName(qWidgetFromHWND(hwnd));
     2076        break;
     2077    myCaseEnd()
     2078
     2079    myCaseBegin(WM_SETFOCUS)
     2080        HWND hwnd = (HWND)qmsg.mp1;
     2081        bool focus = SHORT1FROMMP(qmsg.mp2);
     2082        str += QCStr(" Focus(") + QCStr(focus ? "TRUE) " : "FALSE)");
     2083        str += QString().sprintf(" hwnd %08lX.", hwnd);
     2084        str += qWidgetName(qWidgetFromHWND(hwnd));
     2085        break;
     2086    myCaseEnd()
     2087
    20132088    default:
    20142089        break;
     
    20302105{
    20312106    QString fl;
     2107    myDefFlagEx(swp.fl, SWP_SIZE, fl, "SIZE");
     2108    myDefFlagEx(swp.fl, SWP_MOVE, fl, "MOVE");
     2109    myDefFlagEx(swp.fl, SWP_ZORDER, fl, "ZORD");
    20322110    myDefFlagEx(swp.fl, SWP_SHOW, fl, "SHOW");
    20332111    myDefFlagEx(swp.fl, SWP_HIDE, fl, "HIDE");
     2112    myDefFlagEx(swp.fl, SWP_NOREDRAW, fl, "NORDR");
     2113    myDefFlagEx(swp.fl, SWP_NOADJUST, fl, "NOADJ");
    20342114    myDefFlagEx(swp.fl, SWP_ACTIVATE, fl, "ACT");
    20352115    myDefFlagEx(swp.fl, SWP_DEACTIVATE, fl, "DEACT");
     2116    myDefFlagEx(swp.fl, SWP_EXTSTATECHANGE, fl, "EXTST");
     2117    myDefFlagEx(swp.fl, SWP_MINIMIZE, fl, "MIN");
    20362118    myDefFlagEx(swp.fl, SWP_MAXIMIZE, fl, "MAX");
    2037     myDefFlagEx(swp.fl, SWP_MINIMIZE, fl, "MIN");
    20382119    myDefFlagEx(swp.fl, SWP_RESTORE, fl, "REST");
    2039     myDefFlagEx(swp.fl, SWP_MOVE, fl, "MOVE");
    2040     myDefFlagEx(swp.fl, SWP_SIZE, fl, "SIZE");
    2041     myDefFlagEx(swp.fl, SWP_ZORDER, fl, "ZORD");
     2120    myDefFlagEx(swp.fl, SWP_FOCUSACTIVATE, fl, "FCSACT");
     2121    myDefFlagEx(swp.fl, SWP_FOCUSDEACTIVATE, fl, "FCSDEACT");
     2122    myDefFlagEx(swp.fl, SWP_NOAUTOCLOSE, fl, "NOACLOSE");
    20422123
    20432124    return QString().sprintf("SWP(%ld,%ld %ldx%ld %08lX ",
Note: See TracChangeset for help on using the changeset viewer.