Hide the OnAllDesktops button if there is only one virtual desktop
In KCommonDecoration the OnAllDesktops button gets hidden or shown depending on the number of desktops. For that KDecoration is extended by a new property which delegates to the bridge to return whether onAllDesktops is available. In KWin Core this is implemented using the number of desktops. FEATURE: 321611 FIXED-IN: 5.0.0 REVIEW: 116076
This commit is contained in:
parent
a60d10bedd
commit
aee20b4a5a
10 changed files with 57 additions and 2 deletions
|
@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kconfiggroup.h>
|
||||
#include "composite.h"
|
||||
#include "paintredirector.h"
|
||||
#include "virtualdesktops.h"
|
||||
#include "workspace.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
@ -363,6 +364,11 @@ void Bridge::closeTabGroup()
|
|||
|
||||
//END TABBING
|
||||
|
||||
bool Bridge::isOnAllDesktopsAvailable() const
|
||||
{
|
||||
return VirtualDesktopManager::self()->count() > 1;
|
||||
}
|
||||
|
||||
KDecoration::WindowOperation Bridge::buttonToWindowOperation(Qt::MouseButtons button)
|
||||
{
|
||||
return c->mouseButtonToWindowOperation(button);
|
||||
|
|
1
bridge.h
1
bridge.h
|
@ -40,6 +40,7 @@ public:
|
|||
virtual bool isMinimizable() const override;
|
||||
virtual bool providesContextHelp() const override;
|
||||
virtual int desktop() const override;
|
||||
bool isOnAllDesktopsAvailable() const override;
|
||||
virtual bool isModal() const override;
|
||||
virtual bool isShadeable() const override;
|
||||
virtual bool isShade() const override;
|
||||
|
|
|
@ -213,6 +213,12 @@ Client::Client()
|
|||
connect(clientMachine(), SIGNAL(localhostChanged()), SLOT(updateCaption()));
|
||||
connect(options, SIGNAL(condensedTitleChanged()), SLOT(updateCaption()));
|
||||
|
||||
m_connections << connect(VirtualDesktopManager::self(), &VirtualDesktopManager::countChanged, [this]() {
|
||||
if (decoration) {
|
||||
decoration->onAllDesktopsAvailableChanged();
|
||||
}
|
||||
});
|
||||
|
||||
// SELI TODO: Initialize xsizehints??
|
||||
}
|
||||
|
||||
|
@ -236,6 +242,9 @@ Client::~Client()
|
|||
assert(block_geometry_updates == 0);
|
||||
assert(!check_active_modal);
|
||||
delete bridge;
|
||||
for (auto it = m_connections.constBegin(); it != m_connections.constEnd(); ++it) {
|
||||
disconnect(*it);
|
||||
}
|
||||
}
|
||||
|
||||
// Use destroyClient() or releaseWindow(), Client instances cannot be deleted directly
|
||||
|
|
1
client.h
1
client.h
|
@ -1004,6 +1004,7 @@ private:
|
|||
QTimer *m_focusOutTimer;
|
||||
|
||||
QPalette m_palette;
|
||||
QList<QMetaObject::Connection> m_connections;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -313,6 +313,11 @@ int KDecorationPreviewBridge::desktop() const
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool KDecorationPreviewBridge::isOnAllDesktopsAvailable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KDecorationPreviewBridge::isModal() const
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -109,6 +109,7 @@ public:
|
|||
virtual bool isMinimizable() const override;
|
||||
virtual bool providesContextHelp() const override;
|
||||
virtual int desktop() const override;
|
||||
bool isOnAllDesktopsAvailable() const override;
|
||||
virtual bool isModal() const override;
|
||||
virtual bool isShadeable() const override;
|
||||
virtual bool isShade() const override;
|
||||
|
|
|
@ -93,6 +93,12 @@ KCommonDecoration::KCommonDecoration(KDecorationBridge* bridge, KDecorationFacto
|
|||
connect(d->wrapper, &KDecoration::shadeChanged, this, &KCommonDecoration::shadeChange);
|
||||
connect(d->wrapper, &KDecoration::iconChanged, this, &KCommonDecoration::iconChange);
|
||||
connect(d->wrapper, &KDecoration::maximizeChanged, this, &KCommonDecoration::maximizeChange);
|
||||
connect(d->wrapper, &KDecoration::onAllDesktopsAvailableChanged, [this]() {
|
||||
if (d->button[OnAllDesktopsButton]) {
|
||||
d->button[OnAllDesktopsButton]->setVisible(d->wrapper->isOnAllDesktopsAvailable());
|
||||
updateLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
KCommonDecoration::~KCommonDecoration()
|
||||
|
@ -564,6 +570,8 @@ void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QList<De
|
|||
// will be shown later on window registration
|
||||
if (btn->type() == AppMenuButton && !isPreview() && !d->wrapper->menuAvailable()) {
|
||||
btn->hide();
|
||||
} else if (btn->type() == OnAllDesktopsButton && !isPreview() && !d->wrapper->isOnAllDesktopsAvailable()) {
|
||||
btn->hide();
|
||||
} else {
|
||||
btn->show();
|
||||
}
|
||||
|
@ -607,8 +615,11 @@ void KCommonDecoration::calcHiddenButtons()
|
|||
if (! btnArray[i]->isHidden())
|
||||
break; // all buttons shown...
|
||||
|
||||
if (btnArray[i]->type() != AppMenuButton || d->wrapper->menuAvailable())
|
||||
btnArray[i]->show();
|
||||
if (btnArray[i]->type() == AppMenuButton && !d->wrapper->menuAvailable())
|
||||
continue;
|
||||
if (btnArray[i]->type() == OnAllDesktopsButton && !d->wrapper->isOnAllDesktopsAvailable())
|
||||
continue;
|
||||
btnArray[i]->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -583,6 +583,11 @@ bool KDecoration::isOnAllDesktops() const
|
|||
return desktop() == NET::OnAllDesktops;
|
||||
}
|
||||
|
||||
bool KDecoration::isOnAllDesktopsAvailable() const
|
||||
{
|
||||
return d->bridge->isOnAllDesktopsAvailable();
|
||||
}
|
||||
|
||||
int KDecoration::width() const
|
||||
{
|
||||
return geometry().width();
|
||||
|
|
|
@ -550,6 +550,7 @@ class KDECORATIONS_EXPORT KDecoration
|
|||
Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizeChanged)
|
||||
Q_PROPERTY(bool keepAbove READ keepAbove WRITE setKeepAbove NOTIFY keepAboveChanged)
|
||||
Q_PROPERTY(bool keepBelow READ keepBelow WRITE setKeepBelow NOTIFY keepBelowChanged)
|
||||
Q_PROPERTY(bool onAllDesktopsAvailable READ isOnAllDesktopsAvailable NOTIFY onAllDesktopsAvailableChanged)
|
||||
public:
|
||||
/**
|
||||
* Constructs a KDecoration object. Both the arguments are passed from
|
||||
|
@ -626,6 +627,12 @@ public:
|
|||
* virtual desktops.
|
||||
*/
|
||||
bool isOnAllDesktops() const; // convenience
|
||||
/**
|
||||
* @returns @c true if the decorated window can be put on all desktops
|
||||
* @since 5.0
|
||||
* @see onAllDesktopsAvailableChanged()
|
||||
**/
|
||||
bool isOnAllDesktopsAvailable() const;
|
||||
/**
|
||||
* Returns @a true if the decoration window is modal (usually a modal dialog).
|
||||
*/
|
||||
|
@ -997,6 +1004,14 @@ Q_SIGNALS:
|
|||
* @since 4.10
|
||||
**/
|
||||
void alphaEnabledChanged(bool enabled);
|
||||
/**
|
||||
* This signal is emitted whenever the decorated window can be put on all desktops or no
|
||||
* longer be put on all desktops.
|
||||
*
|
||||
* @see isOnAllDesktopsAvailable()
|
||||
* @since 5.0
|
||||
**/
|
||||
void onAllDesktopsAvailableChanged();
|
||||
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
virtual bool isMinimizable() const = 0;
|
||||
virtual bool providesContextHelp() const = 0;
|
||||
virtual int desktop() const = 0;
|
||||
virtual bool isOnAllDesktopsAvailable() const = 0;
|
||||
virtual bool isModal() const = 0;
|
||||
virtual bool isShadeable() const = 0;
|
||||
virtual bool isShade() const = 0;
|
||||
|
|
Loading…
Reference in a new issue