Skip to content

Commit be64a9b

Browse files
authored
fix(win32): WithWindowPos 模式下禁用窗口位置检查 (#1302)
1 parent b41f84e commit be64a9b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

source/MaaWin32ControlUnit/Input/MessageInput.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ MessageInput::MessageInput(HWND hwnd, Config config)
6363
, config_(config)
6464
{
6565
if (config_.with_window_pos) {
66+
window_pos_guard_enabled_ = false;
6667
tracking_thread_ = std::thread(&MessageInput::tracking_thread_func, this);
6768
}
6869
}
@@ -393,6 +394,10 @@ bool MessageInput::move_window_to_align_cursor(int x, int y)
393394

394395
bool MessageInput::is_window_move_allowed(int new_left, int new_top, const RECT& current_rect, const char* reason)
395396
{
397+
if (!window_pos_guard_enabled_) {
398+
return true;
399+
}
400+
396401
RECT base_rect = window_pos_saved_ ? saved_window_rect_ : current_rect;
397402

398403
HMONITOR origin_monitor = MonitorFromRect(&base_rect, MONITOR_DEFAULTTONULL);

source/MaaWin32ControlUnit/Input/MessageInput.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class MessageInput : public RelativeMoveInput
6060
public: // mouse lock follow
6161
bool set_mouse_lock_follow(bool enabled);
6262

63+
// WithWindowPos 模式下默认禁用显示器保护,因为后台控制器需要自由移动窗口。
64+
// 如需恢复保护,调用 set_window_pos_guard_enabled(true)。
65+
void set_window_pos_guard_enabled(bool enabled) { window_pos_guard_enabled_ = enabled; }
66+
6367
private:
6468
using TrackingClock = std::chrono::steady_clock;
6569
using TrackingDeadlineTicks = TrackingClock::duration::rep;
@@ -121,6 +125,7 @@ class MessageInput : public RelativeMoveInput
121125
std::atomic_int pending_mouse_y_ = 0;
122126
std::atomic_bool has_pending_mouse_ = false;
123127
std::atomic_bool window_pos_invalid_movement_ = false;
128+
std::atomic_bool window_pos_guard_enabled_ = true;
124129
std::atomic_bool mouse_down_sent_ = false;
125130
std::atomic_int mouse_down_contact_ = 0;
126131
std::atomic_int last_mouse_x_ = 0;

0 commit comments

Comments
 (0)