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

Conversation

@moko256
Copy link
Contributor

@moko256 moko256 commented Mar 20, 2022

In main branch, the Windows engine sends mouse leave event without setting mouse coords from initial zero value.
It causes that MouseRegion widget receives hover event to coords (0, 0), and exit event with coords (0, 0).

Demo:

import 'package:flutter/material.dart';

void main() {
  runApp(Container(
    color: Colors.red,
    child: MouseRegion(
      onHover: (event) {
        print("hover: ${event.toString()}");
      },
      onExit: (event) {
        print("exit: ${event.toString()}");
      },
    ),
  ));
}

This PR adds sending the coords:

  • When touch input, window_win32 sends given coords.
  • When mouse input, window_win32 stores coords when WM_MOUSEMOVE, and sends its coords when WM_MOUSELEAVE.

This PR will fix flutter/flutter#100213

No changes in flutter/tests repo.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@jnschulze
Copy link
Member

LGTM

@jnschulze jnschulze merged commit 5ec4df6 into flutter:main May 19, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 19, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
* Win32: Send mouse leave event with last position

* reformat code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows Desktop] Mouse events at coordinates (0, 0) are captured when cursor leaves the window.

2 participants