Skip to content

Commit e365336

Browse files
committed
feat: Auto hide dde-dock on window fullscreen in Wayland
pms: BUG-263325 BUG-278961 Log: Auto hide dde-dock on window fullscreen in Wayland
1 parent abf8a87 commit e365336

13 files changed

+74
-14
lines changed

panels/dock/dockhelper.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ DockHelper::DockHelper(DockPanel *parent)
4545
m_showTimer->start();
4646
}
4747
});
48+
connect(this, &DockHelper::currentActiveWindowFullscreenChanged, this, [this] (bool state) {
49+
if (state) {
50+
checkNeedHideOrNot();
51+
} else {
52+
checkNeedShowOrNot();
53+
}
54+
});
4855
}
4956

5057
bool DockHelper::eventFilter(QObject *watched, QEvent *event)
@@ -154,8 +161,8 @@ void DockHelper::checkNeedHideOrNot()
154161
bool needHide;
155162
switch (parent()->hideMode()) {
156163
case KeepShowing: {
157-
// KeepShow. current activeWindow is maximized.
158-
needHide = currentActiveWindowMaximized();
164+
// KeepShow. current activeWindow is fullscreend.
165+
needHide = currentActiveWindowFullscreened();
159166
break;
160167
}
161168
case SmartHide: {
@@ -184,8 +191,8 @@ void DockHelper::checkNeedShowOrNot()
184191
bool needShow;
185192
switch (parent()->hideMode()) {
186193
case KeepShowing: {
187-
// KeepShow. currentWindow is not maximized.
188-
needShow = !currentActiveWindowMaximized();
194+
// KeepShow. currentWindow is not fullscreened.
195+
needShow = !currentActiveWindowFullscreened();
189196
break;
190197
}
191198
case SmartHide: {

panels/dock/dockhelper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class DockHelper : public QObject
2424

2525
Q_SIGNALS:
2626
void isWindowOverlapChanged(bool overlap);
27-
void currentActiveWindowMaximizedChanged(bool maximized);
27+
void currentActiveWindowFullscreenChanged(bool fullscreen);
2828

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

34-
virtual bool currentActiveWindowMaximized() = 0;
34+
virtual bool currentActiveWindowFullscreened() = 0;
3535
virtual bool isWindowOverlap() = 0;
3636

3737
private:

panels/dock/taskmanager/abstractwindowmonitor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class AbstractWindowMonitor : public QAbstractListModel
4040

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

4547
private:

panels/dock/taskmanager/taskmanager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace dock {
4040

4141
TaskManager::TaskManager(QObject* parent)
4242
: DContainment(parent)
43+
, m_windowFullscreen(false)
4344
{
4445
qRegisterMetaType<ObjectInterfaceMap>();
4546
qDBusRegisterMetaType<ObjectInterfaceMap>();
@@ -110,6 +111,11 @@ bool TaskManager::init()
110111

111112
if (m_windowMonitor)
112113
m_windowMonitor->start();
114+
115+
connect(m_windowMonitor.data(), &AbstractWindowMonitor::windowFullscreenChanged, this, [this] (bool state) {
116+
m_windowFullscreen = state;
117+
emit windowFullscreenChanged(state);
118+
});
113119
return true;
114120
}
115121

@@ -298,6 +304,11 @@ bool TaskManager::windowSplit()
298304
return Settings->isWindowSplit();
299305
}
300306

307+
bool TaskManager::windowFullscreen()
308+
{
309+
return m_windowFullscreen;
310+
}
311+
301312
D_APPLET_CLASS(TaskManager)
302313
}
303314

panels/dock/taskmanager/taskmanager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class TaskManager : public DS_NAMESPACE::DContainment
2121
Q_PROPERTY(ItemModel* dataModel READ dataModel NOTIFY dataModelChanged)
2222

2323
Q_PROPERTY(bool windowSplit READ windowSplit NOTIFY windowSplitChanged)
24+
Q_PROPERTY(bool windowFullscreen READ windowFullscreen NOTIFY windowFullscreenChanged)
2425
Q_PROPERTY(bool allowForceQuit READ allowForceQuit NOTIFY allowedForceQuitChanged)
2526

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

3435
bool windowSplit();
36+
bool windowFullscreen();
3537
bool allowForceQuit();
3638

3739
Q_INVOKABLE QString desktopIdToAppId(const QString& desktopId);
@@ -49,6 +51,7 @@ class TaskManager : public DS_NAMESPACE::DContainment
4951
Q_SIGNALS:
5052
void dataModelChanged();
5153
void windowSplitChanged();
54+
void windowFullscreenChanged(bool);
5255
void allowedForceQuitChanged();
5356

5457
private Q_SLOTS:
@@ -60,6 +63,7 @@ private Q_SLOTS:
6063
private:
6164
QScopedPointer<AbstractWindowMonitor> m_windowMonitor;
6265
RoleCombineModel *m_activeAppModel = nullptr;
66+
bool m_windowFullscreen;
6367
};
6468

6569
}

panels/dock/taskmanager/treelandwindow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ bool TreeLandWindow::isMinimized()
160160
return m_foreignToplevelHandle->state().contains(Minimized);
161161
}
162162

163+
bool TreeLandWindow::isFullscreen()
164+
{
165+
return m_foreignToplevelHandle->state().contains(Fullscreen);
166+
}
167+
163168
bool TreeLandWindow::allowClose()
164169
{
165170
return true;

panels/dock/taskmanager/treelandwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class TreeLandWindow : public AbstractWindow
8181
bool isActive() override;
8282
bool shouldSkip() override;
8383
bool isMinimized() override;
84+
bool isFullscreen();
8485
bool allowClose() override;
8586
bool isAttention() override;
8687

panels/dock/taskmanager/treelandwindowmonitor.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ void TreeLandDockPreviewContext::treeland_dock_preview_context_v1_leave()
7979

8080
TreeLandWindowMonitor::TreeLandWindowMonitor(QObject* parent)
8181
:AbstractWindowMonitor(parent)
82+
, m_fullscreenState(false)
8283
{
8384
}
8485

@@ -170,6 +171,20 @@ void TreeLandWindowMonitor::handleForeignToplevelHandleAdded()
170171
m_windows.insert(id, window);
171172
}
172173

174+
connect(window.data(), &AbstractWindow::stateChanged, this, [=] {
175+
for (auto w: m_windows) {
176+
if (w->isFullscreen() && !m_fullscreenState) {
177+
m_fullscreenState = true;
178+
emit windowFullscreenChanged(true);
179+
return;
180+
}
181+
}
182+
if (m_fullscreenState) {
183+
m_fullscreenState = false;
184+
emit windowFullscreenChanged(false);
185+
}
186+
});
187+
173188
window->setForeignToplevelHandle(handle);
174189

175190
if (window->isReady())

panels/dock/taskmanager/treelandwindowmonitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,6 @@ private Q_SLOTS:
8484
QScopedPointer<ForeignToplevelManager> m_foreignToplevelManager;
8585
QScopedPointer<TreeLandDockPreviewContext> m_dockPreview;
8686

87+
bool m_fullscreenState;
8788
};
8889
}

panels/dock/waylanddockhelper.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

55
#include "waylanddockhelper.h"
6+
#include "appletbridge.h"
67
#include "constants.h"
78
#include "dockhelper.h"
89
#include "dockpanel.h"
@@ -19,10 +20,14 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel)
1920
: DockHelper(panel)
2021
, m_panel(panel)
2122
, m_isWindowOverlap(false)
22-
, m_isCurrentActiveWindowMaximized(false)
23+
, m_isCurrentActiveWindowFullscreened(false)
2324
{
2425
m_wallpaperColorManager.reset(new WallpaperColorManager(this));
2526
m_ddeShellManager.reset(new TreeLandDDEShellManager());
27+
DS_NAMESPACE::DAppletBridge bridge("org.deepin.ds.dock.taskmanager");
28+
if (auto applet = bridge.applet()) {
29+
connect(applet, SIGNAL(windowFullscreenChanged(bool)), this, SLOT(setCurrentActiveWindowFullscreened(bool)));
30+
}
2631

2732
connect(m_panel, &DockPanel::rootObjectChanged, this, [this]() {
2833
m_wallpaperColorManager->watchScreen(dockScreenName());
@@ -60,7 +65,7 @@ WaylandDockHelper::WaylandDockHelper(DockPanel *panel)
6065
m_wallpaperColorManager->watchScreen(dockScreenName());
6166
}
6267

63-
// TODO: get taskmanager applet and use it to update m_isCurrentActiveWindowMaximized.
68+
// TODO: get taskmanager applet and use it to update m_isCurrentActiveWindowFullscreened.
6469
}
6570

6671
void WaylandDockHelper::updateOverlapCheckerPos()
@@ -116,9 +121,15 @@ QString WaylandDockHelper::dockScreenName()
116121
return {};
117122
}
118123

119-
bool WaylandDockHelper::currentActiveWindowMaximized()
124+
bool WaylandDockHelper::currentActiveWindowFullscreened()
125+
{
126+
return m_isCurrentActiveWindowFullscreened;
127+
}
128+
129+
void WaylandDockHelper::setCurrentActiveWindowFullscreened(bool state)
120130
{
121-
return m_isCurrentActiveWindowMaximized;
131+
m_isCurrentActiveWindowFullscreened = state;
132+
emit currentActiveWindowFullscreenChanged(state);
122133
}
123134

124135
bool WaylandDockHelper::isWindowOverlap()

0 commit comments

Comments
 (0)