mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix(frame): 代码合并错误
以下提交在代码合入时冲突,解决冲突时采用了旧代码,导致多屏失效问题 Log: 修复代码合并采用旧代码导致多屏失效问题
This commit is contained in:
parent
ac6a590b37
commit
6a97c67ddf
@ -209,24 +209,33 @@ const QRect DockSettings::primaryRect() const
|
||||
return rect;
|
||||
}
|
||||
|
||||
const QRect DockSettings::currentRect() const
|
||||
const QRect DockSettings::currentRect()
|
||||
{
|
||||
QRect rect;
|
||||
bool positionAllowed = false;
|
||||
QList<Monitor*> monitors = m_monitors.keys();
|
||||
for (Monitor *monitor : monitors) {
|
||||
switch (m_position) {
|
||||
case Top: positionAllowed = monitor->dockPosition().topDock; break;
|
||||
case Right: positionAllowed = monitor->dockPosition().rightDock; break;
|
||||
case Bottom: positionAllowed = monitor->dockPosition().bottomDock; break;
|
||||
case Left: positionAllowed = monitor->dockPosition().leftDock; break;
|
||||
}
|
||||
if (positionAllowed) {
|
||||
rect = monitor->rect();
|
||||
if (monitor->isPrimary())
|
||||
break;
|
||||
QString currentScrName;
|
||||
if (m_isMouseMoveCause) {
|
||||
rect = m_mouseCauseDockScreen->rect();
|
||||
currentScrName = m_mouseCauseDockScreen->name();
|
||||
} else {
|
||||
bool positionAllowed = false;
|
||||
QList<Monitor*> monitors = m_monitors.keys();
|
||||
for (Monitor *monitor : monitors) {
|
||||
switch (m_position) {
|
||||
case Top: positionAllowed = monitor->dockPosition().topDock; break;
|
||||
case Right: positionAllowed = monitor->dockPosition().rightDock; break;
|
||||
case Bottom: positionAllowed = monitor->dockPosition().bottomDock; break;
|
||||
case Left: positionAllowed = monitor->dockPosition().leftDock; break;
|
||||
}
|
||||
if (positionAllowed) {
|
||||
rect = monitor->rect();
|
||||
currentScrName = monitor->name();
|
||||
if (monitor->isPrimary())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_currentScreen = currentScrName;
|
||||
m_currentRawRect = rect;
|
||||
qreal scale = qApp->primaryScreen()->devicePixelRatio();
|
||||
rect.setWidth(std::round(qreal(rect.width()) / scale));
|
||||
@ -360,6 +369,7 @@ void DockSettings::menuActionClicked(QAction *action)
|
||||
if (action == &m_efficientModeAct)
|
||||
return m_dockInter->setDisplayMode(Efficient);
|
||||
|
||||
m_isMouseMoveCause = false;
|
||||
calculateMultiScreensPos();
|
||||
if (action == &m_topPosAct)
|
||||
return m_dockInter->setPosition(Top);
|
||||
@ -497,6 +507,18 @@ void DockSettings::updateFrontendGeometry()
|
||||
resetFrontendGeometry();
|
||||
}
|
||||
|
||||
void DockSettings::setDockScreen(const QString &scrName)
|
||||
{
|
||||
m_isMouseMoveCause = true;
|
||||
QList<Monitor*> monitors = m_monitors.keys();
|
||||
for (Monitor *monitor : monitors) {
|
||||
if (monitor && monitor->name() == scrName) {
|
||||
m_mouseCauseDockScreen = monitor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DockSettings::onOpacityChanged(const double value)
|
||||
{
|
||||
if (m_opacity == value) return;
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
inline int narrowTimeout() const { return 100; }
|
||||
inline bool autoHide() const { return m_autoHide; }
|
||||
const QRect primaryRect() const;
|
||||
const QRect currentRect() const;
|
||||
const QRect currentRect();
|
||||
const QList<QRect> monitorsRect() const;
|
||||
inline const QRect primaryRawRect() const { return m_primaryRawRect; }
|
||||
inline const QRect currentRawRect() const { return m_currentRawRect; }
|
||||
@ -141,7 +141,7 @@ private:
|
||||
HideState m_hideState;
|
||||
DisplayMode m_displayMode;
|
||||
QRect m_primaryRawRect;
|
||||
mutable QRect m_currentRawRect;
|
||||
QRect m_currentRawRect;
|
||||
QRect m_frontendRect;
|
||||
|
||||
QMenu m_settingsMenu;
|
||||
|
@ -1035,63 +1035,97 @@ void MainWindow::themeTypeChanged(DGuiApplicationHelper::ColorType themeType)
|
||||
|
||||
void MainWindow::onRegionMonitorChanged(int x, int y, const QString &key)
|
||||
{
|
||||
// if (m_registerKey != key)
|
||||
// return;
|
||||
|
||||
if (m_settings->hideMode() == KeepShowing)
|
||||
if (m_registerKey != key)
|
||||
return;
|
||||
|
||||
if (!isVisible())
|
||||
setVisible(true);
|
||||
QScreen *screen = Utils::screenAtByScaled(QPoint(x, y));
|
||||
|
||||
// QScreen *screen = Utils::screenAtByScaled(QPoint(x, y));
|
||||
if (screen->name() == m_settings->currentDockScreen()) {
|
||||
if (m_settings->hideMode() == KeepShowing)
|
||||
return;
|
||||
|
||||
if (!isVisible())
|
||||
setVisible(true);
|
||||
} else {
|
||||
// 移动Dock至相应屏相应位置
|
||||
m_mouseCauseDock = true;
|
||||
m_settings->setDockScreen(screen->name());
|
||||
positionChanged(m_curDockPos, m_curDockPos);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateRegionMonitorWatch()
|
||||
{
|
||||
if (m_settings->hideMode() == KeepShowing)
|
||||
return;
|
||||
if (!m_registerKey.isEmpty()) {
|
||||
m_eventInter->UnregisterArea(m_registerKey);
|
||||
m_registerKey.clear();
|
||||
}
|
||||
|
||||
const int flags = Motion | Button | Key;
|
||||
bool isHide = m_settings->hideState() == Hide && !testAttribute(Qt::WA_UnderMouse);
|
||||
const QRect windowRect = m_settings->windowRect(m_curDockPos, isHide);
|
||||
|
||||
QList<QRect> screensRect = m_settings->monitorsRect();
|
||||
QList<MonitRect> monitorAreas;
|
||||
|
||||
const qreal scale = devicePixelRatioF();
|
||||
int val = 5;
|
||||
const int margin = m_settings->dockMargin();
|
||||
int val = 3;
|
||||
int x, y, w, h;
|
||||
|
||||
switch (m_curDockPos) {
|
||||
case Dock::Top: {
|
||||
x = windowRect.topLeft().x();
|
||||
y = windowRect.topLeft().y();
|
||||
w = m_settings->primaryRect().width();
|
||||
h = val + margin;
|
||||
}
|
||||
break;
|
||||
case Dock::Bottom: {
|
||||
x = windowRect.bottomLeft().x();
|
||||
y = windowRect.bottomLeft().y() - val;
|
||||
w = m_settings->primaryRect().width();
|
||||
h = val + margin;
|
||||
}
|
||||
break;
|
||||
case Dock::Left: {
|
||||
x = windowRect.topLeft().x();
|
||||
y = windowRect.topLeft().y();
|
||||
w = val + margin;
|
||||
h = m_settings->primaryRect().height();
|
||||
}
|
||||
break;
|
||||
case Dock::Right: {
|
||||
x = windowRect.topRight().x() - val - margin;
|
||||
y = windowRect.topRight().y();
|
||||
w = m_settings->primaryRect().width();
|
||||
h = m_settings->primaryRect().height();
|
||||
}
|
||||
break;
|
||||
}
|
||||
auto func = [&](MonitRect &monitRect){
|
||||
monitRect.x1 = int(x * scale);
|
||||
monitRect.y1 = int(y * scale);
|
||||
monitRect.x2 = int((x + w) * scale);
|
||||
monitRect.y2 = int((y + h) * scale);
|
||||
monitorAreas << monitRect;
|
||||
};
|
||||
|
||||
m_eventInter->RegisterArea(x * scale, y * scale, w * scale, h * scale, flags);
|
||||
if (screensRect.size()) {
|
||||
MonitRect monitRect;
|
||||
switch (m_curDockPos) {
|
||||
case Dock::Top: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x();
|
||||
y = rect.y();
|
||||
w = rect.width();
|
||||
h = val;
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Dock::Bottom: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x();
|
||||
y = rect.y() + rect.height() - val;
|
||||
w = rect.width();
|
||||
h = val;
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Dock::Left: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x();
|
||||
y = rect.y();
|
||||
w = val;
|
||||
h = rect.height();
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Dock::Right: {
|
||||
for (QRect rect : screensRect) {
|
||||
x = rect.x() + rect.width() - val;
|
||||
y = rect.y();
|
||||
w = val;
|
||||
h = rect.height();
|
||||
func(monitRect);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
m_registerKey = m_eventInter->RegisterAreas(monitorAreas , flags);
|
||||
} else {
|
||||
m_registerKey = m_eventInter->RegisterFullScreen();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user