panel & taskpanel: Fix panel colour on homescreen when shell windows are open

Fixes #161
This commit is contained in:
Devin Lin 2022-04-06 21:18:47 -04:00
parent c9422bc439
commit 3488d2b0f3
5 changed files with 53 additions and 6 deletions

View file

@ -104,13 +104,13 @@ void ApplicationListModel::windowCreated(KWayland::Client::PlasmaWindow *window)
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
(*i).window = window; (*i).window = window;
emit dataChanged(index(idx, 0), index(idx, 0)); Q_EMIT dataChanged(index(idx, 0), index(idx, 0));
connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window]() { connect(window, &KWayland::Client::PlasmaWindow::unmapped, this, [this, window]() {
int idx = 0; int idx = 0;
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) { for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) { if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
(*i).window = nullptr; (*i).window = nullptr;
emit dataChanged(index(idx, 0), index(idx, 0)); Q_EMIT dataChanged(index(idx, 0), index(idx, 0));
break; break;
} }
idx++; idx++;

View file

@ -40,6 +40,11 @@ bool WindowUtil::allWindowsMinimized() const
return m_allWindowsMinimized; return m_allWindowsMinimized;
} }
bool WindowUtil::allWindowsMinimizedExcludingShell() const
{
return m_allWindowsMinimizedExcludingShell;
}
bool WindowUtil::activeWindowIsShell() const bool WindowUtil::activeWindowIsShell() const
{ {
return m_activeWindowIsShell; return m_activeWindowIsShell;
@ -98,17 +103,28 @@ void WindowUtil::updateActiveWindow()
connect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow); connect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow);
} }
// loop through windows
bool newAllMinimized = true; bool newAllMinimized = true;
bool newAllMinimizedExcludingShell = true;
for (auto *w : m_windowManagement->windows()) { for (auto *w : m_windowManagement->windows()) {
if (!w->isMinimized() && !w->skipTaskbar() && !w->isFullscreen() /*&& w->appId() != QStringLiteral("org.kde.plasmashell")*/) { if (!w->isMinimized() && !w->skipTaskbar() && !w->isFullscreen()) {
newAllMinimized = false; newAllMinimized = false;
break;
if (w->appId() != QStringLiteral("org.kde.plasmashell")) {
newAllMinimizedExcludingShell = false;
} }
} }
}
if (newAllMinimized != m_allWindowsMinimized) { if (newAllMinimized != m_allWindowsMinimized) {
m_allWindowsMinimized = newAllMinimized; m_allWindowsMinimized = newAllMinimized;
Q_EMIT allWindowsMinimizedChanged(); Q_EMIT allWindowsMinimizedChanged();
} }
if (newAllMinimizedExcludingShell != m_allWindowsMinimizedExcludingShell) {
m_allWindowsMinimizedExcludingShell = newAllMinimizedExcludingShell;
Q_EMIT allWindowsMinimizedExcludingShellChanged();
}
// TODO: connect to closeableChanged, not needed right now as KWin doesn't provide this changeable // TODO: connect to closeableChanged, not needed right now as KWin doesn't provide this changeable
Q_EMIT hasCloseableActiveWindowChanged(); Q_EMIT hasCloseableActiveWindowChanged();
} }

View file

@ -23,6 +23,7 @@ class WindowUtil : public QObject
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged) Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged)
Q_PROPERTY(bool allWindowsMinimized READ allWindowsMinimized NOTIFY allWindowsMinimizedChanged) Q_PROPERTY(bool allWindowsMinimized READ allWindowsMinimized NOTIFY allWindowsMinimizedChanged)
Q_PROPERTY(bool allWindowsMinimizedExcludingShell READ allWindowsMinimizedExcludingShell NOTIFY allWindowsMinimizedExcludingShellChanged)
Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged) Q_PROPERTY(bool hasCloseableActiveWindow READ hasCloseableActiveWindow NOTIFY hasCloseableActiveWindowChanged)
Q_PROPERTY(bool activeWindowIsShell READ activeWindowIsShell NOTIFY activeWindowIsShellChanged) Q_PROPERTY(bool activeWindowIsShell READ activeWindowIsShell NOTIFY activeWindowIsShellChanged)
@ -30,18 +31,47 @@ public:
WindowUtil(QObject *parent = nullptr); WindowUtil(QObject *parent = nullptr);
static WindowUtil *instance(); static WindowUtil *instance();
/**
* Whether the shell is in "desktop showing" mode, where all windows
* are moved aside.
*/
bool isShowingDesktop() const; bool isShowingDesktop() const;
/**
* Whether all windows are minimized, including shell windows.
*/
bool allWindowsMinimized() const; bool allWindowsMinimized() const;
/**
* Whether all windows are minimized, ignoring shell windows.
*/
bool allWindowsMinimizedExcludingShell() const;
/**
* Whether the active window being shown is a shell window.
*/
bool activeWindowIsShell() const; bool activeWindowIsShell() const;
/**
* Whether the current active window can be closed.
*/
bool hasCloseableActiveWindow() const; bool hasCloseableActiveWindow() const;
/**
* Close the current active window.
*/
Q_INVOKABLE void closeActiveWindow(); Q_INVOKABLE void closeActiveWindow();
/**
* Toggle whether we are in the "desktop showing" mode.
*/
Q_INVOKABLE void requestShowingDesktop(bool showingDesktop); Q_INVOKABLE void requestShowingDesktop(bool showingDesktop);
Q_SIGNALS: Q_SIGNALS:
void windowCreated(KWayland::Client::PlasmaWindow *window); void windowCreated(KWayland::Client::PlasmaWindow *window);
void showingDesktopChanged(bool showingDesktop); void showingDesktopChanged(bool showingDesktop);
void allWindowsMinimizedChanged(); void allWindowsMinimizedChanged();
void allWindowsMinimizedExcludingShellChanged();
void hasCloseableActiveWindowChanged(); void hasCloseableActiveWindowChanged();
void activeWindowChanged(); void activeWindowChanged();
void activeWindowIsShellChanged(); void activeWindowIsShellChanged();
@ -61,5 +91,6 @@ private:
bool m_showingDesktop = false; bool m_showingDesktop = false;
bool m_allWindowsMinimized = true; bool m_allWindowsMinimized = true;
bool m_allWindowsMinimizedExcludingShell = true;
bool m_activeWindowIsShell = false; bool m_activeWindowIsShell = false;
}; };

View file

@ -23,7 +23,7 @@ import org.kde.notificationmanager 1.0 as NotificationManager
Item { Item {
id: root id: root
readonly property bool showingApp: !MobileShell.HomeScreenControls.homeScreenVisible readonly property bool showingApp: !MobileShell.WindowUtil.allWindowsMinimizedExcludingShell
readonly property color backgroundColor: topPanel.colorScopeColor readonly property color backgroundColor: topPanel.colorScopeColor
Plasmoid.backgroundHints: showingApp ? PlasmaCore.Types.StandardBackground : PlasmaCore.Types.NoBackground Plasmoid.backgroundHints: showingApp ? PlasmaCore.Types.StandardBackground : PlasmaCore.Types.NoBackground

View file

@ -16,7 +16,7 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell
MobileShell.NavigationPanel { MobileShell.NavigationPanel {
id: root id: root
property bool appIsShown: !MobileShell.WindowUtil.allWindowsMinimized property bool appIsShown: !MobileShell.WindowUtil.allWindowsMinimizedExcludingShell
// background is: // background is:
// - opaque if an app is shown or vkbd is shown // - opaque if an app is shown or vkbd is shown