kwinrules: Allow multiple activities in rule settings
Change the setting's type from `QString` to `QStringList` and adjust relevant code. Previous config requires no porting as a single string in the config file is read as the first item in the list.
This commit is contained in:
parent
ccfaf1a1d6
commit
fc1553e8ee
4 changed files with 14 additions and 18 deletions
10
rules.cpp
10
rules.cpp
|
@ -451,10 +451,8 @@ bool Rules::update(AbstractClient* c, int selection)
|
|||
screen = c->screen();
|
||||
}
|
||||
if NOW_REMEMBER(Activity, activity) {
|
||||
// TODO: ivan - multiple activities support
|
||||
const QString & joinedActivities = c->activities().join(QStringLiteral(","));
|
||||
updated = updated || activity != joinedActivities;
|
||||
activity = joinedActivities;
|
||||
updated = updated || activity != c->activities();
|
||||
activity = c->activities();
|
||||
}
|
||||
if NOW_REMEMBER(MaximizeVert, maximizevert) {
|
||||
updated = updated || maximizevert != bool(c->maximizeMode() & MaximizeVertical);
|
||||
|
@ -565,7 +563,7 @@ APPLY_RULE(ignoregeometry, IgnoreGeometry, bool)
|
|||
|
||||
APPLY_RULE(desktop, Desktop, int)
|
||||
APPLY_RULE(screen, Screen, int)
|
||||
APPLY_RULE(activity, Activity, QString)
|
||||
APPLY_RULE(activity, Activity, QStringList)
|
||||
APPLY_FORCE_RULE(type, Type, NET::WindowType)
|
||||
|
||||
bool Rules::applyMaximizeHoriz(MaximizeMode& mode, bool init) const
|
||||
|
@ -779,7 +777,7 @@ CHECK_FORCE_RULE(OpacityInactive, int)
|
|||
CHECK_RULE(IgnoreGeometry, bool)
|
||||
|
||||
CHECK_RULE(Desktop, int)
|
||||
CHECK_RULE(Activity, QString)
|
||||
CHECK_RULE(Activity, QStringList)
|
||||
CHECK_FORCE_RULE(Type, NET::WindowType)
|
||||
CHECK_RULE(MaximizeVert, MaximizeMode)
|
||||
CHECK_RULE(MaximizeHoriz, MaximizeMode)
|
||||
|
|
6
rules.h
6
rules.h
|
@ -53,7 +53,7 @@ public:
|
|||
bool checkIgnoreGeometry(bool ignore, bool init = false) const;
|
||||
int checkDesktop(int desktop, bool init = false) const;
|
||||
int checkScreen(int screen, bool init = false) const;
|
||||
QString checkActivity(QString activity, bool init = false) const;
|
||||
QStringList checkActivity(QStringList activity, bool init = false) const;
|
||||
NET::WindowType checkType(NET::WindowType type) const;
|
||||
MaximizeMode checkMaximize(MaximizeMode mode, bool init = false) const;
|
||||
bool checkMinimize(bool minimized, bool init = false) const;
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
bool applyIgnoreGeometry(bool& ignore, bool init) const;
|
||||
bool applyDesktop(int& desktop, bool init) const;
|
||||
bool applyScreen(int& desktop, bool init) const;
|
||||
bool applyActivity(QString& activity, bool init) const;
|
||||
bool applyActivity(QStringList& activity, bool init) const;
|
||||
bool applyType(NET::WindowType& type) const;
|
||||
bool applyMaximizeVert(MaximizeMode& mode, bool init) const;
|
||||
bool applyMaximizeHoriz(MaximizeMode& mode, bool init) const;
|
||||
|
@ -221,7 +221,7 @@ private:
|
|||
SetRule desktoprule;
|
||||
int screen;
|
||||
SetRule screenrule;
|
||||
QString activity;
|
||||
QStringList activity;
|
||||
SetRule activityrule;
|
||||
NET::WindowType type; // type for setting
|
||||
ForceRule typerule;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
|
||||
<kcfgfile arg="true">
|
||||
|
@ -169,7 +169,7 @@
|
|||
<default code="true">Rules::UnusedSetRule</default>
|
||||
</entry>
|
||||
|
||||
<entry name="activity" type="String">
|
||||
<entry name="activity" type="StringList">
|
||||
<label>Activity</label>
|
||||
</entry>
|
||||
<entry name="activityrule" type="Int">
|
||||
|
|
|
@ -527,10 +527,10 @@ bool X11Client::manage(xcb_window_t w, bool isMapped)
|
|||
workspace()->updateOnAllDesktopsOfTransients(this); // SELI TODO
|
||||
//onAllDesktopsChange(); // Decoration doesn't exist here yet
|
||||
|
||||
QString activitiesList;
|
||||
QStringList activitiesList;
|
||||
activitiesList = rules()->checkActivity(activitiesList, !isMapped);
|
||||
if (!activitiesList.isEmpty())
|
||||
setOnActivities(activitiesList.split(QStringLiteral(",")));
|
||||
setOnActivities(activitiesList);
|
||||
|
||||
QRect geom(windowGeometry.rect());
|
||||
bool placementDone = false;
|
||||
|
@ -1912,9 +1912,7 @@ void X11Client::setOnActivities(QStringList newActivitiesList)
|
|||
if (!Activities::self()) {
|
||||
return;
|
||||
}
|
||||
QString joinedActivitiesList = newActivitiesList.join(QStringLiteral(","));
|
||||
joinedActivitiesList = rules()->checkActivity(joinedActivitiesList, false);
|
||||
newActivitiesList = joinedActivitiesList.split(u',', Qt::SkipEmptyParts);
|
||||
newActivitiesList = rules()->checkActivity(newActivitiesList);
|
||||
|
||||
QStringList allActivities = Activities::self()->all();
|
||||
|
||||
|
@ -1928,7 +1926,7 @@ void X11Client::setOnActivities(QStringList newActivitiesList)
|
|||
}
|
||||
|
||||
if (// If we got the request to be on all activities explicitly
|
||||
newActivitiesList.isEmpty() || joinedActivitiesList == Activities::nullUuid() ||
|
||||
newActivitiesList.isEmpty() || newActivitiesList.contains(Activities::nullUuid()) ||
|
||||
// If we got a list of activities that covers all activities
|
||||
(newActivitiesList.count() > 1 && newActivitiesList.count() == allActivities.count())) {
|
||||
|
||||
|
@ -1937,7 +1935,7 @@ void X11Client::setOnActivities(QStringList newActivitiesList)
|
|||
m_client.changeProperty(atoms->activities, XCB_ATOM_STRING, 8, nullUuid.length(), nullUuid.constData());
|
||||
|
||||
} else {
|
||||
QByteArray joined = joinedActivitiesList.toLatin1();
|
||||
QByteArray joined = newActivitiesList.join(QStringLiteral(",")).toLatin1();
|
||||
activityList = newActivitiesList;
|
||||
m_client.changeProperty(atoms->activities, XCB_ATOM_STRING, 8, joined.length(), joined.constData());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue