예제 #1
0
bool CfgWm::tryWmLaunch()
{
    if( currentWm() == KWIN_BIN
        && qstrcmp( NETRootInfo( QX11Info::connection(), NET::SupportingWMCheck ).wmName(), "KWin" ) == 0 )
    {
        return true; // it is already running, don't necessarily restart e.g. after a failure with other WM
    }
    KMessageBox::information( window(), i18n( "Your running window manager will be now replaced with "
        "the configured one." ), i18n( "Window Manager Change" ), "windowmanagerchange" );
    wmLaunchingState = WmLaunching;
    wmProcess = new KProcess;
    *wmProcess << KShell::splitArgs( currentWmData().exec ) << currentWmData().restartArgument;
    connect( wmProcess, SIGNAL( error( QProcess::ProcessError )), this, SLOT( wmLaunchError()));
    connect( wmProcess, SIGNAL( finished( int, QProcess::ExitStatus )),
        this, SLOT( wmLaunchFinished( int, QProcess::ExitStatus )));
    wmProcess->start();
    wmDialog = new KTimerDialog( 20000, KTimerDialog::CountDown, window(), i18n( "Config Window Manager Change" ),
        KTimerDialog::Ok | KTimerDialog::Cancel, KTimerDialog::Cancel );
    wmDialog->setButtonGuiItem( KDialog::Ok, KGuiItem( i18n( "&Accept Change" ), "dialog-ok" ));
    wmDialog->setButtonGuiItem( KDialog::Cancel, KGuiItem( i18n( "&Revert to Previous" ), "dialog-cancel" ));
    QLabel *label = new QLabel(
        i18n( "The configured window manager is being launched.\n"
            "Please check it has started properly and confirm the change.\n"
            "The launch will be automatically reverted in 20 seconds." ), wmDialog );
    label->setWordWrap( true );
    wmDialog->setMainWidget( label );
    if( wmDialog->exec() == QDialog::Accepted ) // the user confirmed
        wmLaunchingState = WmOk;
    else // cancelled for some reason
        {
        if( wmLaunchingState == WmLaunching )
            { // time out
            wmLaunchingState = WmFailed;
            KProcess::startDetached( KWIN_BIN, QStringList() << "--replace" );
            // Let's hope KWin never fails.
            KMessageBox::sorry( window(),
                i18n( "The running window manager has been reverted to the default KDE window manager KWin." ));
            }
        else if( wmLaunchingState == WmFailed )
            {
            KProcess::startDetached( KWIN_BIN, QStringList() << "--replace" );
            // Let's hope KWin never fails.
            KMessageBox::sorry( window(),
                i18n( "The new window manager has failed to start.\n"
                    "The running window manager has been reverted to the default KDE window manager KWin." ));
            }
        }
    bool ret = ( wmLaunchingState == WmOk );
    wmLaunchingState = WmNone;
    delete wmDialog;
    wmDialog = NULL;
    // delete wmProcess; - it is intentionally leaked, since there is no KProcess:detach()
    wmProcess = NULL;
    return ret;
}
예제 #2
0
void LXQtTaskButton::closeApplication()
{
    // FIXME: Why there is no such thing in KWindowSystem??
    NETRootInfo(QX11Info::connection(), NET::CloseWindow).closeWindowRequest(mWindow);
}