Use signal/slots instead of deep function calls into decoration
For all the decoration updates called from Client into the decoration we also have a signal being emitted. So turning the pure virtual public functions into slots means we can just connect our existing signals and get rid off the deep function calls. The keepAbove/Below signals are changed to take a boolean argument as needed by KDecoration and a few emitted signals are moved to a better fitting location. REVIEW: 110335
This commit is contained in:
parent
5a32f8e813
commit
4022de7075
7 changed files with 59 additions and 55 deletions
|
@ -827,8 +827,6 @@ void Client::setActive(bool act)
|
|||
++it)
|
||||
if ((*it)->isFullScreen()) // fullscreens go high even if their transient is active
|
||||
workspace()->updateClientLayer(*it);
|
||||
if (decoration != NULL)
|
||||
decoration->activeChange();
|
||||
emit activeChanged();
|
||||
updateMouseGrab();
|
||||
updateUrgency(); // demand attention again if it's still urgent
|
||||
|
|
85
client.cpp
85
client.cpp
|
@ -427,35 +427,7 @@ void Client::updateDecoration(bool check_workspace_pos, bool force)
|
|||
if (force)
|
||||
destroyDecoration();
|
||||
if (!noBorder()) {
|
||||
setMask(QRegion()); // Reset shape mask
|
||||
if (decorationPlugin()->isDisabled()) {
|
||||
decoration = NULL;
|
||||
} else {
|
||||
decoration = decorationPlugin()->createDecoration(bridge);
|
||||
}
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
connect(this, SIGNAL(showRequest()), decoration, SIGNAL(showRequest()));
|
||||
connect(this, SIGNAL(appMenuAvailable()), decoration, SIGNAL(appMenuAvailable()));
|
||||
connect(this, SIGNAL(appMenuUnavailable()), decoration, SIGNAL(appMenuUnavailable()));
|
||||
connect(this, SIGNAL(menuHidden()), decoration, SIGNAL(menuHidden()));
|
||||
#endif
|
||||
// TODO: Check decoration's minimum size?
|
||||
decoration->init();
|
||||
decoration->widget()->installEventFilter(this);
|
||||
XReparentWindow(display(), decoration->widget()->winId(), frameId(), 0, 0);
|
||||
decoration->widget()->lower();
|
||||
decoration->borders(border_left, border_right, border_top, border_bottom);
|
||||
padding_left = padding_right = padding_top = padding_bottom = 0;
|
||||
if (KDecorationUnstable *deco2 = dynamic_cast<KDecorationUnstable*>(decoration))
|
||||
deco2->padding(padding_left, padding_right, padding_top, padding_bottom);
|
||||
XMoveWindow(display(), decoration->widget()->winId(), -padding_left, -padding_top);
|
||||
move(calculateGravitation(false));
|
||||
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
||||
if (Compositor::compositing()) {
|
||||
paintRedirector = PaintRedirector::create(this, decoration->widget());
|
||||
discardWindowPixmap();
|
||||
}
|
||||
emit geometryShapeChanged(this, oldgeom);
|
||||
createDecoration(oldgeom);
|
||||
} else
|
||||
destroyDecoration();
|
||||
if (check_workspace_pos)
|
||||
|
@ -467,6 +439,48 @@ void Client::updateDecoration(bool check_workspace_pos, bool force)
|
|||
updateFrameExtents();
|
||||
}
|
||||
|
||||
void Client::createDecoration(const QRect& oldgeom)
|
||||
{
|
||||
setMask(QRegion()); // Reset shape mask
|
||||
if (decorationPlugin()->isDisabled()) {
|
||||
decoration = NULL;
|
||||
return;
|
||||
} else {
|
||||
decoration = decorationPlugin()->createDecoration(bridge);
|
||||
}
|
||||
connect(this, SIGNAL(shadeChanged()), decoration, SLOT(shadeChange()));
|
||||
connect(this, SIGNAL(desktopChanged()), decoration, SLOT(desktopChange()));
|
||||
connect(this, SIGNAL(captionChanged()), decoration, SLOT(captionChange()));
|
||||
connect(this, SIGNAL(activeChanged()), decoration, SLOT(activeChange()));
|
||||
connect(this, SIGNAL(clientMaximizedStateChanged(KWin::Client*,KDecorationDefines::MaximizeMode)),
|
||||
decoration, SLOT(maximizeChange()));
|
||||
connect(this, SIGNAL(keepAboveChanged(bool)), decoration, SIGNAL(keepAboveChanged(bool)));
|
||||
connect(this, SIGNAL(keepBelowChanged(bool)), decoration, SIGNAL(keepBelowChanged(bool)));
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
connect(this, SIGNAL(showRequest()), decoration, SIGNAL(showRequest()));
|
||||
connect(this, SIGNAL(appMenuAvailable()), decoration, SIGNAL(appMenuAvailable()));
|
||||
connect(this, SIGNAL(appMenuUnavailable()), decoration, SIGNAL(appMenuUnavailable()));
|
||||
connect(this, SIGNAL(menuHidden()), decoration, SIGNAL(menuHidden()));
|
||||
#endif
|
||||
// TODO: Check decoration's minimum size?
|
||||
decoration->init();
|
||||
decoration->widget()->installEventFilter(this);
|
||||
XReparentWindow(display(), decoration->widget()->winId(), frameId(), 0, 0);
|
||||
decoration->widget()->lower();
|
||||
decoration->borders(border_left, border_right, border_top, border_bottom);
|
||||
padding_left = padding_right = padding_top = padding_bottom = 0;
|
||||
if (KDecorationUnstable *deco2 = dynamic_cast<KDecorationUnstable*>(decoration))
|
||||
deco2->padding(padding_left, padding_right, padding_top, padding_bottom);
|
||||
XMoveWindow(display(), decoration->widget()->winId(), -padding_left, -padding_top);
|
||||
move(calculateGravitation(false));
|
||||
plainResize(sizeForClientSize(clientSize()), ForceGeometrySet);
|
||||
if (Compositor::compositing()) {
|
||||
paintRedirector = PaintRedirector::create(this, decoration->widget());
|
||||
discardWindowPixmap();
|
||||
}
|
||||
emit geometryShapeChanged(this, oldgeom);
|
||||
}
|
||||
|
||||
void Client::destroyDecoration()
|
||||
{
|
||||
QRect oldgeom = geometry();
|
||||
|
@ -951,8 +965,8 @@ void Client::setShade(ShadeMode mode)
|
|||
tabGroup()->updateStates(this, TabGroup::Shaded);
|
||||
|
||||
if (was_shade == isShade()) {
|
||||
if (decoration != NULL) // Decoration may want to update after e.g. hover-shade changes
|
||||
decoration->shadeChange();
|
||||
// Decoration may want to update after e.g. hover-shade changes
|
||||
emit shadeChanged();
|
||||
return; // No real change in shaded state
|
||||
}
|
||||
|
||||
|
@ -1016,8 +1030,6 @@ void Client::setShade(ShadeMode mode)
|
|||
discardWindowPixmap();
|
||||
updateVisibility();
|
||||
updateAllowedActions();
|
||||
if (decoration)
|
||||
decoration->shadeChange();
|
||||
updateWindowRules(Rules::Shade);
|
||||
|
||||
emit shadeChanged();
|
||||
|
@ -1445,8 +1457,6 @@ void Client::setDesktop(int desktop)
|
|||
// onAllDesktops changed
|
||||
workspace()->updateOnAllDesktopsOfTransients(this);
|
||||
}
|
||||
if (decoration != NULL)
|
||||
decoration->desktopChange();
|
||||
|
||||
ClientList transients_stacking_order = workspace()->ensureStackingOrder(transients());
|
||||
for (ClientList::ConstIterator it = transients_stacking_order.constBegin();
|
||||
|
@ -1800,9 +1810,6 @@ void Client::setCaption(const QString& _s, bool force)
|
|||
// Keep the same suffix in iconic name if it's set
|
||||
info->setVisibleIconName(QString(cap_iconic + cap_suffix).toUtf8());
|
||||
|
||||
if (isManaged() && decoration) {
|
||||
decoration->captionChange();
|
||||
}
|
||||
emit captionChanged();
|
||||
}
|
||||
|
||||
|
@ -2067,8 +2074,6 @@ void Client::getIcons()
|
|||
bigicon_pix = KWindowSystem::icon(window(), 64, 64, false, KWindowSystem::ClassHint | KWindowSystem::XApp);
|
||||
hugeicon_pix = KWindowSystem::icon(window(), 128, 128, false, KWindowSystem::ClassHint | KWindowSystem::XApp);
|
||||
}
|
||||
if (isManaged() && decoration != NULL)
|
||||
decoration->iconChange();
|
||||
emit iconChanged();
|
||||
}
|
||||
|
||||
|
|
5
client.h
5
client.h
|
@ -725,8 +725,8 @@ signals:
|
|||
void transientChanged();
|
||||
void modalChanged();
|
||||
void shadeChanged();
|
||||
void keepAboveChanged();
|
||||
void keepBelowChanged();
|
||||
void keepAboveChanged(bool);
|
||||
void keepBelowChanged(bool);
|
||||
void minimizedChanged();
|
||||
void moveResizedChanged();
|
||||
void iconChanged();
|
||||
|
@ -801,6 +801,7 @@ private:
|
|||
void grabButton(int mod);
|
||||
void ungrabButton(int mod);
|
||||
void resizeDecoration(const QSize& s);
|
||||
void createDecoration(const QRect &oldgeom);
|
||||
|
||||
void pingWindow();
|
||||
void killProcess(bool ask, Time timestamp = CurrentTime);
|
||||
|
|
|
@ -517,7 +517,9 @@ void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, KDecorationDefines
|
|||
// default - nothing to do
|
||||
break;
|
||||
}
|
||||
emit windowMaximizedStateChanged(c->effectWindow(), horizontal, vertical);
|
||||
if (EffectWindowImpl *w = c->effectWindow()) {
|
||||
emit windowMaximizedStateChanged(w, horizontal, vertical);
|
||||
}
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::slotClientStartUserMovedResized(Client *c)
|
||||
|
|
|
@ -2096,8 +2096,6 @@ void Client::setMaximize(bool vertically, bool horizontally)
|
|||
max_mode & MaximizeVertical ? !vertically : vertically,
|
||||
max_mode & MaximizeHorizontal ? !horizontally : horizontally,
|
||||
false);
|
||||
emit clientMaximizedStateChanged(this, max_mode);
|
||||
emit clientMaximizedStateChanged(this, vertically, horizontally);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2334,8 +2332,8 @@ void Client::changeMaximize(bool vertical, bool horizontal, bool adjust)
|
|||
syncer.syncNow(); // important because of window rule updates!
|
||||
|
||||
updateAllowedActions();
|
||||
if (decoration != NULL)
|
||||
decoration->maximizeChange();
|
||||
emit clientMaximizedStateChanged(this, max_mode);
|
||||
emit clientMaximizedStateChanged(this, vertical, horizontal);
|
||||
updateWindowRules(Rules::MaximizeVert|Rules::MaximizeHoriz|Rules::Position|Rules::Size);
|
||||
}
|
||||
|
||||
|
|
|
@ -788,15 +788,13 @@ void Client::setKeepAbove(bool b)
|
|||
}
|
||||
keep_above = b;
|
||||
info->setState(keepAbove() ? NET::KeepAbove : 0, NET::KeepAbove);
|
||||
if (decoration != NULL)
|
||||
decoration->emitKeepAboveChanged(keepAbove());
|
||||
workspace()->updateClientLayer(this);
|
||||
updateWindowRules(Rules::Above);
|
||||
|
||||
// Update states of all other windows in this group
|
||||
if (tabGroup())
|
||||
tabGroup()->updateStates(this, TabGroup::Layer);
|
||||
emit keepAboveChanged();
|
||||
emit keepAboveChanged(keep_above);
|
||||
}
|
||||
|
||||
void Client::setKeepBelow(bool b)
|
||||
|
@ -812,15 +810,13 @@ void Client::setKeepBelow(bool b)
|
|||
}
|
||||
keep_below = b;
|
||||
info->setState(keepBelow() ? NET::KeepBelow : 0, NET::KeepBelow);
|
||||
if (decoration != NULL)
|
||||
decoration->emitKeepBelowChanged(keepBelow());
|
||||
workspace()->updateClientLayer(this);
|
||||
updateWindowRules(Rules::Below);
|
||||
|
||||
// Update states of all other windows in this group
|
||||
if (tabGroup())
|
||||
tabGroup()->updateStates(this, TabGroup::Layer);
|
||||
emit keepBelowChanged();
|
||||
emit keepBelowChanged(keep_below);
|
||||
}
|
||||
|
||||
Layer Client::layer() const
|
||||
|
|
|
@ -803,6 +803,8 @@ public:
|
|||
* used to keep the decorated window at least as large.
|
||||
*/
|
||||
virtual QSize minimumSize() const = 0;
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* This function is called whenever the window either becomes or stops being active.
|
||||
* Use isActive() to find out the current state.
|
||||
|
@ -1023,10 +1025,12 @@ public Q_SLOTS:
|
|||
void setKeepBelow(bool set);
|
||||
/**
|
||||
* @internal
|
||||
* TODO KF5: remove me
|
||||
*/
|
||||
void emitKeepAboveChanged(bool above);
|
||||
/**
|
||||
* @internal
|
||||
* TODO KF5: remove me
|
||||
*/
|
||||
void emitKeepBelowChanged(bool below);
|
||||
|
||||
|
|
Loading…
Reference in a new issue