Exemplo n.º 1
0
void NextClient::menuButtonPressed()
{
    // Probably don't need this null check, but we might as well.
    if (button[MENU_IDX]) {
	QRect menuRect = button[MENU_IDX]->rect();
        QPoint menuTop = button[MENU_IDX]->mapToGlobal(menuRect.topLeft());
        QPoint menuBottom = button[MENU_IDX]->mapToGlobal(menuRect.bottomRight());
	menuTop += QPoint(1, 1);
	menuBottom += QPoint(1, 1);
        KDecorationFactory* f = factory();
        showWindowMenu(QRect(menuTop, menuBottom));
        if( !f->exists( this )) // 'this' was deleted
            return;
	button[MENU_IDX]->setDown(false);
    }
}
Exemplo n.º 2
0
void KniftyClient::menuButtonPressed()
{
    static QTime* t = NULL;
    static KniftyClient* lastClient = NULL;
    if (t == NULL)
        t = new QTime;
    bool dbl = (lastClient == this && t->elapsed() <= QApplication::doubleClickInterval());
    lastClient = this;
    t->start();
    if( !dbl )
    {
        QPoint pos = m_button[ButtonMenu]->mapToGlobal(
            m_button[ButtonMenu]->rect().bottomLeft() );
        KDecorationFactory* f = factory();
        showWindowMenu( pos );
        if( !f->exists( this )) // 'this' was deleted
            return;
        m_button[ButtonMenu]->setDown(false);
    }
    else
       closing = true;
}
Exemplo n.º 3
0
void KCommonDecoration::menuButtonPressed()
{
    static QTime* t = NULL;
    static KCommonDecoration* lastClient = NULL;
    if (t == NULL)
        t = new QTime;
    bool dbl = (lastClient==this && t->elapsed() <= QApplication::doubleClickInterval());
    lastClient = this;
    t->start();
    if (!dbl || !decorationBehaviour(DB_MenuClose) ) {
        QRect menuRect = m_button[MenuButton]->rect();
        QPoint menutop = m_button[MenuButton]->mapToGlobal(menuRect.topLeft());
        QPoint menubottom = m_button[MenuButton]->mapToGlobal(menuRect.bottomRight())+QPoint(0,2);
        KDecorationFactory* f = factory();
        showWindowMenu(QRect(menutop, menubottom));
        if( !f->exists( this )) // 'this' was deleted
            return;
        m_button[MenuButton]->setDown(false);
    }
    else
        closing = true;
}
Exemplo n.º 4
0
// returns true if plugin was loaded successfully
bool KDecorationPlugins::loadPlugin(QString nameStr)
{
    KConfigGroup group(config, QStringLiteral("Style"));
    if (nameStr.isEmpty()) {
        nameStr = group.readEntry("PluginLib", defaultPlugin);
    }

    // Check if this library is not already loaded.
    if (pluginStr == nameStr)
        return true;

    if (group.readEntry<bool>("NoPlugin", false)) {
        error(i18n("Loading of window decoration plugin library disabled in configuration."));
        return false;
    }

    auto createFactory = [](const QString &pluginName) -> KDecorationFactory* {
        qDebug() << "Trying to load decoration plugin" << pluginName;
        const QString query = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(pluginName);
        const auto offers = KPluginTrader::self()->query(QStringLiteral("kf5/kwin/kdecorations"), QString(), query);
        if (offers.isEmpty()) {
            qDebug() << "Decoration plugin not found";
            return nullptr;
        }
        KPluginLoader loader(offers.first().libraryPath());
        if (loader.pluginVersion() != KWIN_DECORATION_API_VERSION) {
            qWarning() << i18n("The library %1 has wrong API version %2", loader.pluginName(), loader.pluginVersion());
            return nullptr;
        }
        KPluginFactory *factory = loader.factory();
        if (!factory) {
            qWarning() << "Error loading decoration library: " << loader.errorString();
            return nullptr;
        } else {
            return factory->create<KDecorationFactory>();
        }
    };
    KDecorationFactory *factory = createFactory(nameStr);
    if (!factory) {
        // If that fails, fall back to the default plugin
        factory = createFactory(defaultPlugin);
        if (!factory) {
            // big time trouble!
            // -> exit kwin with an error message
            error(i18n("The default decoration plugin is corrupt and could not be loaded."));
            return false;
        }
    }

    factory->checkRequirements(this);   // let it check what is supported

    pluginStr = nameStr;

    // For clients in kdeartwork
#warning insertCatalog needs porting
#if KWIN_QT5_PORTING
    QString catalog = nameStr;
    catalog.replace("kwin3_", "kwin_");
    KGlobal::locale()->insertCatalog(catalog);
    // For KCommonDecoration based clients
    KGlobal::locale()->insertCatalog("libkdecorations");
    // For clients in kdebase
    KGlobal::locale()->insertCatalog("kwin_clients");
    // For clients in kdeartwork
    KGlobal::locale()->insertCatalog("kwin_art_clients");
#endif

    old_fact = fact;
    fact = factory;

    return true;
}