Commit bbca8c66 authored by Martin Flöser's avatar Martin Flöser

Implement the shortcut caption suffix for Wayland windows

Summary:
The generation of the shortcut caption part is moved from Client to
AbstractClient. The ShellClient also has a captionSuffix and implements
the full part in caption.

Overall this needs more refactoring to support more sharing between the
two implementations. But one step at a time.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7093
parent bbad15f6
...@@ -1750,4 +1750,12 @@ void AbstractClient::setUnresponsive(bool unresponsive) ...@@ -1750,4 +1750,12 @@ void AbstractClient::setUnresponsive(bool unresponsive)
} }
} }
QString AbstractClient::shortcutCaptionSuffix() const
{
if (shortcut().isEmpty()) {
return QString();
}
return QLatin1String(" {") + shortcut().toString() + QLatin1Char('}');
}
} }
...@@ -983,6 +983,8 @@ protected: ...@@ -983,6 +983,8 @@ protected:
void setUnresponsive(bool unresponsive); void setUnresponsive(bool unresponsive);
virtual void setShortcutInternal(); virtual void setShortcutInternal();
QString shortcutCaptionSuffix() const;
virtual void updateCaption() = 0;
private: private:
void handlePaletteChange(); void handlePaletteChange();
......
...@@ -292,7 +292,6 @@ void GlobalShortcutsTest::testWaylandClientShortcut() ...@@ -292,7 +292,6 @@ void GlobalShortcutsTest::testWaylandClientShortcut()
client->setShortcut(seq.toString()); client->setShortcut(seq.toString());
QCOMPARE(client->shortcut(), seq); QCOMPARE(client->shortcut(), seq);
QVERIFY(!workspace()->shortcutAvailable(seq)); QVERIFY(!workspace()->shortcutAvailable(seq));
QEXPECT_FAIL("", "Caption adjustment not yet implemented", Continue);
QCOMPARE(client->caption(), QStringLiteral(" {Meta+Shift+Y}")); QCOMPARE(client->caption(), QStringLiteral(" {Meta+Shift+Y}"));
workspace()->activateClient(nullptr); workspace()->activateClient(nullptr);
......
...@@ -1442,7 +1442,7 @@ void Client::setCaption(const QString& _s, bool force) ...@@ -1442,7 +1442,7 @@ void Client::setCaption(const QString& _s, bool force)
if (clientMachine()->hostName() != ClientMachine::localhost() && !clientMachine()->isLocal()) if (clientMachine()->hostName() != ClientMachine::localhost() && !clientMachine()->isLocal())
machine_suffix = QLatin1String(" <@") + QString::fromUtf8(clientMachine()->hostName()) + QLatin1Char('>') + LRM; machine_suffix = QLatin1String(" <@") + QString::fromUtf8(clientMachine()->hostName()) + QLatin1Char('>') + LRM;
} }
QString shortcut_suffix = !shortcut().isEmpty() ? (QLatin1String(" {") + shortcut().toString() + QLatin1Char('}')) : QString(); QString shortcut_suffix = shortcutCaptionSuffix();
cap_suffix = machine_suffix + shortcut_suffix; cap_suffix = machine_suffix + shortcut_suffix;
auto fetchNameInternalPredicate = [this](const Client *cl) { auto fetchNameInternalPredicate = [this](const Client *cl) {
return (!cl->isSpecialWindow() || cl->isToolbar()) && return (!cl->isSpecialWindow() || cl->isToolbar()) &&
......
...@@ -339,7 +339,7 @@ public: ...@@ -339,7 +339,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void closeWindow() override; void closeWindow() override;
void updateCaption(); void updateCaption() override;
void evaluateWindowRules(); void evaluateWindowRules();
private Q_SLOTS: private Q_SLOTS:
......
...@@ -556,8 +556,20 @@ void ShellClient::blockActivityUpdates(bool b) ...@@ -556,8 +556,20 @@ void ShellClient::blockActivityUpdates(bool b)
QString ShellClient::caption(bool full) const QString ShellClient::caption(bool full) const
{ {
Q_UNUSED(full) QString caption = m_caption;
return m_caption; if (full) {
caption += m_captionSuffix;
}
return caption;
}
void ShellClient::updateCaption()
{
const QString oldSuffix = m_captionSuffix;
m_captionSuffix = shortcutCaptionSuffix();
if (m_captionSuffix != oldSuffix) {
emit captionChanged();
}
} }
void ShellClient::closeWindow() void ShellClient::closeWindow()
......
...@@ -163,6 +163,7 @@ protected: ...@@ -163,6 +163,7 @@ protected:
bool acceptsFocus() const override; bool acceptsFocus() const override;
void doMinimize() override; void doMinimize() override;
void doMove(int x, int y) override; void doMove(int x, int y) override;
void updateCaption() override;
private Q_SLOTS: private Q_SLOTS:
void clientFullScreenChanged(bool fullScreen); void clientFullScreenChanged(bool fullScreen);
...@@ -236,6 +237,7 @@ private: ...@@ -236,6 +237,7 @@ private:
int m_requestGeometryBlockCounter = 0; int m_requestGeometryBlockCounter = 0;
QRect m_blockedRequestGeometry; QRect m_blockedRequestGeometry;
QString m_caption; QString m_caption;
QString m_captionSuffix;
bool m_compositingSetup = false; bool m_compositingSetup = false;
}; };
......
...@@ -1826,6 +1826,7 @@ void AbstractClient::setShortcut(const QString& _cut) ...@@ -1826,6 +1826,7 @@ void AbstractClient::setShortcut(const QString& _cut)
void AbstractClient::setShortcutInternal() void AbstractClient::setShortcutInternal()
{ {
updateCaption();
workspace()->clientShortcutUpdated(this); workspace()->clientShortcutUpdated(this);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment