diff --git a/android-wasm/java/dev/ultra/launcher/wasm/LauncherActivity.java b/android-wasm/java/dev/ultra/launcher/wasm/LauncherActivity.java index f656cc1..88ad7e2 100644 --- a/android-wasm/java/dev/ultra/launcher/wasm/LauncherActivity.java +++ b/android-wasm/java/dev/ultra/launcher/wasm/LauncherActivity.java @@ -545,7 +545,7 @@ public class LauncherActivity extends NativeActivity { } @Override - public boolean onInterceptTouchEvent(MotionEvent ev) { + public boolean dispatchTouchEvent(MotionEvent ev) { switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: lifted = false; @@ -553,36 +553,20 @@ public class LauncherActivity extends NativeActivity { downRawY = lastRawY = ev.getRawY(); main.removeCallbacks(longPress); main.postDelayed(longPress, 450); - break; + super.dispatchTouchEvent(ev); + return true; case MotionEvent.ACTION_MOVE: handleMove(ev); if (lifted) return true; - break; + return super.dispatchTouchEvent(ev); case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: boolean wasLifted = lifted; handleEnd(ev); if (wasLifted) return true; - break; + return super.dispatchTouchEvent(ev); } - return super.onInterceptTouchEvent(ev); - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - switch (ev.getActionMasked()) { - case MotionEvent.ACTION_MOVE: - handleMove(ev); - if (lifted) return true; - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - boolean wasLifted = lifted; - handleEnd(ev); - if (wasLifted) return true; - break; - } - return super.onTouchEvent(ev); + return super.dispatchTouchEvent(ev); } } diff --git a/wasi/src/launcher_window.cpp b/wasi/src/launcher_window.cpp index 9ce605e..bfbdcad 100644 --- a/wasi/src/launcher_window.cpp +++ b/wasi/src/launcher_window.cpp @@ -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(); diff --git a/wasi/src/layout.cpp b/wasi/src/layout.cpp index 8de5bca..b9ddeb8 100644 --- a/wasi/src/layout.cpp +++ b/wasi/src/layout.cpp @@ -37,17 +37,21 @@ PackedGrid packHome(const QVector &items, int cols, const QSet 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; + } } }