Skip to content

Commit

Permalink
fix: mainwindow hide when popup opens
Browse files Browse the repository at this point in the history
MainWindow should not hide when popup opens and the focus is still
on dock even if HideMode is AlwaysHide. Let popup block hiding of
mainwindow.

Log: fix mainwindow hide when popup opens
Issue: linuxdeepin/developer-center#4970
  • Loading branch information
asterwyx committed Jan 4, 2024
1 parent 107e742 commit cf909cd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frame/taskmanager/taskmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ TaskManager::TaskManager(QObject *parent)
, m_hideState(HideState::Unknown)
, m_ddeLauncherVisible(false)
, m_trayGridWidgetVisible(false)
, m_popupVisible(false)
, m_entries(new Entries(this))
, m_windowIdentify(new WindowIdentify(this))
, m_dbusHandler(new DBusHandler(this))
Expand Down Expand Up @@ -248,7 +249,7 @@ bool TaskManager::shouldShowOnDock(WindowInfoBase *info)
*/
void TaskManager::setDdeLauncherVisible(bool visible)
{
m_trayGridWidgetVisible = visible;
m_ddeLauncherVisible = visible;
}

/**
Expand All @@ -257,7 +258,12 @@ void TaskManager::setDdeLauncherVisible(bool visible)
*/
void TaskManager::setTrayGridWidgetVisible(bool visible)
{
m_ddeLauncherVisible = visible;
m_trayGridWidgetVisible = visible;
}

void TaskManager::setPopupVisible(bool visible)
{
m_popupVisible = visible;
}

/**
Expand Down Expand Up @@ -849,7 +855,7 @@ Entry *TaskManager::getDockedEntryByDesktopFile(const QString &desktopFile)
*/
bool TaskManager::shouldHideOnSmartHideMode()
{
if (!m_activeWindow || m_ddeLauncherVisible || m_trayGridWidgetVisible)
if (!m_activeWindow || m_ddeLauncherVisible || m_trayGridWidgetVisible || m_popupVisible)
return false;

if (!m_isWayland) {
Expand Down Expand Up @@ -949,7 +955,7 @@ QVector<XWindow> TaskManager::getActiveWinGroup(XWindow xid)
*/
void TaskManager::updateHideState(bool delay)
{
if (m_ddeLauncherVisible || m_trayGridWidgetVisible) {
if (m_ddeLauncherVisible || m_trayGridWidgetVisible || m_popupVisible) {
setPropHideState(HideState::Show);
return;
}
Expand Down
2 changes: 2 additions & 0 deletions frame/taskmanager/taskmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TaskManager : public QObject
bool shouldShowOnDock(WindowInfoBase *info);
void setDdeLauncherVisible(bool visible);
void setTrayGridWidgetVisible(bool visible);
void setPopupVisible(bool visible);
QString getWMName();
void setWMName(QString name);
void setPropHideState(HideState state);
Expand Down Expand Up @@ -177,6 +178,7 @@ public Q_SLOTS:
ForceQuitAppMode m_forceQuitAppStatus; // 强制退出应用状态
bool m_ddeLauncherVisible;
bool m_trayGridWidgetVisible;
bool m_popupVisible;

Entries *m_entries; // 所有应用实例
X11Manager *m_x11Manager; // X11窗口管理
Expand Down
3 changes: 3 additions & 0 deletions frame/util/dockpopupwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "dbusutil.h"
#include "dockscreen.h"
#include "displaymanager.h"
#include "taskmanager/taskmanager.h"

#include <QScreen>
#include <QApplication>
Expand Down Expand Up @@ -172,12 +173,14 @@ void DockPopupWindow::showEvent(QShowEvent *e)
Utils::updateCursor(this);
}

TaskManager::instance()->setPopupVisible(true);
QTimer::singleShot(1, this, &DockPopupWindow::ensureRaised);
}

void DockPopupWindow::hideEvent(QHideEvent *event)
{
m_extendWidget = nullptr;
TaskManager::instance()->setPopupVisible(false);
Dtk::Widget::DBlurEffectWidget::hideEvent(event);
}

Expand Down

0 comments on commit cf909cd

Please sign in to comment.