Commit 28b1f890 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

wayland: Set kwin up for allowing Xwayland clients scale themselves

Announces that the wayland backend supports the XwaylandClientsScale
setting, which is a boolean value to tell kwin whether it should
automatically scale xwayland apps or let the apps do it themselves.

When the setting changes:
- Updates and notifies kwin's xwayland scale value so it adapts.
- Runs the fonts kcminit module so that the system gets properly
initialised.
parent 18b8f22c
Pipeline #191289 passed with stage
in 4 minutes and 8 seconds
......@@ -6,3 +6,4 @@ Dependencies:
'require':
'frameworks/extra-cmake-modules': '@latest'
'frameworks/kwayland': '@latest'
'frameworks/kconfig': '@latest'
......@@ -36,14 +36,11 @@ find_package(WaylandScanner)
# Wayland backend
find_package(KF5Wayland ${KF5_MIN_VERSION} CONFIG REQUIRED)
add_feature_info("KF5Wayland" KF5Wayland_FOUND "Required for building libkscreen's KWayland backend")
find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED)
find_package(PlasmaWaylandProtocols 1.6.0 CONFIG)
set_package_properties(PlasmaWaylandProtocols PROPERTIES TYPE REQUIRED)
# Wayland backend
find_package(KF5Wayland ${KF5_MIN_VERSION} CONFIG REQUIRED)
add_feature_info("KF5Wayland" KF5Wayland_FOUND "Required for building libkscreen's KWayland backend")
find_package(Wayland 1.15 COMPONENTS Client)
set_package_properties(Wayland PROPERTIES
TYPE REQUIRED
......
......@@ -47,6 +47,7 @@ set_target_properties(KSC_KWayland PROPERTIES PREFIX "")
target_link_libraries(KSC_KWayland Qt::Core
Qt::DBus
Qt::Gui
KF5::ConfigCore
KF5::Screen
KF5::WaylandClient
Wayland::Client
......
......@@ -16,9 +16,13 @@
#include <configmonitor.h>
#include <mode.h>
#include <QProcess>
#include <QSettings>
#include <QStandardPaths>
#include <KConfig>
#include <KConfigGroup>
using namespace KScreen;
WaylandBackend::WaylandBackend()
......@@ -28,7 +32,31 @@ WaylandBackend::WaylandBackend()
qCDebug(KSCREEN_WAYLAND) << "Loading Wayland backend.";
connect(m_internalConfig, &WaylandConfig::configChanged, this, [this]() {
Q_EMIT configChanged(m_internalConfig->currentConfig());
const auto newConfig = m_internalConfig->currentConfig();
KConfig cfg(QStringLiteral("kdeglobals"));
KConfigGroup kscreenGroup = cfg.group("KScreen");
const bool xwaylandClientsScale = kscreenGroup.readEntry("XwaylandClientsScale", false);
KConfig kwinCfg(QStringLiteral("kwinrc"));
KConfigGroup xwaylandGroup = kwinCfg.group("Xwayland");
if (xwaylandClientsScale) {
qreal scaleFactor = 1;
const auto outputs = newConfig->outputs();
for (auto output : outputs) {
scaleFactor = std::max(scaleFactor, output->scale());
}
xwaylandGroup.writeEntry("Scale", scaleFactor, KConfig::Notify);
} else {
xwaylandGroup.deleteEntry("Scale", KConfig::Notify);
}
// here we rerun the fonts kcm init that does the appropriate xrdb call with the new settings
QProcess::startDetached("kcminit", {"kcm_fonts"});
Q_EMIT configChanged(newConfig);
});
}
......
......@@ -242,7 +242,7 @@ KScreen::ConfigPtr WaylandConfig::currentConfig()
m_kscreenConfig->setScreen(m_screen->toKScreenScreen(m_kscreenConfig));
const auto features = Config::Feature::Writable | Config::Feature::PerOutputScaling | Config::Feature::AutoRotation | Config::Feature::TabletMode
| Config::Feature::PrimaryDisplay | Config::Feature::SynchronousOutputChanges;
| Config::Feature::PrimaryDisplay | Config::Feature::XwaylandScales | Config::Feature::SynchronousOutputChanges;
m_kscreenConfig->setSupportedFeatures(features);
m_kscreenConfig->setValid(m_connection->display());
......
......@@ -42,6 +42,7 @@ public:
None = 0x0,
RequireAtLeastOneEnabledScreen = 0x1,
};
Q_ENUM(ValidityFlag)
Q_DECLARE_FLAGS(ValidityFlags, ValidityFlag)
/** This indicates which features the used backend supports.
......@@ -58,7 +59,9 @@ public:
AutoRotation = 1 << 4, ///< The backend supports automatic rotation of outputs.
TabletMode = 1 << 5, ///< The backend supports querying if a device is in tablet mode.
SynchronousOutputChanges = 1 << 6, ///< The backend supports blocking until the output setting changes are applied
XwaylandScales = 1 << 7, ///< The backend supports adapting Xwayland clients to a certain scale
};
Q_ENUM(Feature)
Q_DECLARE_FLAGS(Features, Feature)
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment