Skip to content

Commit

Permalink
fix: Desktop geometry anomaly when resolution changes
Browse files Browse the repository at this point in the history
The geometry of the desktop window was updated by dde-shell, so the intent of the original checking mechanism was changed

Log: fix  Desktop geometry anomaly

Bug: https://pms.uniontech.com/bug-view-275933.html
  • Loading branch information
Johnson-zs authored and deepin-bot[bot] committed Oct 11, 2024
1 parent 4be5b3c commit 2bea063
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
4 changes: 3 additions & 1 deletion src/plugins/desktop/core/ddplugin-core/frame/windowframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ void WindowFrame::onGeometryChanged()
auto win = d->windows.value(sp->name());
fmDebug() << "screen geometry change:" << sp.get() << win.get();
if (win.get() != nullptr) {
// Don't continue! dde-shell change the window geometry,
// always send geometryChanged in the scene
if (win->geometry() == sp->geometry())
continue;
fmDebug() << "Window geometry is equal to logic geomertry" << win->geometry() << sp->geometry();

fmInfo() << "root geometry change from" << win->geometry() << "to" << sp->geometry()
<< "screen name" << sp->name();
Expand Down
43 changes: 18 additions & 25 deletions src/plugins/desktop/ddplugin-background/backgroundmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#ifdef COMPILE_ON_V23
#include "backgrounddde.h"
# include "backgrounddde.h"
#else
#include "backgroundwm.h"
# include "backgroundwm.h"
#endif
#include "backgroundmanager.h"
#include "backgroundmanager_p.h"
Expand Down Expand Up @@ -48,10 +48,8 @@ static QMap<QString, QWidget *> rootMap()
}

BackgroundManagerPrivate::BackgroundManagerPrivate(BackgroundManager *qq)
: QObject(qq)
, q(qq)
: QObject(qq), q(qq)
{

}

BackgroundManagerPrivate::~BackgroundManagerPrivate()
Expand All @@ -71,15 +69,14 @@ bool BackgroundManagerPrivate::isEnableBackground()
}

BackgroundManager::BackgroundManager(QObject *parent)
: QObject(parent)
, d(new BackgroundManagerPrivate(this))
: QObject(parent), d(new BackgroundManagerPrivate(this))
{
d->service =
#ifdef COMPILE_ON_V23
new BackgroundDDE(this);
#else
new BackgroundWM(this);
#endif
#ifdef COMPILE_ON_V23
new BackgroundDDE(this);
#else
new BackgroundWM(this);
#endif

d->bridge = new BackgroundBridge(d);
}
Expand All @@ -88,7 +85,7 @@ BackgroundManager::~BackgroundManager()
{
CanvasCoreUnsubscribe(signal_DesktopFrame_WindowAboutToBeBuilded, &BackgroundManager::onDetachWindows);
CanvasCoreUnsubscribe(signal_DesktopFrame_WindowBuilded, &BackgroundManager::onBackgroundBuild);
CanvasCoreUnsubscribe(signal_DesktopFrame_GeometryChanged, &BackgroundManager::onGeometryChanged);
CanvasCoreUnsubscribe(signal_DesktopFrame_GeometryChanged, &BackgroundManager::onGeometryChanged);
}

void BackgroundManager::init()
Expand Down Expand Up @@ -257,14 +254,14 @@ void BackgroundManager::onGeometryChanged()
if (bw.get() != nullptr) {
QRect geometry = d->relativeGeometry(win->geometry()); // scaled area
if (bw->geometry() == geometry) {
fmDebug() << "background geometry is equal to root widget geometry,and discard changes" << bw->geometry()
<< win->geometry() << win->property(DesktopFrameProperty::kPropScreenName).toString()
<< win->property(DesktopFrameProperty::kPropScreenGeometry).toRect() << win->property(DesktopFrameProperty::kPropScreenHandleGeometry).toRect()
<< win->property(DesktopFrameProperty::kPropScreenAvailableGeometry);
fmWarning() << "background geometry is equal to root widget geometry,and discard changes" << bw->geometry()
<< win->geometry() << win->property(DesktopFrameProperty::kPropScreenName).toString()
<< win->property(DesktopFrameProperty::kPropScreenGeometry).toRect() << win->property(DesktopFrameProperty::kPropScreenHandleGeometry).toRect()
<< win->property(DesktopFrameProperty::kPropScreenAvailableGeometry);
continue;
}
fmInfo() << "background geometry change from" << bw->geometry() << "to" << geometry
<< "screen name" << getScreenName(win) << "screen geometry" << win->geometry();
<< "screen name" << getScreenName(win) << "screen geometry" << win->geometry();
bw->setGeometry(geometry);
changed = true;
}
Expand All @@ -291,12 +288,9 @@ BackgroundWidgetPointer BackgroundManager::createBackgroundWidget(QWidget *root)
return bwp;
}


BackgroundBridge::BackgroundBridge(BackgroundManagerPrivate *ptr)
: QObject()
, d(ptr)
: QObject(), d(ptr)
{

}

BackgroundBridge::~BackgroundBridge()
Expand Down Expand Up @@ -438,7 +432,7 @@ void BackgroundBridge::runUpdate(BackgroundBridge *self, QList<Requestion> reqs)
QPixmap backgroundPixmap = BackgroundBridge::getPixmap(req.path);
if (backgroundPixmap.isNull()) {
fmCritical() << "screen " << req.screen << "backfround path" << req.path
<< "can not read!";
<< "can not read!";
continue;
}

Expand Down Expand Up @@ -473,7 +467,6 @@ void BackgroundBridge::runUpdate(BackgroundBridge *self, QList<Requestion> reqs)

QList<Requestion> *pRecorder = new QList<Requestion>;
*pRecorder = std::move(recorder);
QMetaObject::invokeMethod(self, "onFinished", Qt::QueuedConnection
, Q_ARG(void *, pRecorder));
QMetaObject::invokeMethod(self, "onFinished", Qt::QueuedConnection, Q_ARG(void *, pRecorder));
self->getting = false;
}
7 changes: 4 additions & 3 deletions src/plugins/desktop/ddplugin-organizer/framemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,10 @@ void FrameManagerPrivate::showOptionWindow()
options = new OptionsWindow();
options->setAttribute(Qt::WA_DeleteOnClose);
options->initialize();
connect(options, &OptionsWindow::destroyed, this, [this]() {
options = nullptr;
},
connect(
options, &OptionsWindow::destroyed, this, [this]() {
options = nullptr;
},
Qt::DirectConnection);

options->moveToCenter(QCursor::pos());
Expand Down

0 comments on commit 2bea063

Please sign in to comment.