selective rule remembering

REVIEW: 103875
icc-effect-5.14.5
Thomas Lübking 2012-02-05 18:50:23 +01:00
parent 7c6155a865
commit 033ae96f89
7 changed files with 58 additions and 43 deletions

View File

@ -803,7 +803,7 @@ void Client::setNoBorder(bool set)
return;
noborder = set;
updateDecoration(true, false);
updateWindowRules();
updateWindowRules(Rules::NoBorder);
}
void Client::checkNoBorder()
@ -987,7 +987,7 @@ void Client::minimize(bool avoid_animation)
updateVisibility();
updateAllowedActions();
workspace()->updateMinimizedOfTransients(this);
updateWindowRules();
updateWindowRules(Rules::Minimize);
workspace()->updateFocusChains(this, Workspace::FocusChainMakeLast);
// TODO: merge signal with s_minimized
emit clientMinimized(this, !avoid_animation);
@ -1015,7 +1015,7 @@ void Client::unminimize(bool avoid_animation)
updateVisibility();
updateAllowedActions();
workspace()->updateMinimizedOfTransients(this);
updateWindowRules();
updateWindowRules(Rules::Minimize);
emit clientUnminimized(this, !avoid_animation);
// Update states of all other windows in this group
@ -1120,7 +1120,7 @@ void Client::setShade(ShadeMode mode)
updateAllowedActions();
if (decoration)
decoration->shadeChange();
updateWindowRules();
updateWindowRules(Rules::Shade);
// Update states of all other windows in this group
if (clientGroup())
@ -1508,7 +1508,7 @@ void Client::setSkipTaskbar(bool b, bool from_outside)
return;
skip_taskbar = b;
info->setState(b ? NET::SkipTaskbar : 0, NET::SkipTaskbar);
updateWindowRules();
updateWindowRules(Rules::SkipTaskbar);
if (was_wants_tab_focus != wantsTabFocus())
workspace()->updateFocusChains(this,
isActive() ? Workspace::FocusChainMakeFirst : Workspace::FocusChainUpdate);
@ -1521,7 +1521,7 @@ void Client::setSkipPager(bool b)
return;
skip_pager = b;
info->setState(b ? NET::SkipPager : 0, NET::SkipPager);
updateWindowRules();
updateWindowRules(Rules::SkipPager);
}
void Client::setSkipSwitcher(bool set)
@ -1530,7 +1530,7 @@ void Client::setSkipSwitcher(bool set)
if (set == skipSwitcher())
return;
skip_switcher = set;
updateWindowRules();
updateWindowRules(Rules::SkipSwitcher);
emit skipSwitcherChanged();
}
@ -1581,7 +1581,7 @@ void Client::setDesktop(int desktop)
workspace()->updateFocusChains(this, Workspace::FocusChainMakeFirst);
updateVisibility();
updateWindowRules();
updateWindowRules(Rules::Desktop);
// Update states of all other windows in this group
if (clientGroup())

View File

@ -267,7 +267,7 @@ public:
void removeRule(Rules* r);
void setupWindowRules(bool ignore_temporary);
void applyWindowRules();
void updateWindowRules();
void updateWindowRules(Rules::Types selection);
void updateFullscreenMonitors(NETFullscreenMonitors topology);
/**

View File

@ -1896,7 +1896,7 @@ void Client::setGeometry(int x, int y, int w, int h, ForceGeometry_t force)
}
// SELI TODO won't this be too expensive?
sendSyntheticConfigureNotify();
updateWindowRules();
updateWindowRules(Rules::Position|Rules::Size);
// keep track of old maximize mode
// to detect changes
@ -1973,7 +1973,7 @@ void Client::plainResize(int w, int h, ForceGeometry_t force)
updateShape();
sendSyntheticConfigureNotify();
updateWindowRules();
updateWindowRules(Rules::Position|Rules::Size);
workspace()->checkActiveScreen(this);
workspace()->updateStackingOrder();
workspace()->checkUnredirect();
@ -2018,7 +2018,7 @@ void Client::move(int x, int y, ForceGeometry_t force)
}
XMoveWindow(display(), frameId(), x, y);
sendSyntheticConfigureNotify();
updateWindowRules();
updateWindowRules(Rules::Position);
workspace()->checkActiveScreen(this);
workspace()->updateStackingOrder();
workspace()->checkUnredirect();
@ -2282,7 +2282,7 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
updateAllowedActions();
if (decoration != NULL)
decoration->maximizeChange();
updateWindowRules();
updateWindowRules(Rules::MaximizeVert|Rules::MaximizeHoriz|Rules::Position|Rules::Size);
}
void Client::resetMaximize()
@ -2370,7 +2370,7 @@ void Client::setFullScreen(bool set, bool user)
setGeometry(workspace()->clientArea(MaximizeArea, this));
}
}
updateWindowRules();
updateWindowRules(Rules::Fullscreen|Rules::Position|Rules::Size);
workspace()->checkUnredirect();
if (was_fs != isFullScreen()) {

View File

@ -779,7 +779,7 @@ void Client::setKeepAbove(bool b)
if (decoration != NULL)
decoration->emitKeepAboveChanged(keepAbove());
workspace()->updateClientLayer(this);
updateWindowRules();
updateWindowRules(Rules::Above);
// Update states of all other windows in this group
if (clientGroup())
@ -803,7 +803,7 @@ void Client::setKeepBelow(bool b)
if (decoration != NULL)
decoration->emitKeepBelowChanged(keepBelow());
workspace()->updateClientLayer(this);
updateWindowRules();
updateWindowRules(Rules::Below);
// Update states of all other windows in this group
if (clientGroup())

View File

@ -593,7 +593,7 @@ bool Client::manage(Window w, bool isMapped)
client_rules.discardTemporary();
applyWindowRules(); // Just in case
workspace()->discardUsedWindowRules(this, false); // Remove ApplyNow rules
updateWindowRules(); // Was blocked while !isManaged()
updateWindowRules(Rules::All); // Was blocked while !isManaged()
updateCompositeBlocking(true);

View File

@ -425,11 +425,13 @@ bool Rules::match(const Client* c) const
return true;
}
bool Rules::update(Client* c)
#define NOW_REMEMBER(_T_, _V_) ((selection & _T_) && (_V_##rule == (SetRule)Remember))
bool Rules::update(Client* c, int selection)
{
// TODO check this setting is for this client ?
bool updated = false;
if (positionrule == (SetRule)Remember) {
if NOW_REMEMBER(Position, position) {
if (!c->isFullScreen()) {
QPoint new_pos = position;
// don't use the position in the direction which is maximized
@ -441,7 +443,7 @@ bool Rules::update(Client* c)
position = new_pos;
}
}
if (sizerule == (SetRule)Remember) {
if NOW_REMEMBER(Size, size) {
if (!c->isFullScreen()) {
QSize new_size = size;
// don't use the position in the direction which is maximized
@ -453,63 +455,65 @@ bool Rules::update(Client* c)
size = new_size;
}
}
if (desktoprule == (SetRule)Remember) {
if NOW_REMEMBER(Desktop, desktop) {
updated = updated || desktop != c->desktop();
desktop = c->desktop();
}
if (maximizevertrule == (SetRule)Remember) {
if NOW_REMEMBER(MaximizeVert, maximizevert) {
updated = updated || maximizevert != bool(c->maximizeMode() & MaximizeVertical);
maximizevert = c->maximizeMode() & MaximizeVertical;
}
if (maximizehorizrule == (SetRule)Remember) {
if NOW_REMEMBER(MaximizeHoriz, maximizehoriz) {
updated = updated || maximizehoriz != bool(c->maximizeMode() & MaximizeHorizontal);
maximizehoriz = c->maximizeMode() & MaximizeHorizontal;
}
if (minimizerule == (SetRule)Remember) {
if NOW_REMEMBER(Minimize, minimize) {
updated = updated || minimize != c->isMinimized();
minimize = c->isMinimized();
}
if (shaderule == (SetRule)Remember) {
if NOW_REMEMBER(Shade, shade) {
updated = updated || (shade != (c->shadeMode() != ShadeNone));
shade = c->shadeMode() != ShadeNone;
}
if (skiptaskbarrule == (SetRule)Remember) {
if NOW_REMEMBER(SkipTaskbar, skiptaskbar) {
updated = updated || skiptaskbar != c->skipTaskbar();
skiptaskbar = c->skipTaskbar();
}
if (skippagerrule == (SetRule)Remember) {
if NOW_REMEMBER(SkipPager, skippager) {
updated = updated || skippager != c->skipPager();
skippager = c->skipPager();
}
if (skipswitcherrule == (SetRule)Remember) {
if NOW_REMEMBER(SkipSwitcher, skipswitcher) {
updated = updated || skipswitcher != c->skipSwitcher();
skipswitcher = c->skipSwitcher();
}
if (aboverule == (SetRule)Remember) {
if NOW_REMEMBER(Above, above) {
updated = updated || above != c->keepAbove();
above = c->keepAbove();
}
if (belowrule == (SetRule)Remember) {
if NOW_REMEMBER(Below, below) {
updated = updated || below != c->keepBelow();
below = c->keepBelow();
}
if (fullscreenrule == (SetRule)Remember) {
if NOW_REMEMBER(Fullscreen, fullscreen) {
updated = updated || fullscreen != c->isFullScreen();
fullscreen = c->isFullScreen();
}
if (noborderrule == (SetRule)Remember) {
if NOW_REMEMBER(NoBorder, noborder) {
updated = updated || noborder != c->noBorder();
noborder = c->noBorder();
}
if (opacityactiverule == (ForceRule)Force) {
if NOW_REMEMBER(OpacityActive, opacityactive) {
// TODO
}
if (opacityinactiverule == (ForceRule)Force) {
if NOW_REMEMBER(OpacityInactive, opacityinactive) {
// TODO
}
return updated;
}
#undef NOW_REMEMBER
#define APPLY_RULE( var, name, type ) \
bool Rules::apply##name( type& arg, bool init ) const \
{ \
@ -711,13 +715,13 @@ void WindowRules::discardTemporary()
rules.erase(it2, rules.end());
}
void WindowRules::update(Client* c)
void WindowRules::update(Client* c, int selection)
{
bool updated = false;
for (QVector< Rules* >::ConstIterator it = rules.constBegin();
it != rules.constEnd();
++it)
if ((*it)->update(c)) // no short-circuiting here
if ((*it)->update(c, selection)) // no short-circuiting here
updated = true;
if (updated)
Workspace::self()->rulesUpdated();
@ -870,18 +874,18 @@ void Client::applyWindowRules()
setOpacity(rules()->checkOpacityInactive(qRound(opacity() * 100.0)) / 100.0);
}
void Client::updateWindowRules()
void Client::updateWindowRules(Rules::Types selection)
{
if (!isManaged()) // not fully setup yet
return;
if (workspace()->rulesUpdatesDisabled())
return;
client_rules.update(this);
client_rules.update(this, selection);
}
void Client::finishWindowRules()
{
updateWindowRules();
updateWindowRules(Rules::All);
client_rules = WindowRules();
}
@ -1025,9 +1029,10 @@ void Workspace::rulesUpdated()
void Workspace::disableRulesUpdates(bool disable)
{
rules_updates_disabled = disable;
if (!disable)
if (!disable) {
foreach (Client * c, clients)
c->updateWindowRules();
c->updateWindowRules(Rules::All);
}
}
#endif

14
rules.h
View File

@ -48,7 +48,7 @@ class WindowRules
public:
WindowRules(const QVector< Rules* >& rules);
WindowRules();
void update(Client*);
void update(Client*, int selection);
void discardTemporary();
bool contains(const Rules* rule) const;
void remove(Rules* rule);
@ -100,12 +100,20 @@ public:
Rules();
Rules(const KConfigGroup&);
Rules(const QString&, bool temporary);
enum Type {
Position = 1<<0, Size = 1<<1, Desktop = 1<<2,
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
};
Q_DECLARE_FLAGS(Types, Type)
void write(KConfigGroup&) const;
bool isEmpty() const;
#ifndef KCMRULES
void discardUsed(bool withdrawn);
bool match(const Client* c) const;
bool update(Client*);
bool update(Client*, int selection);
bool isTemporary() const;
bool discardTemporary(bool force); // removes if temporary and forced or too old
bool applyPlacement(Placement::Policy& placement) const;
@ -326,4 +334,6 @@ QDebug& operator<<(QDebug& stream, const Rules*);
} // namespace
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::Rules::Types)
#endif