Adds activity window rules to KWin

- adds the kcm rule option to set the activity - one or all option like
  for virtual desktops
- makes the windows obey the rule
- makes the rule enforced even when the user tries to change the
  window's activity via the alt+f3 menu

REVIEW:104972
icc-effect-5.14.5
Ivan Čukić 2012-05-17 16:32:06 +02:00
parent c8927395ab
commit 0d60a7049d
8 changed files with 481 additions and 364 deletions

View File

@ -1628,18 +1628,26 @@ void Client::setOnActivity(const QString &activity, bool enable)
*/
void Client::setOnActivities(QStringList newActivitiesList)
{
QString joinedActivitiesList = newActivitiesList.join(",");
joinedActivitiesList = rules()->checkActivity(joinedActivitiesList, false);
newActivitiesList = joinedActivitiesList.split(',');
QStringList allActivities = workspace()->activityList();
if (newActivitiesList.size() == allActivities.size() || newActivitiesList.isEmpty()) {
setOnAllActivities(true);
return;
}
activityList.clear();
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (const unsigned char *)"ALL", 3);
QByteArray joined = newActivitiesList.join(",").toAscii();
char *data = joined.data();
activityList = newActivitiesList;
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
} else {
QByteArray joined = joinedActivitiesList.toAscii();
char *data = joined.data();
activityList = newActivitiesList;
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (unsigned char *)data, joined.size());
}
updateActivities(false);
}
@ -1656,7 +1664,7 @@ void Client::updateActivities(bool includeTransients)
workspace()->updateOnAllActivitiesOfTransients(this);
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
updateVisibility();
// TODO: add activity rule
updateWindowRules(Rules::Activity);
// Update states of all other windows in this group
if (tabGroup())
@ -1714,10 +1722,8 @@ void Client::setOnAllActivities(bool on)
if (on == isOnAllActivities())
return;
if (on) {
activityList.clear();
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (const unsigned char *)"ALL", 3);
updateActivities(true);
setOnActivities(QStringList());
} else {
setOnActivity(Workspace::self()->currentActivity(), true);
workspace()->updateOnAllActivitiesOfTransients(this);

View File

@ -9,10 +9,9 @@ kde4_add_ui_files(kwinrules_SRCS ruleslist.ui detectwidget.ui editshortcut.ui ru
set(kwin_rules_dialog_KDEINIT_SRCS main.cpp ${kwinrules_SRCS})
kde4_add_kdeinit_executable( kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_SRCS})
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES})
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES} ${KACTIVITIES_LIBRARY})
install(TARGETS kdeinit_kwin_rules_dialog ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS kwin_rules_dialog DESTINATION ${LIBEXEC_INSTALL_DIR} )
@ -24,7 +23,7 @@ set(kcm_kwinrules_PART_SRCS kcm.cpp ${kwinrules_SRCS})
kde4_add_plugin(kcm_kwinrules ${kcm_kwinrules_PART_SRCS})
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES})
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES} ${KACTIVITIES_LIBRARY})
install(TARGETS kcm_kwinrules DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -27,6 +27,7 @@
#include <kwindowsystem.h>
#include <klocale.h>
#include <QRegExp>
#include <KActivities/Consumer>
#include <assert.h>
#include <kmessagebox.h>
@ -84,6 +85,7 @@ RulesWidget::RulesWidget(QWidget* parent)
SETUP(position, set);
SETUP(size, set);
SETUP(desktop, set);
SETUP(activity, set);
SETUP(maximizehoriz, set);
SETUP(maximizevert, set);
SETUP(minimize, set);
@ -131,6 +133,12 @@ RulesWidget::RulesWidget(QWidget* parent)
++i)
desktop->addItem(QString::number(i).rightJustified(2) + ':' + KWindowSystem::desktopName(i));
desktop->addItem(i18n("All Desktops"));
static KActivities::Consumer activities;
foreach (const QString & activityId, activities.listActivities()) {
activity->addItem(KActivities::Info::name(activityId), activityId);
}
activity->addItem(i18n("All Activities"), QString::fromLatin1("ALL"));
}
#undef SETUP
@ -146,6 +154,7 @@ RulesWidget::RulesWidget(QWidget* parent)
UPDATE_ENABLE_SLOT(position)
UPDATE_ENABLE_SLOT(size)
UPDATE_ENABLE_SLOT(desktop)
UPDATE_ENABLE_SLOT(activity)
UPDATE_ENABLE_SLOT(maximizehoriz)
UPDATE_ENABLE_SLOT(maximizevert)
UPDATE_ENABLE_SLOT(minimize)
@ -281,6 +290,27 @@ int RulesWidget::comboToDesktop(int val) const
return val + 1;
}
int RulesWidget::activityToCombo(QString d) const
{
// TODO: ivan - do a multiselection list
for (int i = 0; i < activity->count(); i++) {
if (activity->itemData(i).toString() == d) {
return i;
}
}
return activity->count() - 1; // on all activities
}
QString RulesWidget::comboToActivity(int val) const
{
// TODO: ivan - do a multiselection list
if (val < 0 || val >= activity->count())
return QString();
return activity->itemData(val).toString();
}
int RulesWidget::tilingToCombo(int t) const
{
return qBound(0, t, 1);
@ -423,6 +453,7 @@ void RulesWidget::setRules(Rules* rules)
LINEEDIT_SET_RULE(position, positionToStr);
LINEEDIT_SET_RULE(size, sizeToStr);
COMBOBOX_SET_RULE(desktop, desktopToCombo);
COMBOBOX_SET_RULE(activity, activityToCombo);
CHECKBOX_SET_RULE(maximizehoriz,);
CHECKBOX_SET_RULE(maximizevert,);
CHECKBOX_SET_RULE(minimize,);
@ -517,6 +548,7 @@ Rules* RulesWidget::rules() const
LINEEDIT_SET_RULE(position, strToPosition);
LINEEDIT_SET_RULE(size, strToSize);
COMBOBOX_SET_RULE(desktop, comboToDesktop);
COMBOBOX_SET_RULE(activity, comboToActivity);
CHECKBOX_SET_RULE(maximizehoriz,);
CHECKBOX_SET_RULE(maximizevert,);
CHECKBOX_SET_RULE(minimize,);
@ -635,6 +667,7 @@ void RulesWidget::prefillUnusedValues(const KWindowInfo& info)
LINEEDIT_PREFILL(position, positionToStr, info.frameGeometry().topLeft());
LINEEDIT_PREFILL(size, sizeToStr, info.frameGeometry().size());
COMBOBOX_PREFILL(desktop, desktopToCombo, info.desktop());
// COMBOBOX_PREFILL(activity, activityToCombo, info.activity()); // TODO: ivan
CHECKBOX_PREFILL(maximizehoriz, , info.state() & NET::MaxHoriz);
CHECKBOX_PREFILL(maximizevert, , info.state() & NET::MaxVert);
CHECKBOX_PREFILL(minimize, , info.isMinimized());

View File

@ -57,6 +57,7 @@ private slots:
void updateEnableposition();
void updateEnablesize();
void updateEnabledesktop();
void updateEnableactivity();
void updateEnablemaximizehoriz();
void updateEnablemaximizevert();
void updateEnableminimize();
@ -93,6 +94,8 @@ private slots:
private:
int desktopToCombo(int d) const;
int comboToDesktop(int val) const;
int activityToCombo(QString d) const;
QString comboToActivity(int val) const;
int tilingToCombo(int t) const;
int comboToTiling(int val) const;
void prefillUnusedValues(const KWindowInfo& info);

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<width>569</width>
<height>517</height>
</rect>
</property>
@ -14,7 +14,7 @@
<item row="0" column="1">
<widget class="QTabWidget" name="tabs">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="TabPage1">
<attribute name="title">
@ -489,13 +489,6 @@
<string>&amp;Size &amp;&amp; Position</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="1">
<widget class="QCheckBox" name="enable_position">
<property name="text">
<string>&amp;Position</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="KComboBox" name="rule_position">
<property name="enabled">
@ -533,104 +526,6 @@
</item>
</widget>
</item>
<item row="0" column="3" colspan="4">
<widget class="KRestrictedLine" name="position">
<property name="enabled">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>x,y</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="enable_size">
<property name="text">
<string>&amp;Size</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="KComboBox" name="rule_size">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="1" column="3" colspan="4">
<widget class="KRestrictedLine" name="size">
<property name="enabled">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>width,height</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
</property>
</widget>
</item>
<item row="2" column="1" rowspan="3" colspan="6">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_maximizehoriz">
<property name="text">
<string>Maximized &amp;horizontally</string>
</property>
</widget>
</item>
<item row="5" column="3" rowspan="2" colspan="4">
<widget class="YesNoBox" name="maximizehoriz" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="enable_maximizevert">
<property name="text">
<string>Maximized &amp;vertically</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="KComboBox" name="rule_maximizevert">
<property name="enabled">
@ -668,43 +563,41 @@
</item>
</widget>
</item>
<item row="7" column="3" colspan="4">
<widget class="YesNoBox" name="maximizevert" native="true">
<item row="0" column="3" colspan="2">
<widget class="KRestrictedLine" name="position">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1" rowspan="3" colspan="6">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="placeholderText">
<string>x,y</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
</property>
</widget>
</item>
<item row="11" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_fullscreen">
<item row="1" column="1">
<widget class="QCheckBox" name="enable_size">
<property name="text">
<string>&amp;Fullscreen</string>
<string>&amp;Size</string>
</property>
</widget>
</item>
<item row="11" column="3" rowspan="2" colspan="4">
<widget class="YesNoBox" name="fullscreen" native="true">
<item row="1" column="3" colspan="2">
<widget class="KRestrictedLine" name="size">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QCheckBox" name="enable_desktop">
<property name="text">
<string>&amp;Desktop</string>
<property name="placeholderText">
<string>width,height</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="KComboBox" name="rule_desktop">
<item row="28" column="2" rowspan="4">
<widget class="KComboBox" name="rule_maxsize">
<property name="enabled">
<bool>false</bool>
</property>
@ -713,26 +606,11 @@
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
@ -740,42 +618,21 @@
</item>
</widget>
</item>
<item row="13" column="3" colspan="4">
<widget class="KComboBox" name="desktop">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="14" column="1" rowspan="3" colspan="6">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="17" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_minimize">
<property name="text">
<string>M&amp;inimized</string>
</property>
</widget>
</item>
<item row="17" column="3" rowspan="2" colspan="4">
<widget class="YesNoBox" name="minimize" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="19" column="1">
<item row="20" column="1">
<widget class="QCheckBox" name="enable_shade">
<property name="text">
<string>Sh&amp;aded</string>
</property>
</widget>
</item>
<item row="19" column="2">
<item row="18" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_minimize">
<property name="text">
<string>M&amp;inimized</string>
</property>
</widget>
</item>
<item row="20" column="2">
<widget class="KComboBox" name="rule_shade">
<property name="enabled">
<bool>false</bool>
@ -812,32 +669,8 @@
</item>
</widget>
</item>
<item row="19" column="3" colspan="4">
<widget class="YesNoBox" name="shade" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="20" column="1" rowspan="2" colspan="6">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="22" column="1">
<widget class="QCheckBox" name="enable_placement">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Initial p&amp;lacement</string>
</property>
</widget>
</item>
<item row="21" column="2" rowspan="2">
<widget class="KComboBox" name="rule_placement">
<item row="1" column="2">
<widget class="KComboBox" name="rule_size">
<property name="enabled">
<bool>false</bool>
</property>
@ -846,11 +679,26 @@
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
@ -858,7 +706,58 @@
</item>
</widget>
</item>
<item row="21" column="3" rowspan="2" colspan="4">
<item row="18" column="2" rowspan="2">
<widget class="KComboBox" name="rule_minimize">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="18" column="3" rowspan="2" colspan="2">
<widget class="YesNoBox" name="minimize" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="24" column="3" colspan="2">
<widget class="YesNoBox" name="ignoreposition" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="22" column="3" rowspan="2" colspan="2">
<widget class="KComboBox" name="placement">
<property name="enabled">
<bool>false</bool>
@ -915,85 +814,7 @@
</item>
</widget>
</item>
<item row="23" column="1">
<widget class="QCheckBox" name="enable_ignoreposition">
<property name="toolTip">
<string>Windows can ask to appear in a certain position.
By default this overrides the placement strategy
what might be nasty if the client abuses the feature
to unconditionally popup in the middle of your screen.</string>
</property>
<property name="text">
<string>Ignore requested &amp;geometry</string>
</property>
</widget>
</item>
<item row="23" column="2">
<widget class="KComboBox" name="rule_ignoreposition">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="23" column="3" colspan="4">
<widget class="YesNoBox" name="ignoreposition" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="24" column="1" colspan="6">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="27" column="1" rowspan="4">
<widget class="QCheckBox" name="enable_maxsize">
<property name="text">
<string>M&amp;aximum size</string>
</property>
</widget>
</item>
<item row="27" column="2" rowspan="4">
<widget class="KComboBox" name="rule_maxsize">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="27" column="3" rowspan="4" colspan="4">
<item row="28" column="3" rowspan="4" colspan="2">
<widget class="KRestrictedLine" name="maxsize">
<property name="enabled">
<bool>false</bool>
@ -1006,29 +827,113 @@ to unconditionally popup in the middle of your screen.</string>
</property>
</widget>
</item>
<item row="31" column="3" rowspan="2" colspan="4">
<item row="28" column="1" rowspan="4">
<widget class="QCheckBox" name="enable_maxsize">
<property name="text">
<string>M&amp;aximum size</string>
</property>
</widget>
</item>
<item row="25" column="1" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="23" column="1">
<widget class="QCheckBox" name="enable_placement">
<property name="toolTip">
<string/>
</property>
<property name="text">
<string>Initial p&amp;lacement</string>
</property>
</widget>
</item>
<item row="20" column="3" colspan="2">
<widget class="YesNoBox" name="shade" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="32" column="3" rowspan="2" colspan="2">
<widget class="YesNoBox" name="strictgeometry" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="33" column="2">
<spacer>
<item row="2" column="1" rowspan="3" colspan="4">
<widget class="Line" name="line_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</widget>
</item>
<item row="12" column="0" rowspan="2">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="32" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_strictgeometry">
<property name="toolTip">
<string>Eg. terminals or video players can ask to keep a certain aspect ratio
or only grow by values larger than one
(eg. by the dimensions of one character).
This may be pointless and the restriction prevents arbitrary dimensions
like your complete screen area.</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Obey geometry restrictions</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="26" column="2" rowspan="2">
<widget class="KComboBox" name="rule_minsize">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="21" column="1" rowspan="2" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="2" rowspan="2">
<widget class="KComboBox" name="rule_maximizehoriz">
<property name="enabled">
@ -1103,8 +1008,127 @@ to unconditionally popup in the middle of your screen.</string>
</item>
</widget>
</item>
<item row="17" column="2" rowspan="2">
<widget class="KComboBox" name="rule_minimize">
<item row="22" column="2" rowspan="2">
<widget class="KComboBox" name="rule_placement">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="7" column="3" colspan="2">
<widget class="YesNoBox" name="maximizevert" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="24" column="1">
<widget class="QCheckBox" name="enable_ignoreposition">
<property name="toolTip">
<string>Windows can ask to appear in a certain position.
By default this overrides the placement strategy
what might be nasty if the client abuses the feature
to unconditionally popup in the middle of your screen.</string>
</property>
<property name="text">
<string>Ignore requested &amp;geometry</string>
</property>
</widget>
</item>
<item row="5" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_maximizehoriz">
<property name="text">
<string>Maximized &amp;horizontally</string>
</property>
</widget>
</item>
<item row="11" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_fullscreen">
<property name="text">
<string>&amp;Fullscreen</string>
</property>
</widget>
</item>
<item row="13" column="3" colspan="2">
<widget class="KComboBox" name="desktop">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="11" column="3" rowspan="2" colspan="2">
<widget class="YesNoBox" name="fullscreen" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="26" column="3" rowspan="2" colspan="2">
<widget class="KRestrictedLine" name="minsize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>width,height</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
</property>
</widget>
</item>
<item row="24" column="2">
<widget class="KComboBox" name="rule_ignoreposition">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="enable_position">
<property name="text">
<string>&amp;Position</string>
</property>
</widget>
</item>
<item row="5" column="3" rowspan="2" colspan="2">
<widget class="YesNoBox" name="maximizehoriz" native="true">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="KComboBox" name="rule_desktop">
<property name="enabled">
<bool>false</bool>
</property>
@ -1140,49 +1164,28 @@ to unconditionally popup in the middle of your screen.</string>
</item>
</widget>
</item>
<item row="25" column="3" rowspan="2" colspan="4">
<widget class="KRestrictedLine" name="minsize">
<property name="enabled">
<bool>false</bool>
</property>
<property name="placeholderText">
<string>width,height</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
<item row="7" column="1">
<widget class="QCheckBox" name="enable_maximizevert">
<property name="text">
<string>Maximized &amp;vertically</string>
</property>
</widget>
</item>
<item row="25" column="2" rowspan="2">
<widget class="KComboBox" name="rule_minsize">
<property name="enabled">
<bool>false</bool>
<item row="13" column="1">
<widget class="QCheckBox" name="enable_desktop">
<property name="text">
<string>&amp;Desktop</string>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="25" column="1" rowspan="2">
<item row="26" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_minsize">
<property name="text">
<string>M&amp;inimum size</string>
</property>
</widget>
</item>
<item row="12" column="7" rowspan="2">
<item row="12" column="5" rowspan="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -1195,40 +1198,14 @@ to unconditionally popup in the middle of your screen.</string>
</property>
</spacer>
</item>
<item row="12" column="0" rowspan="2">
<spacer name="horizontalSpacer_7">
<item row="8" column="1" rowspan="3" colspan="4">
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="31" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_strictgeometry">
<property name="toolTip">
<string>Eg. terminals or video players can ask to keep a certain aspect ratio
or only grow by values larger than one
(eg. by the dimensions of one character).
This may be pointless and the restriction prevents arbitrary dimensions
like your complete screen area.</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Obey geometry restrictions</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="31" column="2" rowspan="2">
<item row="32" column="2" rowspan="2">
<widget class="KComboBox" name="rule_strictgeometry">
<property name="enabled">
<bool>false</bool>
@ -1250,6 +1227,80 @@ like your complete screen area.</string>
</item>
</widget>
</item>
<item row="15" column="1" rowspan="3" colspan="4">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="34" column="2">
<spacer>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="enable_activity">
<property name="text">
<string>Activit&amp;y</string>
</property>
</widget>
</item>
<item row="14" column="2">
<widget class="KComboBox" name="rule_activity">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Do Not Affect</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item>
<property name="text">
<string>Force</string>
</property>
</item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item>
<property name="text">
<string>Force Temporarily</string>
</property>
</item>
</widget>
</item>
<item row="14" column="3" colspan="2">
<widget class="KComboBox" name="activity">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="TabPage4">

View File

@ -205,6 +205,7 @@ bool Client::manage(Window w, bool isMapped)
setOnActivity(Workspace::self()->currentActivity(), true);
}
}
if (desk == 0) // Assume window wants to be visible on the current desktop
desk = isDesktop() ? NET::OnAllDesktops : workspace()->currentDesktop();
desk = rules()->checkDesktop(desk, !isMapped);
@ -214,6 +215,11 @@ bool Client::manage(Window w, bool isMapped)
workspace()->updateOnAllDesktopsOfTransients(this); // SELI TODO
//onAllDesktopsChange(); // Decoration doesn't exist here yet
QString activitiesList;
activitiesList = rules()->checkActivity(activitiesList, !isMapped);
if (!activitiesList.isEmpty())
setOnActivities(activitiesList.split(","));
QRect geom(attr.x, attr.y, attr.width, attr.height);
bool placementDone = false;

View File

@ -53,6 +53,7 @@ Rules::Rules()
, tilingoptionrule(UnusedForceRule)
, ignorepositionrule(UnusedForceRule)
, desktoprule(UnusedSetRule)
, activityrule(UnusedSetRule)
, typerule(UnusedForceRule)
, maximizevertrule(UnusedSetRule)
, maximizehorizrule(UnusedSetRule)
@ -158,6 +159,7 @@ void Rules::readFromCfg(const KConfigGroup& cfg)
READ_FORCE_RULE(tilingoption, , 0);
READ_FORCE_RULE(ignoreposition, , false);
READ_SET_RULE(desktop, , 0);
READ_SET_RULE(activity, , QString());
type = readType(cfg, "type");
typerule = type != NET::Unknown ? readForceRule(cfg, "typerule") : UnusedForceRule;
READ_SET_RULE(maximizevert, , false);
@ -247,6 +249,7 @@ void Rules::write(KConfigGroup& cfg) const
WRITE_FORCE_RULE(tilingoption,);
WRITE_FORCE_RULE(ignoreposition,);
WRITE_SET_RULE(desktop,);
WRITE_SET_RULE(activity,);
WRITE_FORCE_RULE(type, int);
WRITE_SET_RULE(maximizevert,);
WRITE_SET_RULE(maximizehoriz,);
@ -288,6 +291,7 @@ bool Rules::isEmpty() const
&& tilingoptionrule == UnusedForceRule
&& ignorepositionrule == UnusedForceRule
&& desktoprule == UnusedSetRule
&& activityrule == UnusedSetRule
&& typerule == UnusedForceRule
&& maximizevertrule == UnusedSetRule
&& maximizehorizrule == UnusedSetRule
@ -459,6 +463,12 @@ bool Rules::update(Client* c, int selection)
updated = updated || desktop != c->desktop();
desktop = c->desktop();
}
if NOW_REMEMBER(Activity, activity) {
// TODO: ivan - multiple activities support
const QString & joinedActivities = c->activities().join(",");
updated = updated || activity != joinedActivities;
activity = joinedActivities;
}
if NOW_REMEMBER(MaximizeVert, maximizevert) {
updated = updated || maximizevert != bool(c->maximizeMode() & MaximizeVertical);
maximizevert = c->maximizeMode() & MaximizeVertical;
@ -576,6 +586,7 @@ bool Rules::applyIgnoreGeometry(bool& ignore) const
}
APPLY_RULE(desktop, Desktop, int)
APPLY_RULE(activity, Activity, QString)
APPLY_FORCE_RULE(type, Type, NET::WindowType)
bool Rules::applyMaximizeHoriz(MaximizeMode& mode, bool init) const
@ -666,6 +677,7 @@ void Rules::discardUsed(bool withdrawn)
DISCARD_USED_FORCE_RULE(tilingoption);
DISCARD_USED_FORCE_RULE(ignoreposition);
DISCARD_USED_SET_RULE(desktop);
DISCARD_USED_SET_RULE(activity);
DISCARD_USED_FORCE_RULE(type);
DISCARD_USED_SET_RULE(maximizevert);
DISCARD_USED_SET_RULE(maximizehoriz);
@ -781,6 +793,7 @@ bool WindowRules::checkIgnoreGeometry(bool ignore) const
}
CHECK_RULE(Desktop, int)
CHECK_RULE(Activity, QString)
CHECK_FORCE_RULE(Type, NET::WindowType)
CHECK_RULE(MaximizeVert, KDecorationDefines::MaximizeMode)
CHECK_RULE(MaximizeHoriz, KDecorationDefines::MaximizeMode)
@ -837,6 +850,7 @@ void Client::applyWindowRules()
// MinSize, MaxSize handled by Geometry
// IgnorePosition
setDesktop(desktop());
setOnActivities(activities());
// Type
maximize(maximizeMode());
// Minimize : functions don't check, and there are two functions

View File

@ -64,6 +64,7 @@ public:
int checkTilingOption(int s) const;
bool checkIgnoreGeometry(bool ignore) const;
int checkDesktop(int desktop, bool init = false) const;
QString checkActivity(QString 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;
@ -105,7 +106,8 @@ public:
MaximizeVert = 1<<3, MaximizeHoriz = 1<<4, Minimize = 1<<5,
Shade = 1<<6, SkipTaskbar = 1<<7, SkipPager = 1<<8,
SkipSwitcher = 1<<9, Above = 1<<10, Below = 1<<11, Fullscreen = 1<<12,
NoBorder = 1<<13, OpacityActive = 1<<14, OpacityInactive = 1<<15, All = 0xffffffff
NoBorder = 1<<13, OpacityActive = 1<<14, OpacityInactive = 1<<15,
Activity = 1<<16, All = 0xffffffff
};
Q_DECLARE_FLAGS(Types, Type)
void write(KConfigGroup&) const;
@ -128,6 +130,7 @@ public:
bool applyTilingOption(int& s) const;
bool applyIgnoreGeometry(bool& ignore) const;
bool applyDesktop(int& desktop, bool init) const;
bool applyActivity(QString& activity, bool init) const;
bool applyType(NET::WindowType& type) const;
bool applyMaximizeVert(MaximizeMode& mode, bool init) const;
bool applyMaximizeHoriz(MaximizeMode& mode, bool init) const;
@ -226,6 +229,8 @@ private:
ForceRule ignorepositionrule;
int desktop;
SetRule desktoprule;
QString activity;
SetRule activityrule;
NET::WindowType type; // type for setting
ForceRule typerule;
bool maximizevert;