Move minimize implementation to AbstractClient

This commit is contained in:
Martin Gräßlin 2015-03-13 14:45:21 +01:00
parent d2884484bc
commit 38b418887a
7 changed files with 87 additions and 81 deletions

View file

@ -306,4 +306,53 @@ AbstractClient::Position AbstractClient::titlebarPosition() const
return PositionTop;
}
void AbstractClient::setMinimized(bool set)
{
set ? minimize() : unminimize();
}
void AbstractClient::minimize(bool avoid_animation)
{
if (!isMinimizable() || isMinimized())
return;
if (isShade() && info) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
info->setState(0, NET::Shaded);
m_minimized = true;
doMinimize();
updateWindowRules(Rules::Minimize);
FocusChain::self()->update(this, FocusChain::MakeFirstMinimized);
// TODO: merge signal with s_minimized
emit clientMinimized(this, !avoid_animation);
emit minimizedChanged();
}
void AbstractClient::unminimize(bool avoid_animation)
{
if (!isMinimized())
return;
if (rules()->checkMinimize(false)) {
return;
}
if (isShade() && info) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
info->setState(NET::Shaded, NET::Shaded);
m_minimized = false;
doMinimize();
updateWindowRules(Rules::Minimize);
emit clientUnminimized(this, !avoid_animation);
emit minimizedChanged();
}
void AbstractClient::doMinimize()
{
}
}

View file

@ -82,6 +82,15 @@ class AbstractClient : public Toplevel
* Whether the Client is shaded.
**/
Q_PROPERTY(bool shade READ isShade WRITE setShade NOTIFY shadeChanged)
/**
* Whether the Client can be minimized. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool minimizable READ isMinimizable)
/**
* Whether the Client is minimized.
**/
Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged)
/**
* Returns whether the window is any of special windows types (desktop, dock, splash, ...),
* i.e. window types that usually don't have a window frame and the user does not use window
@ -152,7 +161,6 @@ public:
virtual void updateMouseGrab();
virtual QString caption(bool full = true, bool stripped = false) const = 0;
virtual bool isMinimized() const = 0;
virtual bool isCloseable() const = 0;
// TODO: remove boolean trap
virtual bool isShown(bool shaded_is_shown) const = 0;
@ -176,8 +184,15 @@ public:
int desktop() const override {
return m_desktop;
}
virtual void minimize(bool avoid_animation = false) = 0;
virtual void unminimize(bool avoid_animation = false)= 0;
void setMinimized(bool set);
/**
* Minimizes this client plus its transients
*/
void minimize(bool avoid_animation = false);
void unminimize(bool avoid_animation = false);
bool isMinimized() const {
return m_minimized;
}
virtual void setFullScreen(bool set, bool user = true) = 0;
virtual TabGroup *tabGroup() const;
Q_INVOKABLE virtual bool untab(const QRect &toGeometry = QRect(), bool clientRemoved = false);
@ -284,6 +299,9 @@ Q_SIGNALS:
void desktopPresenceChanged(KWin::AbstractClient*, int); // to be forwarded by Workspace
void desktopChanged();
void shadeChanged();
void minimizedChanged();
void clientMinimized(KWin::AbstractClient* client, bool animate);
void clientUnminimized(KWin::AbstractClient* client, bool animate);
protected:
AbstractClient();
@ -323,6 +341,13 @@ protected:
* @param was_desk The desktop the Client was on before
**/
virtual void doSetDesktop(int desktop, int was_desk);
/**
* Called from ::minimize and ::unminimize once the minimized value got updated, but before the
* changed signal is emitted.
*
* Default implementation does nothig.
**/
virtual void doMinimize();
// TODO: remove boolean trap
virtual bool belongsToSameApplication(const AbstractClient *other, bool active_hack) const = 0;
@ -335,6 +360,7 @@ private:
bool m_keepAbove = false;
bool m_keepBelow = false;
bool m_demandsAttention = false;
bool m_minimized = false;
QTimer *m_autoRaiseTimer = nullptr;
int m_desktop = 0; // 0 means not on any desktop yet
};

View file

@ -159,7 +159,6 @@ Client::Client()
fullscreen_mode = FullScreenNone;
skip_taskbar = false;
original_skip_taskbar = false;
minimized = false;
hidden = false;
modal = false;
noborder = false;
@ -729,61 +728,14 @@ bool Client::isMinimizable() const
return true;
}
void Client::setMinimized(bool set)
void Client::doMinimize()
{
set ? minimize() : unminimize();
}
/**
* Minimizes this client plus its transients
*/
void Client::minimize(bool avoid_animation)
{
if (!isMinimizable() || isMinimized())
return;
if (isShade()) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
info->setState(0, NET::Shaded);
minimized = true;
updateVisibility();
updateAllowedActions();
workspace()->updateMinimizedOfTransients(this);
updateWindowRules(Rules::Minimize);
FocusChain::self()->update(this, FocusChain::MakeFirstMinimized);
// TODO: merge signal with s_minimized
emit clientMinimized(this, !avoid_animation);
// Update states of all other windows in this group
if (tabGroup())
tabGroup()->updateStates(this, TabGroup::Minimized);
emit minimizedChanged();
}
void Client::unminimize(bool avoid_animation)
{
if (!isMinimized())
return;
if (rules()->checkMinimize(false)) {
return;
}
if (isShade()) // NETWM restriction - KWindowInfo::isMinimized() == Hidden && !Shaded
info->setState(NET::Shaded, NET::Shaded);
minimized = false;
updateVisibility();
updateAllowedActions();
workspace()->updateMinimizedOfTransients(this);
updateWindowRules(Rules::Minimize);
emit clientUnminimized(this, !avoid_animation);
// Update states of all other windows in this group
if (tabGroup())
tabGroup()->updateStates(this, TabGroup::Minimized);
emit minimizedChanged();
}
QRect Client::iconGeometry() const
@ -945,7 +897,7 @@ void Client::updateVisibility()
}
if (isCurrentTab())
setSkipTaskbar(original_skip_taskbar, false); // Reset from 'hidden'
if (minimized) {
if (isMinimized()) {
info->setState(NET::Hidden, NET::Hidden);
if (compositing() && options->hiddenPreviews() == HiddenPreviewsAlways)
internalKeep();

View file

@ -103,15 +103,6 @@ class Client
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool maximizable READ isMaximizable)
/**
* Whether the Client can be minimized. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
**/
Q_PROPERTY(bool minimizable READ isMinimizable)
/**
* Whether the Client is minimized.
**/
Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged)
/**
* Whether the Client represents a modal window.
**/
@ -299,7 +290,6 @@ public:
void setShade(ShadeMode mode) override;
bool isShadeable() const override;
bool isMinimized() const override;
bool isMaximizable() const override;
QRect geometryRestore() const;
MaximizeMode maximizeMode() const override;
@ -434,9 +424,6 @@ public:
static bool belongToSameApplication(const Client* c1, const Client* c2, bool active_hack = false);
static bool sameAppWindowRoleMatch(const Client* c1, const Client* c2, bool active_hack);
void setMinimized(bool set);
void minimize(bool avoid_animation = false) override;
void unminimize(bool avoid_animation = false) override;
void killWindow();
void maximize(MaximizeMode) override;
void toggleShade();
@ -593,6 +580,7 @@ protected:
void doSetKeepAbove() override;
void doSetKeepBelow() override;
void doSetDesktop(int desktop, int was_desk) override;
void doMinimize() override;
private Q_SLOTS:
void delayedSetShortcut();
@ -607,8 +595,6 @@ Q_SIGNALS:
void clientFullScreenSet(KWin::Client*, bool, bool);
void clientMaximizedStateChanged(KWin::Client*, MaximizeMode);
void clientMaximizedStateChanged(KWin::Client* c, bool h, bool v);
void clientMinimized(KWin::Client* client, bool animate);
void clientUnminimized(KWin::Client* client, bool animate);
void clientStartUserMovedResized(KWin::Client*);
void clientStepUserMovedResized(KWin::Client *, const QRect&);
void clientFinishUserMovedResized(KWin::Client*);
@ -616,7 +602,6 @@ Q_SIGNALS:
void fullScreenChanged();
void transientChanged();
void modalChanged();
void minimizedChanged();
void moveResizedChanged();
void skipTaskbarChanged();
void skipPagerChanged();
@ -803,7 +788,6 @@ private:
uint original_skip_taskbar : 1; ///< Unaffected by KWin
uint skip_pager : 1;
Xcb::MotifHints m_motif;
uint minimized : 1;
uint hidden : 1; ///< Forcibly hidden by calling hide()
uint modal : 1; ///< NET::Modal
uint noborder : 1;
@ -961,11 +945,6 @@ inline TabGroup* Client::tabGroup() const
return tab_group;
}
inline bool Client::isMinimized() const
{
return minimized;
}
inline bool Client::isShown(bool shaded_is_shown) const
{
return !isMinimized() && (!isShade() || shaded_is_shown) && !hidden &&

View file

@ -354,7 +354,7 @@ void EffectsHandlerImpl::setupClientConnections(Client* c)
);
connect(c, &Client::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged);
connect(c, &Client::clientMinimized, this,
[this](Client *c, bool animate) {
[this](AbstractClient *c, bool animate) {
// TODO: notify effects even if it should not animate?
if (animate) {
emit windowMinimized(c->effectWindow());
@ -362,7 +362,7 @@ void EffectsHandlerImpl::setupClientConnections(Client* c)
}
);
connect(c, &Client::clientUnminimized, this,
[this](Client* c, bool animate) {
[this](AbstractClient* c, bool animate) {
// TODO: notify effects even if it should not animate?
if (animate) {
emit windowUnminimized(c->effectWindow());

View file

@ -244,8 +244,8 @@ QString WorkspaceWrapper::supportInformation() const
void WorkspaceWrapper::setupClientConnections(KWin::Client *client)
{
connect(client, SIGNAL(clientMinimized(KWin::Client*,bool)), SIGNAL(clientMinimized(KWin::Client*)));
connect(client, SIGNAL(clientUnminimized(KWin::Client*,bool)), SIGNAL(clientUnminimized(KWin::Client*)));
connect(client, &Client::clientMinimized, this, &WorkspaceWrapper::clientMinimized);
connect(client, &Client::clientUnminimized, this, &WorkspaceWrapper::clientUnminimized);
connect(client, SIGNAL(clientManaging(KWin::Client*)), SIGNAL(clientManaging(KWin::Client*)));
connect(client, SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)), SIGNAL(clientFullScreenSet(KWin::Client*,bool,bool)));
connect(client, SIGNAL(clientMaximizedStateChanged(KWin::Client*,bool,bool)), SIGNAL(clientMaximizeSet(KWin::Client*,bool,bool)));

View file

@ -93,8 +93,8 @@ Q_SIGNALS:
void clientAdded(KWin::Client *client);
void clientRemoved(KWin::Client *client);
void clientManaging(KWin::Client *client);
void clientMinimized(KWin::Client *client);
void clientUnminimized(KWin::Client *client);
void clientMinimized(KWin::AbstractClient *client);
void clientUnminimized(KWin::AbstractClient *client);
void clientRestored(KWin::Client *client);
void clientMaximizeSet(KWin::Client *client, bool h, bool v);
void killWindowCalled(KWin::Client *client);