예제 #1
0
StartupId::StartupId( QWidget* parent, const char* name )
    :   QWidget( parent ),
        startup_info( KStartupInfo::CleanOnCantDetect ),
        startup_window( None ),
        blinking( true ),
        bouncing( false ),
        selection_watcher( new KSelectionWatcher( "_KDE_STARTUP_FEEDBACK", -1, this ))
    {
        setObjectName( QLatin1String( name ) );
    hide(); // is QWidget only because of x11Event()
    if( kde_startup_status == StartupPre )
        {
        kde_splash_progress = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False );
        XWindowAttributes attrs;
        XGetWindowAttributes( QX11Info::display(), QX11Info::appRootWindow(), &attrs);
        XSelectInput( QX11Info::display(), QX11Info::appRootWindow(), attrs.your_event_mask | SubstructureNotifyMask);
        kapp->installX11EventFilter( this );
        }
    update_timer.setSingleShot( true );
    connect( &update_timer, SIGNAL(timeout()), SLOT(update_startupid()));
    connect( &startup_info,
        SIGNAL(gotNewStartup(KStartupInfoId,KStartupInfoData)),
        SLOT(gotNewStartup(KStartupInfoId,KStartupInfoData)));
    connect( &startup_info,
        SIGNAL(gotStartupChange(KStartupInfoId,KStartupInfoData)),
        SLOT(gotStartupChange(KStartupInfoId,KStartupInfoData)));
    connect( &startup_info,
        SIGNAL(gotRemoveStartup(KStartupInfoId,KStartupInfoData)),
        SLOT(gotRemoveStartup(KStartupInfoId)));
    connect( selection_watcher, SIGNAL(newOwner(Window)), SLOT(newOwner()));
    connect( selection_watcher, SIGNAL(lostOwner()), SLOT(lostOwner()));
    active_selection = ( selection_watcher->owner() != None );
    }
예제 #2
0
void KMenuBar::setTopLevelMenuInternal(bool top_level)
{
    if(d->forcedTopLevel)
        top_level = true;

    d->wasTopLevel = top_level;
    if(parentWidget() && parentWidget()->topLevelWidget()->isFullScreen())
        top_level = false;

    if(isTopLevelMenu() == top_level)
        return;
    d->topLevel = top_level;
    if(isTopLevelMenu())
    {
#ifdef Q_WS_X11
        d->selection = new KSelectionWatcher(KMenuBarPrivate::makeSelectionAtom(), DefaultScreen(qt_xdisplay()));
        connect(d->selection, SIGNAL(newOwner(Window)), this, SLOT(updateFallbackSize()));
        connect(d->selection, SIGNAL(lostOwner()), this, SLOT(updateFallbackSize()));
#endif
        d->frameStyle = frameStyle();
        d->lineWidth = lineWidth();
        d->margin = margin();
        d->fallback_mode = false;
        bool wasShown = !isHidden();
        reparent(parentWidget(), WType_TopLevel | WStyle_Tool | WStyle_Customize | WStyle_NoBorder, QPoint(0, 0), false);
#ifdef Q_WS_X11
        KWin::setType(winId(), NET::TopMenu);
        if(parentWidget())
            XSetTransientForHint(qt_xdisplay(), winId(), parentWidget()->topLevelWidget()->winId());
#endif
        QMenuBar::setFrameStyle(NoFrame);
        QMenuBar::setLineWidth(0);
        QMenuBar::setMargin(0);
        updateFallbackSize();
        d->min_size = QSize(0, 0);
        if(parentWidget() && !parentWidget()->isTopLevel())
            setShown(parentWidget()->isVisible());
        else if(wasShown)
            show();
    }
    else
    {
#ifdef Q_WS_X11
        delete d->selection;
        d->selection = NULL;
#endif
        setBackgroundMode(PaletteButton);
        setFrameStyle(d->frameStyle);
        setLineWidth(d->lineWidth);
        setMargin(d->margin);
        setMinimumSize(0, 0);
        setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
        updateMenuBarSize();
        if(parentWidget())
            reparent(parentWidget(), QPoint(0, 0), !isHidden());
    }
}