Skip to content

Commit

Permalink
fix: use timer to avoid window hide caused by switching mode
Browse files Browse the repository at this point in the history
复用了现有的 timer 来避免在无混成时切换 launchpad 模式时失去焦点
导致的窗口隐藏。

Issue: linuxdeepin/developer-center#6818
Log:
  • Loading branch information
BLumia committed Jan 16, 2024
1 parent ab6ff5d commit 328454b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions launchercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ void LauncherController::setCurrentFrame(const QString &frame)
settings.setValue("current_frame", frame);

m_currentFrame = frame;
m_timer->start();
emit currentFrameChanged();
}

Expand All @@ -141,3 +142,8 @@ void LauncherController::hideWithTimer()
setVisible(false);
}
}

bool LauncherController::shouldAvoidHideOrActive()

Check warning on line 146 in launchercontroller.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'shouldAvoidHideOrActive' is never used.
{
return m_timer->isActive();
}
1 change: 1 addition & 0 deletions launchercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LauncherController : public QObject
void setCurrentFrame(const QString & frame);

Q_INVOKABLE void hideWithTimer();
Q_INVOKABLE bool shouldAvoidHideOrActive();

signals:
void currentFrameChanged();
Expand Down
8 changes: 7 additions & 1 deletion qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ QtObject {

onActiveChanged: {
if (!active && !DebugHelper.avoidHideWindow && (LauncherController.currentFrame === "WindowedFrame")) {
LauncherController.hideWithTimer()
// When composting is disabled, switching mode from fullscreen to windowed mode will cause window
// activeChanged signal get emitted. We reused the delay timer here to avoid the window get hide
// caused by that.
// Issue: https://github.com/linuxdeepin/developer-center/issues/6818
if (!LauncherController.shouldAvoidHideOrActive()) {
LauncherController.hideWithTimer()
}
}
}

Expand Down

0 comments on commit 328454b

Please sign in to comment.