Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions panels/dock/dockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ DockHelper::DockHelper(DockPanel *parent)
m_showTimer->start();
}
});
connect(this, &DockHelper::currentActiveWindowFullscreenChanged, this, [this] (bool isFullscreen) {
if (isFullscreen) {
checkNeedHideOrNot();
} else {
checkNeedShowOrNot();
}
});
}

bool DockHelper::eventFilter(QObject *watched, QEvent *event)
Expand Down Expand Up @@ -154,8 +161,8 @@ void DockHelper::checkNeedHideOrNot()
bool needHide;
switch (parent()->hideMode()) {
case KeepShowing: {
// KeepShow. current activeWindow is maximized.
needHide = currentActiveWindowMaximized();
// KeepShow. current activeWindow is fullscreend.
needHide = currentActiveWindowFullscreened();
break;
}
case SmartHide: {
Expand Down Expand Up @@ -184,8 +191,8 @@ void DockHelper::checkNeedShowOrNot()
bool needShow;
switch (parent()->hideMode()) {
case KeepShowing: {
// KeepShow. currentWindow is not maximized.
needShow = !currentActiveWindowMaximized();
// KeepShow. currentWindow is not fullscreened.
needShow = !currentActiveWindowFullscreened();
break;
}
case SmartHide: {
Expand Down
4 changes: 2 additions & 2 deletions panels/dock/dockhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class DockHelper : public QObject

Q_SIGNALS:
void isWindowOverlapChanged(bool overlap);
void currentActiveWindowMaximizedChanged(bool maximized);
void currentActiveWindowFullscreenChanged(bool fullscreen);

protected:
DockPanel *parent();
[[nodiscard]] virtual DockWakeUpArea *createArea(QScreen *screen) = 0;
virtual void destroyArea(DockWakeUpArea *area) = 0;

virtual bool currentActiveWindowMaximized() = 0;
virtual bool currentActiveWindowFullscreened() = 0;
virtual bool isWindowOverlap() = 0;

private:
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/taskmanager/abstractwindowmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class AbstractWindowMonitor : public QAbstractListModel

Q_SIGNALS:
void windowAdded(QPointer<AbstractWindow> window);
// true -> At least one window is at fullscreen state. false -> none of the windows is at fullscreen state.
void windowFullscreenChanged(bool);
void WindowMonitorShutdown();

private:
Expand Down
11 changes: 11 additions & 0 deletions panels/dock/taskmanager/taskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace dock {

TaskManager::TaskManager(QObject* parent)
: DContainment(parent)
, m_windowFullscreen(false)
{
qRegisterMetaType<ObjectInterfaceMap>();
qDBusRegisterMetaType<ObjectInterfaceMap>();
Expand Down Expand Up @@ -110,6 +111,11 @@ bool TaskManager::init()

if (m_windowMonitor)
m_windowMonitor->start();

connect(m_windowMonitor.data(), &AbstractWindowMonitor::windowFullscreenChanged, this, [this] (bool isFullscreen) {
m_windowFullscreen = isFullscreen;
emit windowFullscreenChanged(isFullscreen);
});
return true;
}

Expand Down Expand Up @@ -299,6 +305,11 @@ bool TaskManager::windowSplit()
return Settings->isWindowSplit();
}

bool TaskManager::windowFullscreen()
{
return m_windowFullscreen;
}

D_APPLET_CLASS(TaskManager)
}

Expand Down
4 changes: 4 additions & 0 deletions panels/dock/taskmanager/taskmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TaskManager : public DS_NAMESPACE::DContainment
Q_PROPERTY(ItemModel* dataModel READ dataModel NOTIFY dataModelChanged)

Q_PROPERTY(bool windowSplit READ windowSplit NOTIFY windowSplitChanged)
Q_PROPERTY(bool windowFullscreen READ windowFullscreen NOTIFY windowFullscreenChanged)
Q_PROPERTY(bool allowForceQuit READ allowForceQuit NOTIFY allowedForceQuitChanged)

public:
Expand All @@ -32,6 +33,7 @@ class TaskManager : public DS_NAMESPACE::DContainment
virtual bool load() override;

bool windowSplit();
bool windowFullscreen();
bool allowForceQuit();

Q_INVOKABLE QString desktopIdToAppId(const QString& desktopId);
Expand All @@ -49,6 +51,7 @@ class TaskManager : public DS_NAMESPACE::DContainment
Q_SIGNALS:
void dataModelChanged();
void windowSplitChanged();
void windowFullscreenChanged(bool);
void allowedForceQuitChanged();

private Q_SLOTS:
Expand All @@ -60,6 +63,7 @@ private Q_SLOTS:
private:
QScopedPointer<AbstractWindowMonitor> m_windowMonitor;
RoleCombineModel *m_activeAppModel = nullptr;
bool m_windowFullscreen;
};

}
Expand Down
5 changes: 5 additions & 0 deletions panels/dock/taskmanager/treelandwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@
return m_foreignToplevelHandle->state().contains(Minimized);
}

bool TreeLandWindow::isFullscreen()
{
return m_foreignToplevelHandle->state().contains(Fullscreen);
}

bool TreeLandWindow::allowClose()

Check warning on line 168 in panels/dock/taskmanager/treelandwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'allowClose' is never used.
{
return true;
}
Expand Down
1 change: 1 addition & 0 deletions panels/dock/taskmanager/treelandwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class TreeLandWindow : public AbstractWindow
bool isActive() override;
bool shouldSkip() override;
bool isMinimized() override;
bool isFullscreen();
bool allowClose() override;
bool isAttention() override;

Expand Down
15 changes: 15 additions & 0 deletions panels/dock/taskmanager/treelandwindowmonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void TreeLandDockPreviewContext::treeland_dock_preview_context_v1_leave()

TreeLandWindowMonitor::TreeLandWindowMonitor(QObject* parent)
:AbstractWindowMonitor(parent)
, m_fullscreenState(false)
{
}

Expand Down Expand Up @@ -170,6 +171,20 @@ void TreeLandWindowMonitor::handleForeignToplevelHandleAdded()
m_windows.insert(id, window);
}

connect(window.data(), &AbstractWindow::stateChanged, this, [=] {
for (auto w: m_windows) {
if (w->isFullscreen() && !m_fullscreenState) {
m_fullscreenState = true;
emit windowFullscreenChanged(true);
return;
}
}
if (m_fullscreenState) {
m_fullscreenState = false;
emit windowFullscreenChanged(false);
}
});

window->setForeignToplevelHandle(handle);

if (window->isReady())
Expand Down
1 change: 1 addition & 0 deletions panels/dock/taskmanager/treelandwindowmonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ private Q_SLOTS:
QScopedPointer<ForeignToplevelManager> m_foreignToplevelManager;
QScopedPointer<TreeLandDockPreviewContext> m_dockPreview;

bool m_fullscreenState;
};
}
19 changes: 14 additions & 5 deletions panels/dock/waylanddockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "waylanddockhelper.h"
#include "appletbridge.h"
#include "constants.h"
#include "dockhelper.h"
#include "dockpanel.h"
Expand All @@ -19,10 +20,14 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel)
: DockHelper(panel)
, m_panel(panel)
, m_isWindowOverlap(false)
, m_isCurrentActiveWindowMaximized(false)
, m_isCurrentActiveWindowFullscreened(false)
{
m_wallpaperColorManager.reset(new WallpaperColorManager(this));
m_ddeShellManager.reset(new TreeLandDDEShellManager());
DS_NAMESPACE::DAppletBridge bridge("org.deepin.ds.dock.taskmanager");
if (auto applet = bridge.applet()) {
connect(applet, SIGNAL(windowFullscreenChanged(bool)), this, SLOT(setCurrentActiveWindowFullscreened(bool)));
}

connect(m_panel, &DockPanel::rootObjectChanged, this, [this]() {
m_wallpaperColorManager->watchScreen(dockScreenName());
Expand Down Expand Up @@ -59,8 +64,6 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel)
if (m_panel->rootObject() != nullptr) {
m_wallpaperColorManager->watchScreen(dockScreenName());
}

// TODO: get taskmanager applet and use it to update m_isCurrentActiveWindowMaximized.
}

void WaylandDockHelper::updateOverlapCheckerPos()
Expand Down Expand Up @@ -116,9 +119,15 @@ QString WaylandDockHelper::dockScreenName()
return {};
}

bool WaylandDockHelper::currentActiveWindowMaximized()
bool WaylandDockHelper::currentActiveWindowFullscreened()
{
return m_isCurrentActiveWindowFullscreened;
}

void WaylandDockHelper::setCurrentActiveWindowFullscreened(bool isFullscreen)
{
return m_isCurrentActiveWindowMaximized;
m_isCurrentActiveWindowFullscreened = isFullscreen;
emit currentActiveWindowFullscreenChanged(isFullscreen);
}

bool WaylandDockHelper::isWindowOverlap()
Expand Down
7 changes: 5 additions & 2 deletions panels/dock/waylanddockhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ class WaylandDockHelper : public DockHelper
QString dockScreenName();

protected:
bool currentActiveWindowMaximized() override;
bool currentActiveWindowFullscreened() override;
bool isWindowOverlap() override;
[[nodiscard]] virtual DockWakeUpArea *createArea(QScreen *screen) override;
void destroyArea(DockWakeUpArea *area) override;

protected Q_SLOTS:
void setCurrentActiveWindowFullscreened(bool);

private:
void updateOverlapCheckerPos();

private:
friend class TreeLandWindowOverlapChecker;
bool m_isWindowOverlap;
bool m_isCurrentActiveWindowMaximized;
bool m_isCurrentActiveWindowFullscreened;
DockPanel *m_panel;
QScopedPointer<WallpaperColorManager> m_wallpaperColorManager;
QScopedPointer<TreeLandWindowOverlapChecker> m_overlapChecker;
Expand Down
2 changes: 1 addition & 1 deletion panels/dock/x11dockhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void X11DockHelper::updateDockArea()
}
}

bool X11DockHelper::currentActiveWindowMaximized()
bool X11DockHelper::currentActiveWindowFullscreened()
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion panels/dock/x11dockhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class X11DockHelper : public DockHelper
X11DockHelper(DockPanel *panel);

protected:
bool currentActiveWindowMaximized() override;
bool currentActiveWindowFullscreened() override;
bool isWindowOverlap() override;

[[nodiscard]] DockWakeUpArea *createArea(QScreen *screen) override;
Expand Down