Exemplo n.º 1
0
void setBarState(bool bAnimate = false)
{
    if ((dock->getState() == ABE_FLOAT) || !pMain->isVisible()){
        appBarMessage(ABM_SETPOS, ABE_FLOAT, FALSE);
    }else{
        if (dock->getAutoHide() && !appBarMessage(ABM_SETAUTOHIDEBAR, dock->getState(), TRUE, NULL)){
            dock->setAutoHide(false);
            QMessageBox::warning(NULL, i18n("Error"),
                                 i18n("There is already an auto hidden window on this edge.\nOnly one auto hidden window is allowed on each edge."),
                                 QMessageBox::Ok, 0);
        }
        QRect rc;
        getBarRect(dock->getState(), rc);
        if (dock->getAutoHide()){
            QRect rcAutoHide = rc;
            int w = 4 * GetSystemMetrics(SM_CXBORDER);
            if (dock->getState() == ABE_LEFT){
                rcAutoHide.setRight(rcAutoHide.left() + w);
            }else{
                rcAutoHide.setLeft(rcAutoHide.right() - w);
            }
            appBarMessage(ABM_SETPOS, dock->getState(), FALSE, &rcAutoHide);
            if (!bAutoHideVisible){
                if (bOldVisible)
                    dock->setWidth(rc.width() - GetSystemMetrics(SM_CXBORDER) * 2);
                MINMAXINFO mmInfo;
                rc = rcAutoHide;
                SendMessageA(pMain->winId(), WM_GETMINMAXINFO, 0, (LPARAM)&mmInfo);
                if (dock->getState() == ABE_LEFT){
                    rc.setLeft(rc.right() - mmInfo.ptMinTrackSize.x);
                }else{
                    rc.setRight(rc.left() + mmInfo.ptMinTrackSize.x);
                }
            }else{
                if (dock->getState() == ABE_LEFT){
                    rc.setRight(rc.left() + dock->getWidth());
                }else{
                    rc.setLeft(rc.right() - dock->getWidth());
                }
            }
            bOldVisible = bAutoHideVisible;
        }else{
            appBarMessage(ABM_SETPOS, dock->getState(), FALSE, &rc);
        }
        slideWindow(rc, bAnimate);
    }
    if (pMain->isVisible()){
        Event eOnTop(EventOnTop, (void*)bFullScreen);
        eOnTop.process();
        if (!bFullScreen && (qApp->activeWindow() == pMain))
            appBarMessage(ABM_ACTIVATE);
    }
}
Exemplo n.º 2
0
void WinDockPlugin::uninit()
{
    QWidget *main = getMainWindow();
    if (main && oldProc){
        appBarMessage(ABM_REMOVE);
        WNDPROC p;
        p = (WNDPROC)SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        if (p == 0)
            p = (WNDPROC)SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc);
		oldProc = NULL;
    }
}
Exemplo n.º 3
0
void WinDockPlugin::uninit()
{
    QWidget *main = getMainWindow();
    if (main && oldProc){
        appBarMessage(ABM_REMOVE);
        if (IsWindowUnicode(pMain->winId())){
            SetWindowLongW(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }else{
            SetWindowLongA(main->winId(), GWL_WNDPROC, (LONG)oldProc);
        }
        oldProc = NULL;
    }
}
Exemplo n.º 4
0
void WinDockPlugin::init()
{
    pMain = getMainWindow();
    if (pMain){
        if (IsWindowUnicode(pMain->winId())){
            oldProc = (WNDPROC)SetWindowLongW(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
            if (oldProc == 0)
                oldProc = (WNDPROC)SetWindowLongA(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
        }
        appBarMessage(ABM_NEW);
        m_bInit = true;
        setBarState();
    }
}
Exemplo n.º 5
0
void setBarState(bool bAnimate = false)
{
    if ((dock->getState() == ABE_FLOAT) || !pMain->isVisible()){
        appBarMessage(ABM_SETPOS, dock->getState(), FALSE);
    }else{
        if (dock->getAutoHide() && !appBarMessage(ABM_SETAUTOHIDEBAR, dock->getState(), TRUE, NULL)){
            dock->setAutoHide(false);
            QMessageBox::warning(NULL, i18n("Error"),
                                 i18n("There is already an auto hidden window on this edge.\nOnly one auto hidden window is allowed on each edge."),
                                 QMessageBox::Ok, 0);
        }
        QRect rc;
        getBarRect(dock->getState(), rc);
        if (dock->getAutoHide()){
            QRect rcAutoHide = rc;
            int w = 4 * GetSystemMetrics(SM_CXBORDER);
            if (dock->getState() == ABE_LEFT){
                rcAutoHide.setRight(rcAutoHide.left() + w);
            }else{
                rcAutoHide.setLeft(rcAutoHide.right() - w);
            }
            appBarMessage(ABM_SETPOS, dock->getState(), FALSE, &rcAutoHide);
            if (!bAutoHideVisible)
                rc = rcAutoHide;
        }else{
            appBarMessage(ABM_SETPOS, dock->getState(), FALSE, &rc);
        }
        slideWindow(rc, bAnimate);
    }
    if (pMain->isVisible()){
        Event eOnTop(EventOnTop, (void*)bFullScreen);
        eOnTop.process();
        if (!bFullScreen && (qApp->activeWindow() == pMain))
            appBarMessage(ABM_ACTIVATE);
    }
}
Exemplo n.º 6
0
void WinDockPlugin::init()
{
    if (m_bInit)
        return;
    pMain = getMainWindow();
    if (pMain){
        if (IsWindowUnicode(pMain->winId())){
            oldProc = (WNDPROC)SetWindowLongW(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
        }else{
            oldProc = (WNDPROC)SetWindowLongA(pMain->winId(), GWL_WNDPROC, (LONG)dockWndProc);
        }
        appBarMessage(ABM_NEW);
        m_bInit = true;
        setBarState();
        pMain->installEventFilter(this);
    }
}
Exemplo n.º 7
0
static void getBarRect(UINT state, QRect &rc, RECT *rcWnd = NULL)
{
    RECT rcWork;
    SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0);
    rc.setCoords(0, rcWork.top, GetSystemMetrics(SM_CXSCREEN), rcWork.bottom);
    appBarMessage(ABM_QUERYPOS, state, FALSE, &rc);
    int w;
    if (rcWnd){
        w = rcWnd->right - rcWnd->left;
    }else{
        GetWindowRect(pMain->winId(), &rcWork);
        w = rcWork.right - rcWork.left;
    }
    switch (state){
    case ABE_LEFT:
        rc.setRight(rc.left() + w);
        break;
    case ABE_RIGHT:
        rc.setLeft(rc.right() - w);
        break;
    }
}
Exemplo n.º 8
0
LRESULT CALLBACK dockWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LRESULT res;
	log(L_DEBUG, "Msg %04X %04X", msg, wParam);
    if (msg == WM_APPBAR){
        switch (wParam){
        case ABN_FULLSCREENAPP:
            bFullScreen = (lParam != 0);
            setBarState();
            break;
        case ABN_POSCHANGED:
            if (dock->getState() != ABE_FLOAT)
                setBarState();
            break;
        }
    }
    unsigned type;
    RECT  *prc;
    RECT  rcWnd;
    QRect rc;
    switch (msg){
    case WM_ACTIVATE:
		if (dock->getState() != ABE_FLOAT){
			if ((wParam == WA_INACTIVE) && dock->getAutoHide() && bAutoHideVisible){
				bAutoHideVisible = false;
				setBarState();
			}
			appBarMessage(ABM_ACTIVATE);

		}
        break;
    case WM_NCMOUSEMOVE:
        if ((dock->getState() != ABE_FLOAT) && dock->getAutoHide() && !bAutoHideVisible){
            bAutoHideVisible = true;
            setBarState(true);
        }
        break;
    case WM_ENTERSIZEMOVE:
        bMoving = true;
        bSizing = true;
        if (dock->getState() == ABE_FLOAT){
            bSizing = false;
            GetWindowRect(hWnd, &rcWnd);
            dock->setHeight(rcWnd.bottom - rcWnd.top);
        }
        return DefWindowProc(hWnd, msg, wParam, lParam);
    case WM_EXITSIZEMOVE:
        bMoving = false;
        dock->setState(getEdge());
        setBarState(true);
        return DefWindowProc(hWnd, msg, wParam, lParam);
    case WM_MOVING:
    case WM_SIZING:
        if (!bMoving) break;
        prc = (RECT*)lParam;
        type = getEdge(prc);
        if (type == ABE_FLOAT){
            if (bSizing){
                prc->bottom = prc->top + dock->getHeight();
                bSizing = false;
            }
        }else{
            getBarRect(type, rc, prc);
            prc->left = rc.left();
            prc->top = rc.top();
            prc->right = rc.right();
            prc->bottom = rc.bottom();
            bSizing = true;
        }
        return 1;
    case WM_WINDOWPOSCHANGED:
        res = oldProc(hWnd, msg, wParam, lParam);
		if (dock->getState() != ABE_FLOAT)
	        appBarMessage(ABM_WINDOWPOSCHANGED);
        return res;
    }
    return oldProc(hWnd, msg, wParam, lParam);
}
Exemplo n.º 9
0
LRESULT CALLBACK dockWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    LRESULT res;
    if (msg == WM_APPBAR){
        switch (wParam){
        case ABN_FULLSCREENAPP:
            if ((lParam != 0) == bFullScreen)
                break;
            bFullScreen = (lParam != 0);
            setBarState();
            break;
        case ABN_POSCHANGED:
            if (dock->getState() != ABE_FLOAT)
                setBarState();
            break;
        }
    }
    unsigned type;
    RECT  *prc;
    RECT  rcWnd;
    QRect rc;
    unsigned oldState;
    switch (msg){
    case WM_DESTROY:
        res = oldProc(hWnd, msg, wParam, lParam);
        appBarMessage(ABM_REMOVE);
        WNDPROC p;
        p = (WNDPROC)SetWindowLongW(hWnd, GWL_WNDPROC, (LONG)oldProc);
        if (p == 0)
            p = (WNDPROC)SetWindowLongA(hWnd, GWL_WNDPROC, (LONG)oldProc);
        oldProc = NULL;
        return res;
    case WM_SHOWWINDOW:
        res = oldProc(hWnd, msg, wParam, lParam);
        if (dock->getState() != ABE_FLOAT)
            QTimer::singleShot(0, dock, SLOT(slotSetState()));
        return res;
    case WM_ACTIVATE:
        if (dock->getState() != ABE_FLOAT){
            if ((wParam == WA_INACTIVE) && dock->getAutoHide() && bAutoHideVisible){
                bAutoHideVisible = false;
                setBarState();
                dock->enableAutoHide(false);
            }
            appBarMessage(ABM_ACTIVATE);
        }
        break;
    case WM_NCMOUSEMOVE:
        if ((dock->getState() != ABE_FLOAT) && dock->getAutoHide() && !bAutoHideVisible){
            bAutoHideVisible = true;
            setBarState(true);
            dock->enableAutoHide(true);
        }
        break;
    case WM_ENTERSIZEMOVE:
        bMoving = true;
        bSizing = true;
        if (dock->getState() == ABE_FLOAT){
            bSizing = false;
            GetWindowRect(hWnd, &rcWnd);
            dock->setHeight(rcWnd.bottom - rcWnd.top);
        }
        return DefWindowProc(hWnd, msg, wParam, lParam);
    case WM_EXITSIZEMOVE:
        bMoving = false;
        oldState = dock->getState();
        dock->setState(getEdge());
        GetWindowRect(hWnd, &rcWnd);
        if ((dock->getState() == ABE_FLOAT) && (oldState != ABE_FLOAT)){
            rcWnd.bottom = rcWnd.top + dock->getHeight();
            SetWindowPos(pMain->winId(), NULL,
                         rcWnd.left, rcWnd.top, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top,
                         SWP_NOZORDER | SWP_NOACTIVATE | SWP_DRAWFRAME);
        }
        dock->setWidth(rcWnd.right - rcWnd.left);
        setBarState(true);
        return DefWindowProc(hWnd, msg, wParam, lParam);
    case WM_MOVING:
    case WM_SIZING:
        if (!bMoving) break;
        prc = (RECT*)lParam;
        type = getEdge(prc);
        if (type == ABE_FLOAT){
            if (bSizing){
                prc->bottom = prc->top + dock->getHeight();
                bSizing = false;
            }
        }else{
            getBarRect(type, rc, prc);
            prc->left = rc.left();
            prc->top = rc.top();
            prc->right = rc.right();
            prc->bottom = rc.bottom();
            bSizing = true;
        }
        return 1;
    case WM_WINDOWPOSCHANGED:
        res = oldProc(hWnd, msg, wParam, lParam);
        if (dock->getState() != ABE_FLOAT)
            appBarMessage(ABM_WINDOWPOSCHANGED);
        return res;
    }
    return oldProc(hWnd, msg, wParam, lParam);
}