1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-09 16:58:16 +03:00

fix #573,improve the primary docks behavior

--users reported that when activating an external screen
as primary and at the same time disabling the original
screen e.g. the laptop one, latte wasnt showing docks at
all. This could also occur on startup. This commit
fixes this and improves more the multi-screen code in
various corner cases
This commit is contained in:
Michail Vourlakos 2017-06-30 11:26:54 +03:00
parent d467815aa8
commit c72f7f4531
2 changed files with 21 additions and 15 deletions

View File

@ -534,13 +534,8 @@ void DockCorona::syncDockViews()
bool found{false};
foreach (auto scr, qGuiApp->screens()) {
int id = view->containment()->screen();
if (id == -1) {
id = view->containment()->lastScreen();
}
if (scr->name() == view->currentScreen()) {
if (scr->name() == view->currentScreen()
|| (view->onPrimary() && scr == qGuiApp->primaryScreen() ) ) {
found = true;
break;
}
@ -572,7 +567,8 @@ void DockCorona::syncDockViews()
bool found{false};
foreach (auto scr, qGuiApp->screens()) {
if (scr->name() == view->currentScreen()) {
if (scr->name() == view->currentScreen()
|| (view->onPrimary() && scr == qGuiApp->primaryScreen()) ) {
found = true;
break;
}
@ -733,7 +729,7 @@ QList<Plasma::Types::Location> DockCorona::freeEdges(QScreen *screen) const
Types::TopEdge, Types::RightEdge};
for (auto *view : m_dockViews) {
if (view && view->screen() == screen && view->session() == m_session) {
if (view && view->currentScreen() == screen->name() && view->session() == m_session) {
edges.removeOne(view->location());
}
}
@ -750,7 +746,7 @@ QList<Plasma::Types::Location> DockCorona::freeEdges(int screen) const
QScreen *scr = m_screenPool->screenForId(screen);
for (auto *view : m_dockViews) {
if (view && view->screen() == scr && view->session() == m_session) {
if (view && scr && view->currentScreen() == scr->name() && view->session() == m_session) {
edges.removeOne(view->location());
}
}

View File

@ -343,9 +343,11 @@ void DockView::reconsiderScreen()
//!check if the associated screen is running
foreach (auto scr, qGuiApp->screens()) {
if (m_screenToFollowId == scr->name())
if (m_screenToFollowId == scr->name()
|| (onPrimary() && scr == qGuiApp->primaryScreen()) ) {
screenExists = true;
}
}
qDebug() << "dock screen exists ::: " << screenExists;
@ -353,31 +355,39 @@ void DockView::reconsiderScreen()
//! 2.the last tasks dock must also always on the primary screen
//! even though it has been configured as an explicit
if ((m_onPrimary || (tasksPresent() && dockCorona->noDocksWithTasks() == 1 && !screenExists))
&& m_screenToFollowId != qGuiApp->primaryScreen()->name()
&& m_screenToFollow != qGuiApp->primaryScreen()) {
&& (m_screenToFollowId != qGuiApp->primaryScreen()->name()
|| m_screenToFollow != qGuiApp->primaryScreen())) {
//change to primary screen only if the specific edge is free
qDebug() << "updating the primary screen for dock...";
qDebug() << "available primary screen edges:" << dockCorona->freeEdges(qGuiApp->primaryScreen());
qDebug() << "dock location:" << location();
if (dockCorona->freeEdges(qGuiApp->primaryScreen()).contains(location())) {
connect(qGuiApp->primaryScreen(), &QScreen::geometryChanged, this, &DockView::screenGeometryChanged);
//! case 2
if (!m_onPrimary && !screenExists && tasksPresent() && (dockCorona->noDocksWithTasks() == 1)) {
qDebug() << "reached case 2 of updating dock primary screen...";
setScreenToFollow(qGuiApp->primaryScreen(), false);
} else {
//! case 1
qDebug() << "reached case 1 of updating dock primary screen...";
setScreenToFollow(qGuiApp->primaryScreen());
}
syncGeometry();
}
} else {
} else if (!m_onPrimary){
//! 3.an explicit dock must be always on the correct associated screen
//! there are cases that window manager misplaces the dock, this function
//! ensures that this dock will return at its correct screen
foreach (auto scr, qGuiApp->screens()) {
if (scr && scr->name() == m_screenToFollowId) {
qDebug() << "updating the explicit screen for dock...";
connect(scr, &QScreen::geometryChanged, this, &DockView::screenGeometryChanged);
setScreenToFollow(scr);
syncGeometry();
break;
}
}
}