Skip to content

Commit

Permalink
fix: dock get max size when positionChanged and KeepHide mode
Browse files Browse the repository at this point in the history
no one update hideState properties in taskmanager and
not update dockSize when dock is in hide state by resetDragWindow call

log: as title
issue: linuxdeepin/developer-center#7040
  • Loading branch information
tsic404 committed Jan 25, 2024
1 parent 8b04a51 commit dcbf346
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
10 changes: 10 additions & 0 deletions frame/util/multiscreenworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "multiscreenworker.h"
#include "constants.h"
#include "mainwindow.h"
#include "taskmanager/taskmanager.h"
#include "utils.h"
#include "displaymanager.h"
#include "traymainwindow.h"
Expand Down Expand Up @@ -102,6 +104,10 @@ void MultiScreenWorker::onRegionMonitorChanged(int x, int y, const QString &key)
if (m_registerKey != key || testState(MousePress))
return;

if (m_hideMode == HideMode::KeepHidden) {
TaskManager::instance()->setPropHideState(HideState::Show);
}

tryToShowDock(x, y);
}

Expand All @@ -122,6 +128,10 @@ void MultiScreenWorker::onExtralRegionMonitorChanged(int x, int y, const QString
// 鼠标移动到任务栏界面之外,停止计时器(延时2秒改变任务栏所在屏幕)
m_delayWakeTimer->stop();

if (m_hideMode == HideMode::KeepHidden) {
TaskManager::instance()->setPropHideState(HideState::Hide);
}

if (m_hideMode == HideMode::KeepShowing
|| ((m_hideMode == HideMode::KeepHidden || m_hideMode == HideMode::SmartHide) && m_hideState == HideState::Show)) {
Q_EMIT requestPlayAnimation(DOCK_SCREEN->current(), m_position, Dock::AniAction::Show);
Expand Down
40 changes: 22 additions & 18 deletions frame/window/mainwindowbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "mainwindowbase.h"
#include "constants.h"
#include "dragwidget.h"
#include "multiscreenworker.h"
#include "dockscreen.h"
Expand Down Expand Up @@ -270,27 +271,30 @@ void MainWindowBase::resetDragWindow()
if (!screen)
return;

QRect currentRect = getDockGeometry(screen, position(), displayMode(), Dock::HideState::Show);
if (m_multiScreenWorker->hideState() == Dock::HideState::Show) {
QRect currentRect = getDockGeometry(screen, position(), displayMode(), Dock::HideState::Show);

// 这个时候屏幕有可能是隐藏的,不能直接使用this->width()这种去设置任务栏的高度,而应该保证原值
int dockSize = 0;
if (m_multiScreenWorker->position() == Position::Left
|| m_multiScreenWorker->position() == Position::Right) {
dockSize = this->width() == 0 ? currentRect.width() : this->width();
} else {
dockSize = this->height() == 0 ? currentRect.height() : this->height();
}
// 这个时候屏幕有可能是隐藏的,不能直接使用this->width()这种去设置任务栏的高度,而应该保证原值
int dockSize = 0;
if (m_multiScreenWorker->position() == Position::Left
|| m_multiScreenWorker->position() == Position::Right) {
dockSize = this->width() == 0 ? currentRect.width() : this->width();
} else {
dockSize = this->height() == 0 ? currentRect.height() : this->height();
}

/** FIX ME
* 作用:限制dockSize的值在40~100之间。
* 问题1:如果dockSize为39,会导致dock的mainwindow高度变成99,显示的内容高度却是39。
* 问题2:dockSize的值在这里不应该为39,但在高分屏上开启缩放后,拉高任务栏操作会概率出现。
* 暂时未分析出原因,后面再修改。
*/
dockSize = qBound(DOCK_MIN_SIZE, dockSize, DOCK_MAX_SIZE);
/** FIX ME
* 作用:限制dockSize的值在40~100之间。
* 问题1:如果dockSize为39,会导致dock的mainwindow高度变成99,显示的内容高度却是39。
* 问题2:dockSize的值在这里不应该为39,但在高分屏上开启缩放后,拉高任务栏操作会概率出现。
* 暂时未分析出原因,后面再修改。
*/
dockSize = qBound(DOCK_MIN_SIZE, dockSize, DOCK_MAX_SIZE);

// 通知窗管和后端更新数据
m_multiScreenWorker->updateDaemonDockSize(dockSize); // 1.先更新任务栏高度
}

// 通知窗管和后端更新数据
m_multiScreenWorker->updateDaemonDockSize(dockSize); // 1.先更新任务栏高度
m_multiScreenWorker->requestUpdateFrontendGeometry(); // 2.再更新任务栏位置,保证先1再2
m_multiScreenWorker->requestNotifyWindowManager();
m_multiScreenWorker->requestUpdateRegionMonitor(); // 界面发生变化,应更新监控区域
Expand Down

0 comments on commit dcbf346

Please sign in to comment.