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
This commit is contained in:
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) void Client::setOnActivities(QStringList newActivitiesList)
{ {
QString joinedActivitiesList = newActivitiesList.join(",");
joinedActivitiesList = rules()->checkActivity(joinedActivitiesList, false);
newActivitiesList = joinedActivitiesList.split(',');
QStringList allActivities = workspace()->activityList(); QStringList allActivities = workspace()->activityList();
if (newActivitiesList.size() == allActivities.size() || newActivitiesList.isEmpty()) { if (newActivitiesList.size() == allActivities.size() || newActivitiesList.isEmpty()) {
setOnAllActivities(true); setOnAllActivities(true);
return; activityList.clear();
} XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (const unsigned char *)"ALL", 3);
QByteArray joined = newActivitiesList.join(",").toAscii(); } else {
char *data = joined.data(); QByteArray joined = joinedActivitiesList.toAscii();
activityList = newActivitiesList; char *data = joined.data();
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8, activityList = newActivitiesList;
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (unsigned char *)data, joined.size()); PropModeReplace, (unsigned char *)data, joined.size());
}
updateActivities(false); updateActivities(false);
} }
@ -1656,7 +1664,7 @@ void Client::updateActivities(bool includeTransients)
workspace()->updateOnAllActivitiesOfTransients(this); workspace()->updateOnAllActivitiesOfTransients(this);
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst); workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
updateVisibility(); updateVisibility();
// TODO: add activity rule updateWindowRules(Rules::Activity);
// Update states of all other windows in this group // Update states of all other windows in this group
if (tabGroup()) if (tabGroup())
@ -1714,10 +1722,8 @@ void Client::setOnAllActivities(bool on)
if (on == isOnAllActivities()) if (on == isOnAllActivities())
return; return;
if (on) { if (on) {
activityList.clear(); setOnActivities(QStringList());
XChangeProperty(display(), window(), atoms->activities, XA_STRING, 8,
PropModeReplace, (const unsigned char *)"ALL", 3);
updateActivities(true);
} else { } else {
setOnActivity(Workspace::self()->currentActivity(), true); setOnActivity(Workspace::self()->currentActivity(), true);
workspace()->updateOnAllActivitiesOfTransients(this); 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}) set(kwin_rules_dialog_KDEINIT_SRCS main.cpp ${kwinrules_SRCS})
kde4_add_kdeinit_executable( kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_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 kdeinit_kwin_rules_dialog ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS kwin_rules_dialog DESTINATION ${LIBEXEC_INSTALL_DIR} ) 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}) 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} ) install(TARGETS kcm_kwinrules DESTINATION ${PLUGIN_INSTALL_DIR} )

View file

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

View file

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

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>547</width> <width>569</width>
<height>517</height> <height>517</height>
</rect> </rect>
</property> </property>
@ -14,7 +14,7 @@
<item row="0" column="1"> <item row="0" column="1">
<widget class="QTabWidget" name="tabs"> <widget class="QTabWidget" name="tabs">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="TabPage1"> <widget class="QWidget" name="TabPage1">
<attribute name="title"> <attribute name="title">
@ -489,13 +489,6 @@
<string>&amp;Size &amp;&amp; Position</string> <string>&amp;Size &amp;&amp; Position</string>
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout_5"> <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"> <item row="0" column="2">
<widget class="KComboBox" name="rule_position"> <widget class="KComboBox" name="rule_position">
<property name="enabled"> <property name="enabled">
@ -533,104 +526,6 @@
</item> </item>
</widget> </widget>
</item> </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"> <item row="7" column="2">
<widget class="KComboBox" name="rule_maximizevert"> <widget class="KComboBox" name="rule_maximizevert">
<property name="enabled"> <property name="enabled">
@ -668,43 +563,41 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="7" column="3" colspan="4"> <item row="0" column="3" colspan="2">
<widget class="YesNoBox" name="maximizevert" native="true"> <widget class="KRestrictedLine" name="position">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> <property name="placeholderText">
</item> <string>x,y</string>
<item row="8" column="1" rowspan="3" colspan="6"> </property>
<widget class="Line" name="line_4"> <property name="validChars">
<property name="orientation"> <string>0123456789-+,xX:</string>
<enum>Qt::Horizontal</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="1" rowspan="2"> <item row="1" column="1">
<widget class="QCheckBox" name="enable_fullscreen"> <widget class="QCheckBox" name="enable_size">
<property name="text"> <property name="text">
<string>&amp;Fullscreen</string> <string>&amp;Size</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="11" column="3" rowspan="2" colspan="4"> <item row="1" column="3" colspan="2">
<widget class="YesNoBox" name="fullscreen" native="true"> <widget class="KRestrictedLine" name="size">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> <property name="placeholderText">
</item> <string>width,height</string>
<item row="13" column="1"> </property>
<widget class="QCheckBox" name="enable_desktop"> <property name="validChars">
<property name="text"> <string>0123456789-+,xX:</string>
<string>&amp;Desktop</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="13" column="2"> <item row="28" column="2" rowspan="4">
<widget class="KComboBox" name="rule_desktop"> <widget class="KComboBox" name="rule_maxsize">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -713,26 +606,11 @@
<string>Do Not Affect</string> <string>Do Not Affect</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Force</string> <string>Force</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Force Temporarily</string> <string>Force Temporarily</string>
@ -740,42 +618,21 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="13" column="3" colspan="4"> <item row="20" column="1">
<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">
<widget class="QCheckBox" name="enable_shade"> <widget class="QCheckBox" name="enable_shade">
<property name="text"> <property name="text">
<string>Sh&amp;aded</string> <string>Sh&amp;aded</string>
</property> </property>
</widget> </widget>
</item> </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"> <widget class="KComboBox" name="rule_shade">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -812,32 +669,8 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="19" column="3" colspan="4"> <item row="1" column="2">
<widget class="YesNoBox" name="shade" native="true"> <widget class="KComboBox" name="rule_size">
<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">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -846,11 +679,26 @@
<string>Do Not Affect</string> <string>Do Not Affect</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Apply Initially</string>
</property>
</item>
<item>
<property name="text">
<string>Remember</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Force</string> <string>Force</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Apply Now</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Force Temporarily</string> <string>Force Temporarily</string>
@ -858,7 +706,58 @@
</item> </item>
</widget> </widget>
</item> </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"> <widget class="KComboBox" name="placement">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -915,85 +814,7 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="23" column="1"> <item row="28" column="3" rowspan="4" colspan="2">
<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">
<widget class="KRestrictedLine" name="maxsize"> <widget class="KRestrictedLine" name="maxsize">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -1006,29 +827,113 @@ to unconditionally popup in the middle of your screen.</string>
</property> </property>
</widget> </widget>
</item> </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"> <widget class="YesNoBox" name="strictgeometry" native="true">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="33" column="2"> <item row="2" column="1" rowspan="3" colspan="4">
<spacer> <widget class="Line" name="line_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType"> </widget>
<enum>QSizePolicy::Expanding</enum> </item>
<item row="12" column="0" rowspan="2">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>40</width>
<height>16</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </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"> <item row="5" column="2" rowspan="2">
<widget class="KComboBox" name="rule_maximizehoriz"> <widget class="KComboBox" name="rule_maximizehoriz">
<property name="enabled"> <property name="enabled">
@ -1103,8 +1008,127 @@ to unconditionally popup in the middle of your screen.</string>
</item> </item>
</widget> </widget>
</item> </item>
<item row="17" column="2" rowspan="2"> <item row="22" column="2" rowspan="2">
<widget class="KComboBox" name="rule_minimize"> <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"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -1140,49 +1164,28 @@ to unconditionally popup in the middle of your screen.</string>
</item> </item>
</widget> </widget>
</item> </item>
<item row="25" column="3" rowspan="2" colspan="4"> <item row="7" column="1">
<widget class="KRestrictedLine" name="minsize"> <widget class="QCheckBox" name="enable_maximizevert">
<property name="enabled"> <property name="text">
<bool>false</bool> <string>Maximized &amp;vertically</string>
</property>
<property name="placeholderText">
<string>width,height</string>
</property>
<property name="validChars">
<string>0123456789-+,xX:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="25" column="2" rowspan="2"> <item row="13" column="1">
<widget class="KComboBox" name="rule_minsize"> <widget class="QCheckBox" name="enable_desktop">
<property name="enabled"> <property name="text">
<bool>false</bool> <string>&amp;Desktop</string>
</property> </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> </widget>
</item> </item>
<item row="25" column="1" rowspan="2"> <item row="26" column="1" rowspan="2">
<widget class="QCheckBox" name="enable_minsize"> <widget class="QCheckBox" name="enable_minsize">
<property name="text"> <property name="text">
<string>M&amp;inimum size</string> <string>M&amp;inimum size</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="12" column="7" rowspan="2"> <item row="12" column="5" rowspan="2">
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1195,40 +1198,14 @@ to unconditionally popup in the middle of your screen.</string>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="12" column="0" rowspan="2"> <item row="8" column="1" rowspan="3" colspan="4">
<spacer name="horizontalSpacer_7"> <widget class="Line" name="line_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </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> </widget>
</item> </item>
<item row="31" column="2" rowspan="2"> <item row="32" column="2" rowspan="2">
<widget class="KComboBox" name="rule_strictgeometry"> <widget class="KComboBox" name="rule_strictgeometry">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -1250,6 +1227,80 @@ like your complete screen area.</string>
</item> </item>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
<widget class="QWidget" name="TabPage4"> <widget class="QWidget" name="TabPage4">

View file

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

View file

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

View file

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