[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin] /: Implement the shortcut caption suffix for Wayland windows
From:       Martin_Flöser <null () kde ! org>
Date:       2017-08-12 9:33:15
Message-ID: E1dgSnD-0007Rn-V0 () code ! kde ! org
[Download RAW message or body]

Git commit bbca8c6677feb5dc4ad91bd296ce5a7e5a4d36f2 by Martin Flöser.
Committed on 12/08/2017 at 09:31.
Pushed by graesslin into branch 'master'.

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

M  +8    -0    abstract_client.cpp
M  +2    -0    abstract_client.h
M  +0    -1    autotests/integration/globalshortcuts_test.cpp
M  +1    -1    client.cpp
M  +1    -1    client.h
M  +14   -2    shell_client.cpp
M  +2    -0    shell_client.h
M  +1    -0    useractions.cpp

https://commits.kde.org/kwin/bbca8c6677feb5dc4ad91bd296ce5a7e5a4d36f2

diff --git a/abstract_client.cpp b/abstract_client.cpp
index e3c488127..17e88ccdd 100644
--- a/abstract_client.cpp
+++ b/abstract_client.cpp
@@ -1750,4 +1750,12 @@ void AbstractClient::setUnresponsive(bool unresponsive)
     }
 }
 
+QString AbstractClient::shortcutCaptionSuffix() const
+{
+    if (shortcut().isEmpty()) {
+        return QString();
+    }
+    return QLatin1String(" {") + shortcut().toString() + QLatin1Char('}');
+}
+
 }
diff --git a/abstract_client.h b/abstract_client.h
index 10e359b50..a2fc9ad0d 100644
--- a/abstract_client.h
+++ b/abstract_client.h
@@ -983,6 +983,8 @@ protected:
     void setUnresponsive(bool unresponsive);
 
     virtual void setShortcutInternal();
+    QString shortcutCaptionSuffix() const;
+    virtual void updateCaption() = 0;
 
 private:
     void handlePaletteChange();
diff --git a/autotests/integration/globalshortcuts_test.cpp \
b/autotests/integration/globalshortcuts_test.cpp index 0c1893bc1..14a924a85 100644
--- a/autotests/integration/globalshortcuts_test.cpp
+++ b/autotests/integration/globalshortcuts_test.cpp
@@ -292,7 +292,6 @@ void GlobalShortcutsTest::testWaylandClientShortcut()
     client->setShortcut(seq.toString());
     QCOMPARE(client->shortcut(), seq);
     QVERIFY(!workspace()->shortcutAvailable(seq));
-    QEXPECT_FAIL("", "Caption adjustment not yet implemented", Continue);
     QCOMPARE(client->caption(), QStringLiteral(" {Meta+Shift+Y}"));
 
     workspace()->activateClient(nullptr);
diff --git a/client.cpp b/client.cpp
index 19ddb9679..1187b8bb8 100644
--- a/client.cpp
+++ b/client.cpp
@@ -1442,7 +1442,7 @@ void Client::setCaption(const QString& _s, bool force)
         if (clientMachine()->hostName() != ClientMachine::localhost() && \
                !clientMachine()->isLocal())
             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;
     auto fetchNameInternalPredicate = [this](const Client *cl) {
         return (!cl->isSpecialWindow() || cl->isToolbar()) &&
diff --git a/client.h b/client.h
index 076b3c0c7..b77c8cdf8 100644
--- a/client.h
+++ b/client.h
@@ -339,7 +339,7 @@ public:
 
 public Q_SLOTS:
     void closeWindow() override;
-    void updateCaption();
+    void updateCaption() override;
     void evaluateWindowRules();
 
 private Q_SLOTS:
diff --git a/shell_client.cpp b/shell_client.cpp
index 58ba2165f..82e6bb875 100644
--- a/shell_client.cpp
+++ b/shell_client.cpp
@@ -556,8 +556,20 @@ void ShellClient::blockActivityUpdates(bool b)
 
 QString ShellClient::caption(bool full) const
 {
-    Q_UNUSED(full)
-    return m_caption;
+    QString caption = 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()
diff --git a/shell_client.h b/shell_client.h
index f4fc85231..1328ad747 100644
--- a/shell_client.h
+++ b/shell_client.h
@@ -163,6 +163,7 @@ protected:
     bool acceptsFocus() const override;
     void doMinimize() override;
     void doMove(int x, int y) override;
+    void updateCaption() override;
 
 private Q_SLOTS:
     void clientFullScreenChanged(bool fullScreen);
@@ -236,6 +237,7 @@ private:
     int m_requestGeometryBlockCounter = 0;
     QRect m_blockedRequestGeometry;
     QString m_caption;
+    QString m_captionSuffix;
 
     bool m_compositingSetup = false;
 };
diff --git a/useractions.cpp b/useractions.cpp
index 62052baa3..91bb925cb 100644
--- a/useractions.cpp
+++ b/useractions.cpp
@@ -1826,6 +1826,7 @@ void AbstractClient::setShortcut(const QString& _cut)
 
 void AbstractClient::setShortcutInternal()
 {
+    updateCaption();
     workspace()->clientShortcutUpdated(this);
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic