fix(toplevel): added support for beginMove. The settings window can be repositionned without Meta key

This commit is contained in:
Lemmy
2026-05-10 23:58:48 -04:00
parent 6740260693
commit 4bb6842113
4 changed files with 24 additions and 3 deletions
+14 -1
View File
@@ -40,6 +40,7 @@
#include <cstdint>
#include <filesystem>
#include <fstream>
#include <linux/input-event-codes.h>
#include <memory>
#include <optional>
#include <string>
@@ -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<Node>();
@@ -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<float>(event.sy) < hy + m_headerRow->height()) {
m_surface->beginMove(event.serial);
consumed = true;
break;
}
}
if (pressed) {
Select::handleGlobalPointerPress(m_inputDispatcher.hoveredArea());
}
+3 -2
View File
@@ -95,8 +95,9 @@ private:
std::unique_ptr<ToplevelSurface> m_surface;
std::unique_ptr<Node> 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;
+6
View File
@@ -93,6 +93,12 @@ bool ToplevelSurface::initialize(wl_output* output, ToplevelSurfaceConfig config
void ToplevelSurface::setClosedCallback(std::function<void()> 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<ToplevelSurface*>(data);
xdg_surface_ack_configure(surface, serial);
+1
View File
@@ -30,6 +30,7 @@ public:
bool initialize(wl_output* output, ToplevelSurfaceConfig config);
void setClosedCallback(std::function<void()> callback);
void beginMove(std::uint32_t serial);
[[nodiscard]] xdg_surface* xdgSurface() const noexcept { return m_xdgSurface; }