diff --git a/kcmkwin/kwinrules/CMakeLists.txt b/kcmkwin/kwinrules/CMakeLists.txt index 7027b1ffec..dc6e935f21 100644 --- a/kcmkwin/kwinrules/CMakeLists.txt +++ b/kcmkwin/kwinrules/CMakeLists.txt @@ -11,6 +11,7 @@ set(kwinrules_SRCS ../../rules.cpp ../../placement.cpp ../../utils.cpp + ../../virtualdesktopsdbustypes.cpp kwinsrc.cpp optionsmodel.cpp ruleitem.cpp diff --git a/kcmkwin/kwinrules/ruleitem.cpp b/kcmkwin/kwinrules/ruleitem.cpp index a4efce7f10..ff8047e71d 100644 --- a/kcmkwin/kwinrules/ruleitem.cpp +++ b/kcmkwin/kwinrules/ruleitem.cpp @@ -119,7 +119,7 @@ RuleItem::Type RuleItem::type() const QVariant RuleItem::value() const { - if (m_type == Option) { + if (m_options && m_type == Option) { return m_options->value(); } return m_value; @@ -127,7 +127,7 @@ QVariant RuleItem::value() const void RuleItem::setValue(QVariant value) { - if (m_type == Option) { + if (m_options && m_type == Option) { m_options->setValue(value); } m_value = typedValue(value, m_type); diff --git a/kcmkwin/kwinrules/rulesmodel.cpp b/kcmkwin/kwinrules/rulesmodel.cpp index bdf1309e45..daa17a0c03 100644 --- a/kcmkwin/kwinrules/rulesmodel.cpp +++ b/kcmkwin/kwinrules/rulesmodel.cpp @@ -45,6 +45,9 @@ RulesModel::RulesModel(QObject *parent) qmlRegisterUncreatableType("org.kde.kcms.kwinrules", 1, 0, "RulesModel", QStringLiteral("Do not create objects of type RulesModel")); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + populateRuleList(); } @@ -421,6 +424,10 @@ void RulesModel::populateRuleList() QIcon::fromTheme("virtual-desktops"))); desktop->setOptionsData(virtualDesktopsModelData()); + connect(this, &RulesModel::virtualDesktopsUpdated, + this, [this] { m_rules["desktop"]->setOptionsData(virtualDesktopsModelData()); }); + updateVirtualDesktops(); + #ifdef KWIN_BUILD_ACTIVITIES m_activities = new KActivities::Consumer(this); @@ -700,10 +707,10 @@ QList RulesModel::windowTypesModelData() const QList RulesModel::virtualDesktopsModelData() const { QList modelData; - for (int desktopId = 1; desktopId <= KWindowSystem::numberOfDesktops(); ++desktopId) { + for (const DBusDesktopDataStruct &desktop : m_virtualDesktops) { modelData << OptionsModel::Data{ - desktopId, - QString::number(desktopId).rightJustified(2) + QStringLiteral(": ") + KWindowSystem::desktopName(desktopId), + desktop.position + 1, // "desktop" setting uses the desktop position (int) starting at 1 + QString::number(desktop.position + 1).rightJustified(2) + QStringLiteral(": ") + desktop.name, QIcon::fromTheme("virtual-desktops") }; } @@ -740,18 +747,17 @@ QList RulesModel::activitiesModelData() const QList RulesModel::placementModelData() const { - // From "placement.h" : Placement rule is stored as a string, not the enum value static const auto modelData = QList { - { Placement::policyToString(Placement::Default), i18n("Default") }, - { Placement::policyToString(Placement::NoPlacement), i18n("No Placement") }, - { Placement::policyToString(Placement::Smart), i18n("Minimal Overlapping") }, - { Placement::policyToString(Placement::Maximizing), i18n("Maximized") }, - { Placement::policyToString(Placement::Cascade), i18n("Cascaded") }, - { Placement::policyToString(Placement::Centered), i18n("Centered") }, - { Placement::policyToString(Placement::Random), i18n("Random") }, - { Placement::policyToString(Placement::ZeroCornered), i18n("In Top-Left Corner") }, - { Placement::policyToString(Placement::UnderMouse), i18n("Under Mouse") }, - { Placement::policyToString(Placement::OnMainWindow), i18n("On Main Window") } + { Placement::Default, i18n("Default") }, + { Placement::NoPlacement, i18n("No Placement") }, + { Placement::Smart, i18n("Minimal Overlapping") }, + { Placement::Maximizing, i18n("Maximized") }, + { Placement::Cascade, i18n("Cascaded") }, + { Placement::Centered, i18n("Centered") }, + { Placement::Random, i18n("Random") }, + { Placement::ZeroCornered, i18n("In Top-Left Corner") }, + { Placement::UnderMouse, i18n("Under Mouse") }, + { Placement::OnMainWindow, i18n("On Main Window") } }; return modelData; } @@ -816,4 +822,32 @@ void RulesModel::selectX11Window() ); } +void RulesModel::updateVirtualDesktops() +{ + QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.KWin"), + QStringLiteral("/VirtualDesktopManager"), + QStringLiteral("org.freedesktop.DBus.Properties"), + QStringLiteral("Get")); + message.setArguments(QVariantList{ + QStringLiteral("org.kde.KWin.VirtualDesktopManager"), + QStringLiteral("desktops") + }); + + QDBusPendingReply async = QDBusConnection::sessionBus().asyncCall(message); + + QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(async, this); + connect(callWatcher, &QDBusPendingCallWatcher::finished, this, + [this](QDBusPendingCallWatcher *self) { + QDBusPendingReply reply = *self; + self->deleteLater(); + if (!reply.isValid()) { + return; + } + m_virtualDesktops = qdbus_cast(reply.value()); + emit virtualDesktopsUpdated(); + } + ); +} + + } //namespace diff --git a/kcmkwin/kwinrules/rulesmodel.h b/kcmkwin/kwinrules/rulesmodel.h index 3de0736845..a62cff5525 100644 --- a/kcmkwin/kwinrules/rulesmodel.h +++ b/kcmkwin/kwinrules/rulesmodel.h @@ -22,8 +22,9 @@ #define KWIN_RULES_MODEL_H #include "ruleitem.h" -#include "rulesettings.h" #include +#include +#include #include #include @@ -96,6 +97,8 @@ signals: void warningMessageChanged(); void suggestionsChanged(); + void virtualDesktopsUpdated(); + private: void populateRuleList(); bool wmclassWarning() const; @@ -103,6 +106,7 @@ private: QString defaultDescription() const; static const QHash x11PropertyHash(); + void updateVirtualDesktops(); QList windowTypesModelData() const; QList virtualDesktopsModelData() const; @@ -117,6 +121,7 @@ private slots: private: QList m_ruleList; QHash m_rules; + DBusDesktopDataVector m_virtualDesktops; #ifdef KWIN_BUILD_ACTIVITIES KActivities::Consumer *m_activities; #endif diff --git a/plugins/platforms/drm/drm_backend.h b/plugins/platforms/drm/drm_backend.h index 545865187f..93333279a6 100644 --- a/plugins/platforms/drm/drm_backend.h +++ b/plugins/platforms/drm/drm_backend.h @@ -132,6 +132,10 @@ public: QString supportInformation() const override; + bool isCursorEnabled() const { + return m_cursorEnabled; + }; + public Q_SLOTS: void turnOutputsOn(); diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp index 0d3ee97788..66ffbe06aa 100644 --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -709,9 +709,12 @@ void DrmOutput::updateTransform(Transform transform) } m_modesetRequested = true; - // the cursor might need to get rotated - updateCursor(); - showCursor(); + // show cursor only if is enabled, i.e if pointer device is presentP + if (m_backend->isCursorEnabled()) { + // the cursor might need to get rotated + updateCursor(); + showCursor(); + } } void DrmOutput::updateMode(int modeIndex) @@ -867,9 +870,11 @@ bool DrmOutput::presentAtomically(DrmBuffer *buffer) m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); } m_modesetRequested = true; - // the cursor might need to get rotated - updateCursor(); - showCursor(); + if (m_backend->isCursorEnabled()) { + // the cursor might need to get rotated + updateCursor(); + showCursor(); + } // TODO: forward to OutputInterface and OutputDeviceInterface setWaylandMode(); emit screens()->changed(); diff --git a/scene.cpp b/scene.cpp index 7b0a2fc09d..d798998092 100644 --- a/scene.cpp +++ b/scene.cpp @@ -1132,8 +1132,9 @@ void WindowPixmap::create() if (kwinApp()->shouldUseWaylandForCompositing()) { // use Buffer update(); - if (!isRoot() && isValid()) { + if (isRoot() && isValid()) { m_window->unreferencePreviousPixmap(); + m_window->invalidateQuadsCache(); } return; } @@ -1164,6 +1165,7 @@ void WindowPixmap::create() m_pixmapSize = bufferGeometry.size(); m_contentsRect = QRect(toplevel()->clientPos(), toplevel()->clientSize()); m_window->unreferencePreviousPixmap(); + m_window->invalidateQuadsCache(); } void WindowPixmap::update()