add screen rule
This commit is contained in:
parent
24cf0e75f3
commit
850c1e6f0d
8 changed files with 623 additions and 477 deletions
|
@ -2607,7 +2607,6 @@ static ElectricBorder electricBorderFromMode(QuickTileMode mode)
|
|||
void Client::finishMoveResize(bool cancel)
|
||||
{
|
||||
const bool wasResize = isResize(); // store across leaveMoveResize
|
||||
const bool wasMove = isMove();
|
||||
leaveMoveResize();
|
||||
|
||||
if (cancel)
|
||||
|
@ -2623,8 +2622,12 @@ void Client::finishMoveResize(bool cancel)
|
|||
}
|
||||
setGeometry(moveResizeGeom);
|
||||
}
|
||||
if (screen() != moveResizeStartScreen && maximizeMode() != MaximizeRestore)
|
||||
checkWorkspacePosition();
|
||||
const int newScreen = screen();
|
||||
if (newScreen != moveResizeStartScreen) {
|
||||
workspace()->sendClientToScreen(this, newScreen); // checks rule validity
|
||||
if (maximizeMode() != MaximizeRestore)
|
||||
checkWorkspacePosition();
|
||||
}
|
||||
|
||||
if (isElectricBorderMaximizing()) {
|
||||
setQuickTileMode(electricMode);
|
||||
|
|
|
@ -85,6 +85,7 @@ RulesWidget::RulesWidget(QWidget* parent)
|
|||
SETUP(position, set);
|
||||
SETUP(size, set);
|
||||
SETUP(desktop, set);
|
||||
SETUP(screen, set);
|
||||
SETUP(activity, set);
|
||||
SETUP(maximizehoriz, set);
|
||||
SETUP(maximizevert, set);
|
||||
|
@ -152,6 +153,7 @@ RulesWidget::RulesWidget(QWidget* parent)
|
|||
UPDATE_ENABLE_SLOT(position)
|
||||
UPDATE_ENABLE_SLOT(size)
|
||||
UPDATE_ENABLE_SLOT(desktop)
|
||||
UPDATE_ENABLE_SLOT(screen)
|
||||
UPDATE_ENABLE_SLOT(activity)
|
||||
UPDATE_ENABLE_SLOT(maximizehoriz)
|
||||
UPDATE_ENABLE_SLOT(maximizevert)
|
||||
|
@ -403,6 +405,7 @@ static NET::WindowType comboToType(int val)
|
|||
#define CHECKBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setChecked, setChecked( false ))
|
||||
#define LINEEDIT_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setText, setText( "" ))
|
||||
#define COMBOBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setCurrentIndex, setCurrentIndex( 0 ))
|
||||
#define SPINBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, setValue, setValue(0))
|
||||
#define CHECKBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setChecked, setChecked( false ))
|
||||
#define LINEEDIT_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setText, setText( "" ))
|
||||
#define COMBOBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setCurrentIndex, setCurrentIndex( 0 ))
|
||||
|
@ -440,6 +443,7 @@ void RulesWidget::setRules(Rules* rules)
|
|||
LINEEDIT_SET_RULE(position, positionToStr);
|
||||
LINEEDIT_SET_RULE(size, sizeToStr);
|
||||
COMBOBOX_SET_RULE(desktop, desktopToCombo);
|
||||
SPINBOX_SET_RULE(screen, inc);
|
||||
COMBOBOX_SET_RULE(activity, activityToCombo);
|
||||
CHECKBOX_SET_RULE(maximizehoriz,);
|
||||
CHECKBOX_SET_RULE(maximizevert,);
|
||||
|
@ -475,6 +479,7 @@ void RulesWidget::setRules(Rules* rules)
|
|||
#undef CHECKBOX_SET_RULE
|
||||
#undef LINEEDIT_SET_RULE
|
||||
#undef COMBOBOX_SET_RULE
|
||||
#undef SPINBOX_SET_RULE
|
||||
#undef CHECKBOX_FORCE_RULE
|
||||
#undef LINEEDIT_FORCE_RULE
|
||||
#undef COMBOBOX_FORCE_RULE
|
||||
|
@ -492,6 +497,7 @@ void RulesWidget::setRules(Rules* rules)
|
|||
#define CHECKBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, isChecked )
|
||||
#define LINEEDIT_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, text )
|
||||
#define COMBOBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, currentIndex )
|
||||
#define SPINBOX_SET_RULE( var, func ) GENERIC_RULE( var, func, Set, set, value)
|
||||
#define CHECKBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, isChecked )
|
||||
#define LINEEDIT_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, text )
|
||||
#define COMBOBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, currentIndex )
|
||||
|
@ -534,6 +540,7 @@ Rules* RulesWidget::rules() const
|
|||
LINEEDIT_SET_RULE(position, strToPosition);
|
||||
LINEEDIT_SET_RULE(size, strToSize);
|
||||
COMBOBOX_SET_RULE(desktop, comboToDesktop);
|
||||
SPINBOX_SET_RULE(screen, dec);
|
||||
COMBOBOX_SET_RULE(activity, comboToActivity);
|
||||
CHECKBOX_SET_RULE(maximizehoriz,);
|
||||
CHECKBOX_SET_RULE(maximizevert,);
|
||||
|
@ -570,6 +577,7 @@ Rules* RulesWidget::rules() const
|
|||
#undef CHECKBOX_SET_RULE
|
||||
#undef LINEEDIT_SET_RULE
|
||||
#undef COMBOBOX_SET_RULE
|
||||
#undef SPINBOX_SET_RULE
|
||||
#undef CHECKBOX_FORCE_RULE
|
||||
#undef LINEEDIT_FORCE_RULE
|
||||
#undef COMBOBOX_FORCE_RULE
|
||||
|
|
|
@ -57,6 +57,7 @@ private slots:
|
|||
void updateEnableposition();
|
||||
void updateEnablesize();
|
||||
void updateEnabledesktop();
|
||||
void updateEnablescreen();
|
||||
void updateEnableactivity();
|
||||
void updateEnablemaximizehoriz();
|
||||
void updateEnablemaximizevert();
|
||||
|
@ -96,6 +97,8 @@ private:
|
|||
int activityToCombo(QString d) const;
|
||||
QString comboToActivity(int val) const;
|
||||
int comboToTiling(int val) const;
|
||||
int inc(int i) const { return i+1; }
|
||||
int dec(int i) const { return i-1; }
|
||||
void prefillUnusedValues(const KWindowInfo& info);
|
||||
DetectDialog* detect_dlg;
|
||||
bool detect_dlg_ok;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -232,6 +232,7 @@ bool Client::manage(Window w, bool isMapped)
|
|||
area = workspace()->clientArea(FullArea, geom.center(), desktop());
|
||||
else {
|
||||
int screen = asn_data.xinerama() == -1 ? workspace()->activeScreen() : asn_data.xinerama();
|
||||
screen = rules()->checkScreen(screen, !isMapped);
|
||||
area = workspace()->clientArea(PlacementArea, workspace()->screenGeometry(screen).center(), desktop());
|
||||
}
|
||||
|
||||
|
|
26
rules.cpp
26
rules.cpp
|
@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <ktoolinvocation.h>
|
||||
|
||||
#ifndef KCMRULES
|
||||
#include <QDesktopWidget>
|
||||
#include "client.h"
|
||||
#include "workspace.h"
|
||||
#endif
|
||||
|
@ -52,6 +53,7 @@ Rules::Rules()
|
|||
, opacityinactiverule(UnusedForceRule)
|
||||
, ignorepositionrule(UnusedForceRule)
|
||||
, desktoprule(UnusedSetRule)
|
||||
, screenrule(UnusedSetRule)
|
||||
, activityrule(UnusedSetRule)
|
||||
, typerule(UnusedForceRule)
|
||||
, maximizevertrule(UnusedSetRule)
|
||||
|
@ -157,6 +159,7 @@ void Rules::readFromCfg(const KConfigGroup& cfg)
|
|||
opacityinactive = 100;
|
||||
READ_FORCE_RULE(ignoreposition, , false);
|
||||
READ_SET_RULE(desktop, , 0);
|
||||
READ_SET_RULE(screen, , 0);
|
||||
READ_SET_RULE(activity, , QString());
|
||||
type = readType(cfg, "type");
|
||||
typerule = type != NET::Unknown ? readForceRule(cfg, "typerule") : UnusedForceRule;
|
||||
|
@ -246,6 +249,7 @@ void Rules::write(KConfigGroup& cfg) const
|
|||
WRITE_FORCE_RULE(opacityinactive,);
|
||||
WRITE_FORCE_RULE(ignoreposition,);
|
||||
WRITE_SET_RULE(desktop,);
|
||||
WRITE_SET_RULE(screen,);
|
||||
WRITE_SET_RULE(activity,);
|
||||
WRITE_FORCE_RULE(type, int);
|
||||
WRITE_SET_RULE(maximizevert,);
|
||||
|
@ -287,6 +291,7 @@ bool Rules::isEmpty() const
|
|||
&& opacityinactiverule == UnusedForceRule
|
||||
&& ignorepositionrule == UnusedForceRule
|
||||
&& desktoprule == UnusedSetRule
|
||||
&& screenrule == UnusedSetRule
|
||||
&& activityrule == UnusedSetRule
|
||||
&& typerule == UnusedForceRule
|
||||
&& maximizevertrule == UnusedSetRule
|
||||
|
@ -459,6 +464,10 @@ bool Rules::update(Client* c, int selection)
|
|||
updated = updated || desktop != c->desktop();
|
||||
desktop = c->desktop();
|
||||
}
|
||||
if NOW_REMEMBER(Screen, screen) {
|
||||
updated = updated || screen != c->screen();
|
||||
screen = c->screen();
|
||||
}
|
||||
if NOW_REMEMBER(Activity, activity) {
|
||||
// TODO: ivan - multiple activities support
|
||||
const QString & joinedActivities = c->activities().join(",");
|
||||
|
@ -581,6 +590,7 @@ bool Rules::applyIgnoreGeometry(bool& ignore) const
|
|||
}
|
||||
|
||||
APPLY_RULE(desktop, Desktop, int)
|
||||
APPLY_RULE(screen, Screen, int)
|
||||
APPLY_RULE(activity, Activity, QString)
|
||||
APPLY_FORCE_RULE(type, Type, NET::WindowType)
|
||||
|
||||
|
@ -671,6 +681,7 @@ void Rules::discardUsed(bool withdrawn)
|
|||
DISCARD_USED_FORCE_RULE(opacityinactive);
|
||||
DISCARD_USED_FORCE_RULE(ignoreposition);
|
||||
DISCARD_USED_SET_RULE(desktop);
|
||||
DISCARD_USED_SET_RULE(screen);
|
||||
DISCARD_USED_SET_RULE(activity);
|
||||
DISCARD_USED_FORCE_RULE(type);
|
||||
DISCARD_USED_SET_RULE(maximizevert);
|
||||
|
@ -798,6 +809,20 @@ KDecorationDefines::MaximizeMode WindowRules::checkMaximize(MaximizeMode mode, b
|
|||
return static_cast< MaximizeMode >((vert ? MaximizeVertical : 0) | (horiz ? MaximizeHorizontal : 0));
|
||||
}
|
||||
|
||||
int WindowRules::checkScreen(int screen, bool init) const
|
||||
{
|
||||
if ( rules.count() == 0 )
|
||||
return screen;
|
||||
int ret = screen;
|
||||
for ( QVector< Rules* >::ConstIterator it = rules.constBegin(); it != rules.constEnd(); ++it ) {
|
||||
if ( (*it)->applyScreen( ret, init ))
|
||||
break;
|
||||
}
|
||||
if (ret >= QApplication::desktop()->screenCount())
|
||||
ret = screen;
|
||||
return ret;
|
||||
}
|
||||
|
||||
CHECK_RULE(Minimize, bool)
|
||||
CHECK_RULE(Shade, ShadeMode)
|
||||
CHECK_RULE(SkipTaskbar, bool)
|
||||
|
@ -843,6 +868,7 @@ void Client::applyWindowRules()
|
|||
// MinSize, MaxSize handled by Geometry
|
||||
// IgnorePosition
|
||||
setDesktop(desktop());
|
||||
workspace()->sendClientToScreen(this, screen());
|
||||
setOnActivities(activities());
|
||||
// Type
|
||||
maximize(maximizeMode());
|
||||
|
|
6
rules.h
6
rules.h
|
@ -63,6 +63,7 @@ public:
|
|||
int checkOpacityInactive(int s) const;
|
||||
bool checkIgnoreGeometry(bool ignore) 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;
|
||||
NET::WindowType checkType(NET::WindowType type) const;
|
||||
MaximizeMode checkMaximize(MaximizeMode mode, bool init = false) const;
|
||||
|
@ -106,7 +107,7 @@ public:
|
|||
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,
|
||||
Activity = 1<<16, All = 0xffffffff
|
||||
Activity = 1<<16, Screen = 1<<17, All = 0xffffffff
|
||||
};
|
||||
Q_DECLARE_FLAGS(Types, Type)
|
||||
void write(KConfigGroup&) const;
|
||||
|
@ -128,6 +129,7 @@ public:
|
|||
bool applyOpacityInactive(int& s) const;
|
||||
bool applyIgnoreGeometry(bool& ignore) const;
|
||||
bool applyDesktop(int& desktop, bool init) const;
|
||||
bool applyScreen(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;
|
||||
|
@ -225,6 +227,8 @@ private:
|
|||
ForceRule ignorepositionrule;
|
||||
int desktop;
|
||||
SetRule desktoprule;
|
||||
int screen;
|
||||
SetRule screenrule;
|
||||
QString activity;
|
||||
SetRule activityrule;
|
||||
NET::WindowType type; // type for setting
|
||||
|
|
|
@ -1744,6 +1744,7 @@ int Workspace::screenNumber(const QPoint& pos) const
|
|||
|
||||
void Workspace::sendClientToScreen(Client* c, int screen)
|
||||
{
|
||||
screen = c->rules()->checkScreen(screen);
|
||||
if (c->screen() == screen) // Don't use isOnScreen(), that's true even when only partially
|
||||
return;
|
||||
GeometryUpdatesBlocker blocker(c);
|
||||
|
|
Loading…
Reference in a new issue