Use dispatchTouchEvent for widget drag and prioritize widgets in layout

This commit is contained in:
nandi committed 2026-11-13 12:12:32 -08:00
1 parent 3cf65af790
commit f4e4cd3884
3 files changed
+31 -32

No files matched your search

+11
View File
@@ -351,6 +351,17 @@ void LauncherWindow::pollHostEvents() {
const int maxCol = std::max(0, homeCols() - m_home[idx].w);
const int col = std::clamp(int(std::lround(localX / (homeColW() + Layout::kColGap))), 0, maxCol);
const int row = std::max(0, int(std::lround(localY / (Layout::kCellH + Layout::kRowGap))));
const int ww = m_home[idx].w;
const int wh = m_home[idx].h;
// Unpin any app icons overlapping the widget's target rect so they reflow around it.
for (int i = 0; i < m_home.size(); ++i) {
if (i == idx || m_home[i].isWidget()) continue;
if (m_home[i].x >= col && m_home[i].x < col + ww
&& m_home[i].y >= row && m_home[i].y < row + wh) {
m_home[i].x = -1;
m_home[i].y = -1;
}
}
m_home[idx].x = col;
m_home[idx].y = row;
saveHome();
+14 -10
View File
@@ -37,17 +37,21 @@ PackedGrid packHome(const QVector<HomeSlot> &items, int cols, const QSet<QString
}
};
// Pass 1: place pinned slots first if their area is free.
// Pass 1: place pinned slots first (widgets before apps) if their area is free.
QVector<bool> placed(items.size(), false);
for (int i = 0; i < items.size(); ++i) {
const auto &s = items[i];
if (!s.isWidget() && hidden.contains(s.component)) continue;
const int w = std::clamp(s.w, 1, cols);
const int h = std::max(1, s.h);
if (s.x >= 0 && s.y >= 0 && isFree(s.x, s.y, w, h)) {
occupy(s.x, s.y, w, h);
out.cells[i] = {s.x, s.y};
placed[i] = true;
for (int pass = 0; pass < 2; ++pass) {
const bool wantWidget = (pass == 0);
for (int i = 0; i < items.size(); ++i) {
const auto &s = items[i];
if (s.isWidget() != wantWidget) continue;
if (!s.isWidget() && hidden.contains(s.component)) continue;
const int w = std::clamp(s.w, 1, cols);
const int h = std::max(1, s.h);
if (s.x >= 0 && s.y >= 0 && isFree(s.x, s.y, w, h)) {
occupy(s.x, s.y, w, h);
out.cells[i] = {s.x, s.y};
placed[i] = true;
}
}
}