Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a759e94

Browse files
authored
[Windows] Set cursor immediately when framework requests update (#49784)
On Windows, when using a `MouseRegion` widget to change the cursor it is not actually updated until the cursor is moved. This is because the Windows embedder only updates the `current_cursor_` field but does not actually set the cursor until the window receives the `WM_SETCURSOR` message when the mouse moves. This change makes it set the cursor immediately. Fixes flutter/flutter#76622
1 parent e8213ab commit a759e94

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

shell/platform/windows/flutter_window.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ PhysicalWindowBounds FlutterWindow::GetPhysicalWindowBounds() {
173173
}
174174

175175
void FlutterWindow::UpdateFlutterCursor(const std::string& cursor_name) {
176-
current_cursor_ = GetCursorByName(cursor_name);
176+
SetFlutterCursor(GetCursorByName(cursor_name));
177177
}
178178

179179
void FlutterWindow::SetFlutterCursor(HCURSOR cursor) {

shell/platform/windows/flutter_window_unittests.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,5 +435,12 @@ TEST(FlutterWindowTest, PosthumousWindowMessage) {
435435
EXPECT_GE(msg_count, 1);
436436
}
437437

438+
TEST(FlutterWindowTest, UpdateCursor) {
439+
FlutterWindow win32window(100, 100);
440+
win32window.UpdateFlutterCursor("text");
441+
HCURSOR cursor = ::GetCursor();
442+
EXPECT_EQ(cursor, ::LoadCursor(nullptr, IDC_IBEAM));
443+
}
444+
438445
} // namespace testing
439446
} // namespace flutter

0 commit comments

Comments
 (0)