Skip to content

Commit c6ab20e

Browse files
committed
fix: wrong panel position for multiple screens with different resolution
1 parent 0e83bd3 commit c6ab20e

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

deb.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set(_VERSION_MAJOR 0)
22
set(_VERSION_MINOR 6)
3-
set(_VERSION_PATCH 6)
3+
set(_VERSION_PATCH 7)
44

55
set(CPACK_GENERATOR "DEB")
66

frame/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
3131
app.setOrganizationName("septemberhx");
3232
app.setApplicationName("dde-top-panel");
3333
app.setApplicationDisplayName("DDE Top Panel");
34-
app.setApplicationVersion("0.6.6");
34+
app.setApplicationVersion("0.6.7");
3535
app.loadTranslator();
3636
app.setAttribute(Qt::AA_EnableHighDpiScaling, true);
3737
app.setAttribute(Qt::AA_UseHighDpiPixmaps, false);

frame/window/MainWindow.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "controller/dockitemmanager.h"
88
#include "util/utils.h"
99
#include <DGuiApplicationHelper>
10+
#include <iostream>
1011

1112
DGUI_USE_NAMESPACE
1213

@@ -305,26 +306,30 @@ void TopPanelLauncher::rearrange() {
305306
break;
306307
}
307308
}
308-
309+
std::cout << "==============> ifCopyMode:" << ifCopyScreenMode << std::endl;
309310
if (!ifCopyScreenMode) {
310311
for (auto p_screen : qApp->screens()) {
311312
if (mwMap.contains(p_screen)) {
312313
// adjust size
314+
std::cout << "========> Panel exists, resizing..." << std::endl;
313315
mwMap[p_screen]->hide();
314316
mwMap[p_screen]->moveToScreen(p_screen);
315317
mwMap[p_screen]->show();
316318
mwMap[p_screen]->setRaidus(0);
317319
continue;
318320
}
319321

320-
qDebug() << "===========> create top panel on" << p_screen->name();
322+
std::cout << "===========> create top panel on" << p_screen->name().toStdString() << std::endl;
321323
MainWindow *mw = new MainWindow(p_screen, p_screen != qApp->primaryScreen());
322324
connect(mw, &MainWindow::settingActionClicked, this, [this]() {
323325
int screenNum = QApplication::desktop()->screenNumber(dynamic_cast<MainWindow *>(sender()));
324-
this->m_settingWidget->move(QApplication::desktop()->screen(screenNum)->rect().center() -
325-
this->m_settingWidget->rect().center());
326+
this->m_settingWidget->move(QApplication::desktop()->screen(screenNum)->rect().topLeft());
326327
this->m_settingWidget->show();
327328
});
329+
330+
QPoint t = p_screen->geometry().topLeft();
331+
mw->move(t);
332+
328333
if (p_screen == qApp->primaryScreen()) {
329334
mw->loadPlugins();
330335
}
@@ -335,8 +340,7 @@ void TopPanelLauncher::rearrange() {
335340
MainWindow *mw = new MainWindow(p_screen, p_screen != qApp->primaryScreen());
336341
connect(mw, &MainWindow::settingActionClicked, this, [this]() {
337342
int screenNum = QApplication::desktop()->screenNumber(dynamic_cast<MainWindow *>(sender()));
338-
this->m_settingWidget->move(QApplication::desktop()->screen(screenNum)->rect().center() -
339-
this->m_settingWidget->rect().center());
343+
this->m_settingWidget->move(QApplication::desktop()->screen(screenNum)->rect().topLeft());
340344
this->m_settingWidget->show();
341345
});
342346
mw->loadPlugins();
@@ -375,6 +379,7 @@ void TopPanelLauncher::primaryChanged() {
375379
mwMap[currPrimaryScreen]->hide();
376380
if (ifRawPrimaryExists) {
377381
mwMap[currPrimaryScreen]->moveToScreen(primaryScreen);
382+
mwMap[currPrimaryScreen]->move(primaryScreen->geometry().topLeft());
378383
mwMap[primaryScreen] = mwMap[currPrimaryScreen];
379384
} else {
380385
mwMap[currPrimaryScreen]->close();

0 commit comments

Comments
 (0)