From 4bb68421137b2a71a067c310051bac4442a675db Mon Sep 17 00:00:00 2001 From: Lemmy Date: Sun, 10 May 2026 23:58:48 -0400 Subject: [PATCH] fix(toplevel): added support for beginMove. The settings window can be repositionned without Meta key --- src/shell/settings/settings_window.cpp | 15 ++++++++++++++- src/shell/settings/settings_window.h | 5 +++-- src/wayland/toplevel_surface.cpp | 6 ++++++ src/wayland/toplevel_surface.h | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/shell/settings/settings_window.cpp b/src/shell/settings/settings_window.cpp index cdb336e13..16182ae95 100644 --- a/src/shell/settings/settings_window.cpp +++ b/src/shell/settings/settings_window.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -363,6 +364,7 @@ void SettingsWindow::destroyWindow() { m_surface->setSceneRoot(nullptr); } m_mainContainer = nullptr; + m_headerRow = nullptr; m_contentContainer = nullptr; m_contentScrollView = nullptr; m_actionsMenuButton = nullptr; @@ -1503,6 +1505,7 @@ void SettingsWindow::buildScene(std::uint32_t width, std::uint32_t height) { m_inputDispatcher.setSceneRoot(nullptr); m_mainContainer = nullptr; + m_headerRow = nullptr; m_panelBackground = nullptr; m_contentContainer = nullptr; m_sceneRoot = std::make_unique(); @@ -1573,7 +1576,7 @@ void SettingsWindow::buildScene(std::uint32_t width, std::uint32_t height) { closeBtn->setOnClick([this]() { close(); }); header->addChild(std::move(closeBtn)); - main->addChild(centeredRow(std::move(header))); + m_headerRow = main->addChild(centeredRow(std::move(header))); const auto requestRebuild = [this]() { requestSceneRebuild(); }; const auto clearStatus = [this]() { clearStatusMessage(); }; @@ -1861,6 +1864,16 @@ bool SettingsWindow::onPointerEvent(const PointerEvent& event) { if (onThis) { m_pointerInside = true; } + if (pressed && event.button == BTN_LEFT && m_headerRow != nullptr && m_inputDispatcher.hoveredArea() == nullptr) { + float hx = 0.0f; + float hy = 0.0f; + Node::absolutePosition(m_headerRow, hx, hy); + if (static_cast(event.sy) < hy + m_headerRow->height()) { + m_surface->beginMove(event.serial); + consumed = true; + break; + } + } if (pressed) { Select::handleGlobalPointerPress(m_inputDispatcher.hoveredArea()); } diff --git a/src/shell/settings/settings_window.h b/src/shell/settings/settings_window.h index 651c164f1..d65a34d20 100644 --- a/src/shell/settings/settings_window.h +++ b/src/shell/settings/settings_window.h @@ -95,8 +95,9 @@ private: std::unique_ptr m_surface; std::unique_ptr m_sceneRoot; - Flex* m_mainContainer = nullptr; // Outer Flex inside m_sceneRoot, sized to the window - Box* m_panelBackground = nullptr; // Window-sized background panel inside m_sceneRoot + Flex* m_mainContainer = nullptr; // Outer Flex inside m_sceneRoot, sized to the window + Box* m_panelBackground = nullptr; + Node* m_headerRow = nullptr; Button* m_actionsMenuButton = nullptr; Flex* m_contentContainer = nullptr; ScrollView* m_contentScrollView = nullptr; diff --git a/src/wayland/toplevel_surface.cpp b/src/wayland/toplevel_surface.cpp index 9855b9f35..32fe3bc7b 100644 --- a/src/wayland/toplevel_surface.cpp +++ b/src/wayland/toplevel_surface.cpp @@ -93,6 +93,12 @@ bool ToplevelSurface::initialize(wl_output* output, ToplevelSurfaceConfig config void ToplevelSurface::setClosedCallback(std::function callback) { m_closedCallback = std::move(callback); } +void ToplevelSurface::beginMove(std::uint32_t serial) { + if (m_toplevel != nullptr) { + xdg_toplevel_move(m_toplevel, m_connection.seat(), serial); + } +} + void ToplevelSurface::handleXdgSurfaceConfigure(void* data, xdg_surface* surface, std::uint32_t serial) { auto* self = static_cast(data); xdg_surface_ack_configure(surface, serial); diff --git a/src/wayland/toplevel_surface.h b/src/wayland/toplevel_surface.h index 3b297e6ea..337990fbf 100644 --- a/src/wayland/toplevel_surface.h +++ b/src/wayland/toplevel_surface.h @@ -30,6 +30,7 @@ public: bool initialize(wl_output* output, ToplevelSurfaceConfig config); void setClosedCallback(std::function callback); + void beginMove(std::uint32_t serial); [[nodiscard]] xdg_surface* xdgSurface() const noexcept { return m_xdgSurface; }