build: Hardcode kwin name

We use KWIN_NAME, KWIN_INTERNAL_NAME_X11 and KWIN_INTERNAL_WAYLAND
properly only in a few places. In other, we use hardcoded names.

Let's not bother and hardcode kwin names everywhere rather than have one
foot in and one foot out, it's simpler.
This commit is contained in:
Vlad Zahorodnii 2022-11-01 19:46:03 +02:00
parent 1801421080
commit a235cd6d26
27 changed files with 38 additions and 47 deletions

View file

@ -383,11 +383,6 @@ option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
cmake_dependent_option(KWIN_BUILD_ACTIVITIES "Enable building of KWin with kactivities support" ON "KF5Activities_FOUND" OFF)
cmake_dependent_option(KWIN_BUILD_RUNNERS "Enable building of KWin with krunner support" ON "KF5Runner_FOUND" OFF)
# Binary name of KWin
set(KWIN_NAME "kwin")
set(KWIN_INTERNAL_NAME_X11 "kwin_x11")
set(KWIN_INTERNAL_NAME_WAYLAND "kwin_wayland")
set(HAVE_EPOXY_GLX ${epoxy_HAS_GLX})
# for kwin internal things

View file

@ -138,7 +138,7 @@ void GlobalShortcutsTest::testNonLatinLayout()
const QKeySequence seq(qtModifier + qtKey);
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName("globalshortcuts-test-non-latin-layout");
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
@ -162,7 +162,7 @@ void GlobalShortcutsTest::testConsumedShift()
// this test verifies that a shortcut with a consumed shift modifier triggers
// create the action
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-consumed-shift"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::Key_Percent}, KGlobalAccel::NoAutoloading);
@ -185,7 +185,7 @@ void GlobalShortcutsTest::testRepeatedTrigger()
// in addition pressing another key should stop triggering the shortcut
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-consumed-shift"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::Key_Percent}, KGlobalAccel::NoAutoloading);
@ -244,7 +244,7 @@ void GlobalShortcutsTest::testMetaShiftW()
{
// BUG 370341
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-meta-shift-w"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::META | Qt::SHIFT | Qt::Key_W}, KGlobalAccel::NoAutoloading);
@ -268,7 +268,7 @@ void GlobalShortcutsTest::testComponseKey()
{
// BUG 390110
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-accent"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::NoModifier}, KGlobalAccel::NoAutoloading);

View file

@ -679,7 +679,7 @@ void LockScreenTest::testKeyboardShortcut()
using namespace KWayland::Client;
std::unique_ptr<QAction> action(new QAction(nullptr));
QSignalSpy actionSpy(action.get(), &QAction::triggered);
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName("LockScreenTest::testKeyboardShortcut");
KGlobalAccel::self()->setDefaultShortcut(action.get(), QList<QKeySequence>{Qt::CTRL | Qt::META | Qt::ALT | Qt::Key_Space});
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::CTRL | Qt::META | Qt::ALT | Qt::Key_Space},

View file

@ -171,7 +171,7 @@ void NoGlobalShortcutsTest::testTrigger()
void NoGlobalShortcutsTest::testKGlobalAccel()
{
std::unique_ptr<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(QStringLiteral("globalshortcuts-test-meta-shift-w"));
QSignalSpy triggeredSpy(action.get(), &QAction::triggered);
KGlobalAccel::self()->setShortcut(action.get(), QList<QKeySequence>{Qt::META | Qt::SHIFT | Qt::Key_W}, KGlobalAccel::NoAutoloading);

View file

@ -339,9 +339,9 @@ if (PipeWire_FOUND)
target_link_libraries(kwin_wayland KWinScreencastPlugin)
endif()
install(FILES kwin.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} RENAME ${KWIN_NAME}.kcfg)
install(FILES kwin.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
if (KWIN_BUILD_NOTIFICATIONS)
install(FILES kwin.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR} RENAME ${KWIN_NAME}.notifyrc)
install(FILES kwin.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR})
endif()
install(
FILES

View file

@ -6,9 +6,7 @@
#cmakedefine01 KWIN_BUILD_SCREENLOCKER
#cmakedefine01 KWIN_BUILD_TABBOX
#cmakedefine01 KWIN_BUILD_ACTIVITIES
#define KWIN_NAME "${KWIN_NAME}"
#define KWIN_INTERNAL_NAME_X11 "${KWIN_INTERNAL_NAME_X11}"
#define KWIN_CONFIG "${KWIN_NAME}rc"
#define KWIN_CONFIG "kwinrc"
#define KWIN_VERSION_STRING "${PROJECT_VERSION}"
#define XCB_VERSION_STRING "${XCB_VERSION}"
#define KWIN_KILLER_BIN "${CMAKE_INSTALL_FULL_LIBEXECDIR}/kwin_killer_helper"

View file

@ -2332,7 +2332,7 @@ EffectFrameQuickScene::EffectFrameQuickScene(EffectFrameStyle style, bool static
break;
}
const QString defaultPath = QStringLiteral(KWIN_NAME "/frames/plasma/frame_%1.qml").arg(name);
const QString defaultPath = QStringLiteral("kwin/frames/plasma/frame_%1.qml").arg(name);
// TODO read from kwinApp()->config() "QmlPath" like Outline/OnScreenNotification
// *if* someone really needs this to be configurable.
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, defaultPath);

View file

@ -34,7 +34,7 @@ macro(KWIN4_ADD_EFFECT_MODULE name)
kcoreaddons_add_plugin(${name} STATIC SOURCES ${ARGN} INSTALL_NAMESPACE "kwin/effects/plugins")
set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON)
kwin_strip_builtin_effect_metadata(${name} metadata.json)
install(FILES metadata.json DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/builtin-effects/${name}/)
install(FILES metadata.json DESTINATION ${KDE_INSTALL_DATADIR}/kwin/builtin-effects/${name}/)
endmacro()
# Install the KWin/Effect service type

View file

@ -1960,7 +1960,7 @@ public:
connect(input(), &InputRedirection::deviceRemoved, this, &TabletInputFilter::removeDevice);
auto tabletNextOutput = new QAction(this);
tabletNextOutput->setProperty("componentName", QStringLiteral(KWIN_NAME));
tabletNextOutput->setProperty("componentName", QStringLiteral("kwin"));
tabletNextOutput->setText(i18n("Move the tablet to the next output"));
tabletNextOutput->setObjectName(QStringLiteral("Move Tablet to Next Output"));
KGlobalAccel::setGlobalShortcut(tabletNextOutput, QList<QKeySequence>());

View file

@ -40,7 +40,6 @@ set_target_properties(kwineffects PROPERTIES
VERSION ${KWINEFFECTS_VERSION}
SOVERSION ${KWINEFFECTS_SOVERSION}
)
set_target_properties(kwineffects PROPERTIES OUTPUT_NAME ${KWIN_NAME}effects)
install(TARGETS kwineffects EXPORT KWinEffectsTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
@ -60,7 +59,6 @@ target_link_libraries(kwinglutils PUBLIC XCB::XCB KF5::CoreAddons KF5::ConfigCor
set_target_properties(kwinglutils PROPERTIES
VERSION ${KWINEFFECTS_VERSION}
SOVERSION ${KWINEFFECTS_SOVERSION}
OUTPUT_NAME ${KWIN_NAME}glutils
)
install(TARGETS kwinglutils EXPORT KWinEffectsTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})

View file

@ -170,7 +170,7 @@ bool Application::wasCrash()
void Application::createAboutData()
{
KAboutData aboutData(QStringLiteral(KWIN_NAME), // The program name used internally
KAboutData aboutData(QStringLiteral("kwin"), // The program name used internally
i18n("KWin"), // A displayable program name string
QStringLiteral(KWIN_VERSION_STRING), // The program version string
i18n("KDE window manager"), // Short description of what the app does

View file

@ -74,7 +74,7 @@ public:
addWM(QStringLiteral("metacity"));
addWM(QStringLiteral("openbox"));
addWM(QStringLiteral("fvwm2"));
addWM(QStringLiteral(KWIN_INTERNAL_NAME_X11));
addWM(QStringLiteral("kwin_x11"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(mainWidget);
@ -283,7 +283,7 @@ void ApplicationX11::crashChecking()
if (crashes >= 4) {
// Something has gone seriously wrong
AlternativeWMDialog dialog;
QString cmd = QStringLiteral(KWIN_INTERNAL_NAME_X11);
QString cmd = QStringLiteral("kwin_x11");
if (dialog.exec() == QDialog::Accepted) {
cmd = dialog.selectedWM();
} else {

View file

@ -173,7 +173,7 @@ void OnScreenNotification::ensureQmlComponent()
}
m_qmlComponent.reset(new QQmlComponent(m_qmlEngine));
const QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
m_config->group(QStringLiteral("OnScreenNotification")).readEntry("QmlPath", QStringLiteral(KWIN_NAME "/onscreennotification/plasma/main.qml")));
m_config->group(QStringLiteral("OnScreenNotification")).readEntry("QmlPath", QStringLiteral("kwin/onscreennotification/plasma/main.qml")));
if (fileName.isEmpty()) {
return;
}

View file

@ -169,7 +169,7 @@ void CompositedOutlineVisual::show()
if (!m_qmlComponent) {
m_qmlComponent = std::make_unique<QQmlComponent>(Scripting::self()->qmlEngine());
const QString fileName = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
kwinApp()->config()->group(QStringLiteral("Outline")).readEntry("QmlPath", QStringLiteral(KWIN_NAME "/outline/plasma/outline.qml")));
kwinApp()->config()->group(QStringLiteral("Outline")).readEntry("QmlPath", QStringLiteral("kwin/outline/plasma/outline.qml")));
if (fileName.isEmpty()) {
qCDebug(KWIN_CORE) << "Could not locate outline.qml";
return;

View file

@ -105,7 +105,7 @@ void Helper::unref()
}
static const QString s_defaultTheme = QStringLiteral("kwin4_decoration_qml_plastik");
static const QString s_qmlPackageFolder = QStringLiteral(KWIN_NAME "/decorations/");
static const QString s_qmlPackageFolder = QStringLiteral("kwin/decorations/");
/*
* KDecoration2::BorderSize doesn't map to the indices used for the Aurorae SVG Button Sizes.
* BorderSize defines None and NoSideBorder as index 0 and 1. These do not make sense for Button

View file

@ -1,6 +1,6 @@
add_subdirectory(code)
install(DIRECTORY package/
DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/decorations/kwin4_decoration_qml_plastik)
DESTINATION ${KDE_INSTALL_DATADIR}/kwin/decorations/kwin4_decoration_qml_plastik)
file(COPY package/ DESTINATION ${CMAKE_BINARY_DIR}/bin/kwin/decorations/kwin4_decoration_qml_plastik)

View file

@ -27,6 +27,6 @@ endif()
target_link_libraries(KWinNightColorPlugin kwin)
install(FILES nightcolorsettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR} RENAME ${KWIN_NAME}_colorcorrect.kcfg)
install(FILES nightcolorsettings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES org.kde.kwin.ColorCorrect.xml DESTINATION ${KDE_INSTALL_DBUSINTERFACEDIR})
install(TARGETS KWinNightColorPlugin DESTINATION ${KDE_INSTALL_PLUGINDIR}/kwin/plugins/)

View file

@ -87,13 +87,13 @@ NightColorManager::NightColorManager()
// legacy shortcut with localized key (to avoid breaking existing config)
if (i18n("Toggle Night Color") != QStringLiteral("Toggle Night Color")) {
QAction toggleActionLegacy;
toggleActionLegacy.setProperty("componentName", QStringLiteral(KWIN_NAME));
toggleActionLegacy.setProperty("componentName", QStringLiteral("kwin"));
toggleActionLegacy.setObjectName(i18n("Toggle Night Color"));
KGlobalAccel::self()->removeAllShortcuts(&toggleActionLegacy);
}
QAction *toggleAction = new QAction(this);
toggleAction->setProperty("componentName", QStringLiteral(KWIN_NAME));
toggleAction->setProperty("componentName", QStringLiteral("kwin"));
toggleAction->setObjectName(QStringLiteral("Toggle Night Color"));
toggleAction->setText(i18n("Toggle Night Color"));
KGlobalAccel::setGlobalShortcut(toggleAction, QList<QKeySequence>());

View file

@ -1,3 +1,3 @@
install(DIRECTORY outline/plasma DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/outline)
install(DIRECTORY onscreennotification/plasma DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/onscreennotification)
install(DIRECTORY frames/plasma DESTINATION ${KDE_INSTALL_DATADIR}/${KWIN_NAME}/frames)
install(DIRECTORY outline/plasma DESTINATION ${KDE_INSTALL_DATADIR}/kwin/outline)
install(DIRECTORY onscreennotification/plasma DESTINATION ${KDE_INSTALL_DATADIR}/kwin/onscreennotification)
install(DIRECTORY frames/plasma DESTINATION ${KDE_INSTALL_DATADIR}/kwin/frames)

View file

@ -970,7 +970,7 @@ void RuleBook::load()
{
deleteAll();
if (!m_config) {
m_config = KSharedConfig::openConfig(QStringLiteral(KWIN_NAME "rulesrc"), KConfig::NoGlobals);
m_config = KSharedConfig::openConfig(QStringLiteral("kwinrulesrc"), KConfig::NoGlobals);
} else {
m_config->reparseConfiguration();
}

View file

@ -64,7 +64,7 @@ void GenericScriptedConfig::createUi()
QVBoxLayout *layout = new QVBoxLayout(this);
const QString packageRoot = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QLatin1String(KWIN_NAME) + QLatin1Char('/') + typeName() + QLatin1Char('/') + m_packageName,
QLatin1String("kwin/") + typeName() + QLatin1Char('/') + m_packageName,
QStandardPaths::LocateDirectory);
if (packageRoot.isEmpty()) {
layout->addWidget(new QLabel(i18nc("Error message", "Could not locate package metadata")));

View file

@ -162,7 +162,7 @@ ScriptedEffect *ScriptedEffect::create(const KPluginMetaData &effect)
return nullptr;
}
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QLatin1String(KWIN_NAME "/effects/") + name + QLatin1String("/contents/") + scriptName);
QLatin1String("kwin/effects/") + name + QLatin1String("/contents/") + scriptName);
if (scriptFile.isNull()) {
qCDebug(KWIN_SCRIPTING) << "Could not locate the effect script";
return nullptr;
@ -225,7 +225,7 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
m_scriptFile = pathToScript;
// does the effect contain an KConfigXT file?
const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(KWIN_NAME "/effects/") + m_effectName + QLatin1String("/contents/config/main.xml"));
const QString kconfigXTFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("kwin/effects/") + m_effectName + QLatin1String("/contents/config/main.xml"));
if (!kconfigXTFile.isNull()) {
KConfigGroup cg = QCoreApplication::instance()->property("config").value<KSharedConfigPtr>()->group(QStringLiteral("Effect-%1").arg(m_effectName));
QFile xmlFile(kconfigXTFile);
@ -802,7 +802,7 @@ uint ScriptedEffect::addFragmentShader(ShaderTrait traits, const QString &fragme
m_engine->throwError(QStringLiteral("Failed to make OpenGL context current"));
return 0;
}
const QString shaderDir{QLatin1String(KWIN_NAME "/effects/") + m_effectName + QLatin1String("/contents/shaders/")};
const QString shaderDir{QLatin1String("kwin/effects/") + m_effectName + QLatin1String("/contents/shaders/")};
const QString fragment = fragmentShaderFile.isEmpty() ? QString{} : QStandardPaths::locate(QStandardPaths::GenericDataLocation, shaderDir + fragmentShaderFile);
auto shader = ShaderManager::instance()->generateShaderFromFile(static_cast<KWin::ShaderTraits>(int(traits)), {}, fragment);

View file

@ -748,7 +748,7 @@ LoadScriptList KWin::Scripting::queryScriptsToLoad()
s_started = true;
}
QMap<QString, QString> pluginStates = KConfigGroup(_config, "Plugins").entryMap();
const QString scriptFolder = QStringLiteral(KWIN_NAME "/scripts/");
const QString scriptFolder = QStringLiteral("kwin/scripts/");
const auto offers = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder);
LoadScriptList scriptsToLoad;

View file

@ -509,7 +509,7 @@ template<typename Slot>
void TabBox::key(const KLazyLocalizedString &actionName, Slot slot, const QKeySequence &shortcut)
{
QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setProperty("componentName", QStringLiteral("kwin"));
a->setObjectName(QString::fromUtf8(actionName.untranslatedText()));
a->setText(actionName.toString());
KGlobalAccel::self()->setGlobalShortcut(a, QList<QKeySequence>() << shortcut);

View file

@ -244,7 +244,7 @@ QObject *TabBoxHandlerPrivate::createSwitcherItem(bool desktopMode)
.arg(config.layoutName(),
desktopMode ? QStringLiteral("desktopswitcher/DesktopSwitcher.qml") : QStringLiteral("windowswitcher/WindowSwitcher.qml")));
if (file.isNull()) {
const QString folderName = QLatin1String(KWIN_NAME) + (desktopMode ? QLatin1String("/desktoptabbox/") : QLatin1String("/tabbox/"));
const QString folderName = desktopMode ? QLatin1String("kwin/desktoptabbox/") : QLatin1String("kwin/tabbox/");
auto findSwitcher = [this, desktopMode, folderName] {
const QString type = desktopMode ? QStringLiteral("KWin/DesktopSwitcher") : QStringLiteral("KWin/WindowSwitcher");
auto offers = KPackage::PackageLoader::self()->findPackages(type, folderName,

View file

@ -963,7 +963,7 @@ template<typename T, typename Slot>
void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, T *receiver, Slot slot)
{
QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setProperty("componentName", QStringLiteral("kwin"));
a->setObjectName(actionName);
a->setText(description);
KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << shortcut);
@ -1178,7 +1178,7 @@ void Workspace::windowShortcutUpdated(Window *window)
if (!window->shortcut().isEmpty()) {
if (action == nullptr) { // new shortcut
action = new QAction(this);
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setProperty("componentName", QStringLiteral("kwin"));
action->setObjectName(key);
action->setText(i18n("Activate Window (%1)", window->caption()));
connect(action, &QAction::triggered, window, std::bind(&Workspace::activateWindow, this, window, true));

View file

@ -905,7 +905,7 @@ void VirtualDesktopManager::initSwitchToShortcuts()
QAction *VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)())
{
QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setProperty("componentName", QStringLiteral("kwin"));
a->setObjectName(name.arg(value));
a->setText(label.subs(value).toString());
a->setData(value);
@ -917,7 +917,7 @@ QAction *VirtualDesktopManager::addAction(const QString &name, const KLocalizedS
QAction *VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)())
{
QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setProperty("componentName", QStringLiteral("kwin"));
a->setObjectName(name);
a->setText(label);
KGlobalAccel::setGlobalShortcut(a, QKeySequence());