From 6457ac27dd624461194177c974df7377ab1a6686 Mon Sep 17 00:00:00 2001 From: mx6436 Date: Thu, 16 Apr 2026 21:53:48 +0800 Subject: [PATCH 1/2] refactor(wlroots): remove unused last_pos_ / has_clicked_ state The Ended phase in WaylandClient::pointer only sends a button release and ignores coordinates. The framework guarantees position is already set via touch_down/touch_move before touch_up, so tracking last_pos_ served no purpose. Made-with: Cursor --- .../Manager/WlRootsControlUnitMgr.cpp | 35 ++----------------- .../Manager/WlRootsControlUnitMgr.h | 3 -- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp b/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp index 27bc3d0f6..586cacf01 100644 --- a/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp +++ b/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp @@ -2,7 +2,6 @@ #include #include -#include #include @@ -138,14 +137,7 @@ bool WlRootsControlUnitMgr::touch_down(int contact, int x, int y, int pressure) return false; } - if (!client_->pointer(WaylandClient::EventPhase::Began, x, y, contact)) { - return false; - } - - last_pos_ = { x, y }; - has_clicked_ = true; - - return true; + return client_->pointer(WaylandClient::EventPhase::Began, x, y, contact); } bool WlRootsControlUnitMgr::touch_move(int contact, int x, int y, int pressure) @@ -157,14 +149,7 @@ bool WlRootsControlUnitMgr::touch_move(int contact, int x, int y, int pressure) return false; } - if (!client_->pointer(WaylandClient::EventPhase::Moved, x, y, contact)) { - return false; - } - - last_pos_ = { x, y }; - has_clicked_ = true; - - return true; + return client_->pointer(WaylandClient::EventPhase::Moved, x, y, contact); } bool WlRootsControlUnitMgr::touch_up(int contact) @@ -174,21 +159,7 @@ bool WlRootsControlUnitMgr::touch_up(int contact) return false; } - std::pair up = { 0, 0 }; - if (has_clicked_) { - up = last_pos_; - } - else { - auto [width, height] = client_->screen_size(); - up = { width / 2, height / 2 }; - } - - if (!client_->pointer(WaylandClient::EventPhase::Ended, up.first, up.second, contact)) { - return false; - } - - has_clicked_ = false; - return true; + return client_->pointer(WaylandClient::EventPhase::Ended, 0, 0, contact); } bool WlRootsControlUnitMgr::click_key(int key) diff --git a/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.h b/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.h index 50919fb52..db05e4f87 100644 --- a/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.h +++ b/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.h @@ -3,7 +3,6 @@ #include #include #include -#include #include "MaaControlUnit/ControlUnitAPI.h" #include "MaaFramework/MaaDef.h" @@ -55,8 +54,6 @@ class WlRootsControlUnitMgr : public WlRootsControlUnitAPI private: std::unique_ptr client_; std::filesystem::path wlr_socket_path_; - std::pair last_pos_ = { 0, 0 }; - bool has_clicked_ = false; }; MAA_CTRL_UNIT_NS_END From 2976c17edf0aac5f41982a34672a361bb82a9a17 Mon Sep 17 00:00:00 2001 From: mx6436 Date: Fri, 17 Apr 2026 12:40:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=86=99=E7=82=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp b/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp index 586cacf01..7d5c59720 100644 --- a/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp +++ b/source/MaaWlRootsControlUnit/Manager/WlRootsControlUnitMgr.cpp @@ -159,6 +159,7 @@ bool WlRootsControlUnitMgr::touch_up(int contact) return false; } + // Ended phase only sends button release; WaylandClient ignores x/y. (0,0) is a placeholder. return client_->pointer(WaylandClient::EventPhase::Ended, 0, 0, contact); }