Commit 3488d2b0 authored by Devin Lin's avatar Devin Lin 🎨
Browse files

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

Fixes #161
parent c9422bc4
Pipeline #160542 passed with stages
in 1 minute and 4 seconds
......@@ -104,13 +104,13 @@ void ApplicationListModel::windowCreated(KWayland::Client::PlasmaWindow *window)
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
(*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]() {
int idx = 0;
for (auto i = m_applicationList.begin(); i != m_applicationList.end(); i++) {
if ((*i).storageId == window->appId() + QStringLiteral(".desktop")) {
(*i).window = nullptr;
emit dataChanged(index(idx, 0), index(idx, 0));
Q_EMIT dataChanged(index(idx, 0), index(idx, 0));
break;
}
idx++;
......
......@@ -40,6 +40,11 @@ bool WindowUtil::allWindowsMinimized() const
return m_allWindowsMinimized;
}
bool WindowUtil::allWindowsMinimizedExcludingShell() const
{
return m_allWindowsMinimizedExcludingShell;
}
bool WindowUtil::activeWindowIsShell() const
{
return m_activeWindowIsShell;
......@@ -98,17 +103,28 @@ void WindowUtil::updateActiveWindow()
connect(m_activeWindow.data(), &PlasmaWindow::unmapped, this, &WindowUtil::forgetActiveWindow);
}
// loop through windows
bool newAllMinimized = true;
bool newAllMinimizedExcludingShell = true;
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;
break;
if (w->appId() != QStringLiteral("org.kde.plasmashell")) {
newAllMinimizedExcludingShell = false;
}
}
}
if (newAllMinimized != m_allWindowsMinimized) {
m_allWindowsMinimized = newAllMinimized;
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
Q_EMIT hasCloseableActiveWindowChanged();
}
......
......@@ -23,6 +23,7 @@ class WindowUtil : public QObject
Q_OBJECT
Q_PROPERTY(bool showDesktop READ isShowingDesktop WRITE requestShowingDesktop NOTIFY showingDesktopChanged)
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 activeWindowIsShell READ activeWindowIsShell NOTIFY activeWindowIsShellChanged)
......@@ -30,18 +31,47 @@ public:
WindowUtil(QObject *parent = nullptr);
static WindowUtil *instance();
/**
* Whether the shell is in "desktop showing" mode, where all windows
* are moved aside.
*/
bool isShowingDesktop() const;
/**
* Whether all windows are minimized, including shell windows.
*/
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;
/**
* Whether the current active window can be closed.
*/
bool hasCloseableActiveWindow() const;
/**
* Close the current active window.
*/
Q_INVOKABLE void closeActiveWindow();
/**
* Toggle whether we are in the "desktop showing" mode.
*/
Q_INVOKABLE void requestShowingDesktop(bool showingDesktop);
Q_SIGNALS:
void windowCreated(KWayland::Client::PlasmaWindow *window);
void showingDesktopChanged(bool showingDesktop);
void allWindowsMinimizedChanged();
void allWindowsMinimizedExcludingShellChanged();
void hasCloseableActiveWindowChanged();
void activeWindowChanged();
void activeWindowIsShellChanged();
......@@ -61,5 +91,6 @@ private:
bool m_showingDesktop = false;
bool m_allWindowsMinimized = true;
bool m_allWindowsMinimizedExcludingShell = true;
bool m_activeWindowIsShell = false;
};
......@@ -23,7 +23,7 @@ import org.kde.notificationmanager 1.0 as NotificationManager
Item {
id: root
readonly property bool showingApp: !MobileShell.HomeScreenControls.homeScreenVisible
readonly property bool showingApp: !MobileShell.WindowUtil.allWindowsMinimizedExcludingShell
readonly property color backgroundColor: topPanel.colorScopeColor
Plasmoid.backgroundHints: showingApp ? PlasmaCore.Types.StandardBackground : PlasmaCore.Types.NoBackground
......
......@@ -16,7 +16,7 @@ import org.kde.plasma.private.mobileshell 1.0 as MobileShell
MobileShell.NavigationPanel {
id: root
property bool appIsShown: !MobileShell.WindowUtil.allWindowsMinimized
property bool appIsShown: !MobileShell.WindowUtil.allWindowsMinimizedExcludingShell
// background is:
// - opaque if an app is shown or vkbd is shown
......
Supports Markdown
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