Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions source/MaaWin32ControlUnit/Input/MessageInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ MessageInput::MessageInput(HWND hwnd, Config config)
, config_(config)
{
if (config_.with_window_pos) {
window_pos_guard_enabled_ = false;
tracking_thread_ = std::thread(&MessageInput::tracking_thread_func, this);
}
}
Expand Down Expand Up @@ -393,6 +394,10 @@ bool MessageInput::move_window_to_align_cursor(int x, int y)

bool MessageInput::is_window_move_allowed(int new_left, int new_top, const RECT& current_rect, const char* reason)
{
if (!window_pos_guard_enabled_) {
return true;
}

RECT base_rect = window_pos_saved_ ? saved_window_rect_ : current_rect;

HMONITOR origin_monitor = MonitorFromRect(&base_rect, MONITOR_DEFAULTTONULL);
Expand Down
5 changes: 5 additions & 0 deletions source/MaaWin32ControlUnit/Input/MessageInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class MessageInput : public RelativeMoveInput
public: // mouse lock follow
bool set_mouse_lock_follow(bool enabled);

// WithWindowPos 模式下默认禁用显示器保护,因为后台控制器需要自由移动窗口。
// 如需恢复保护,调用 set_window_pos_guard_enabled(true)。
void set_window_pos_guard_enabled(bool enabled) { window_pos_guard_enabled_ = enabled; }

private:
using TrackingClock = std::chrono::steady_clock;
using TrackingDeadlineTicks = TrackingClock::duration::rep;
Expand Down Expand Up @@ -121,6 +125,7 @@ class MessageInput : public RelativeMoveInput
std::atomic_int pending_mouse_y_ = 0;
std::atomic_bool has_pending_mouse_ = false;
std::atomic_bool window_pos_invalid_movement_ = false;
std::atomic_bool window_pos_guard_enabled_ = true;
std::atomic_bool mouse_down_sent_ = false;
std::atomic_int mouse_down_contact_ = 0;
std::atomic_int last_mouse_x_ = 0;
Expand Down
Loading