Closed abdelaziz-mahdy closed 2 days ago
Currently, I'm unable to test this functionality on Windows. The only workaround I can propose, particularly if the hiding of the mouse cursor requires movement, involves setting a threshold of ignored pixel movement. Specifically, this would mean:
Ignoring a certain number of pixels: The mouse cursor would be hidden unless the movement exceeds a predefined number of pixels. This is to ensure that minor, unintentional cursor movements don't disrupt the viewing experience.
Showing controls upon exceeding the threshold: If the user's cursor movement exceeds this set threshold, the video controls would reappear, allowing for user interaction.
This approach aims to balance between providing a clean, uninterrupted view and ensuring that the controls are accessible when genuinely needed by the user.
let me know if that is good, and if the functionally works on windows and linux
import 'package:win32/win32.dart';
import 'package:win32/win32.dart' as win32;
import 'dart:ffi';
import 'package:ffi/ffi.dart';
Timer(const Duration(milliseconds: 100), () {
Pointer<POINT> point = malloc();
win32.GetCursorPos(point);
win32.SetCursorPos(point.ref.x, point.ref.y);
free(point);
});
something i found online https://stackoverflow.com/questions/74963577/how-to-hide-mouse-cursor-in-flutter
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:win32/win32.dart';
import 'package:win32/win32.dart' as win32;
import 'dart:ffi';
import 'package:ffi/ffi.dart';
class EnhancedMouseRegion extends StatefulWidget {
final Function(PointerEnterEvent)? onEnter;
final Function(PointerExitEvent)? onExit;
final Function(PointerHoverEvent)? onHover;
final MouseCursor cursor;
final bool opaque;
final HitTestBehavior? hitTestBehavior;
final Widget? child;
const EnhancedMouseRegion({
super.key,
this.onEnter,
this.onExit,
this.onHover,
this.cursor = MouseCursor.defer,
this.opaque = true,
this.hitTestBehavior,
this.child,
});
@override
State<EnhancedMouseRegion> createState() => _EnhancedMouseRegionState();
}
class _EnhancedMouseRegionState extends State<EnhancedMouseRegion> {
MouseCursor? lastCursor;
@override
Widget build(BuildContext context) {
if (lastCursor != widget.cursor) {
Timer(const Duration(milliseconds: 100), () {
Pointer<POINT> point = malloc();
win32.GetCursorPos(point);
win32.SetCursorPos(point.ref.x, point.ref.y);
free(point);
});
}
lastCursor = widget.cursor;
return MouseRegion(
onEnter: widget.onEnter,
onExit: widget.onExit,
onHover: widget.onHover,
cursor: widget.cursor,
opaque: widget.opaque,
hitTestBehavior: widget.hitTestBehavior,
child: widget.child,
);
}
}
it may work. @abdelaziz-mahdy
Thank you for work around, but letting you know https://github.com/flutter/engine/commit/a759e94cee04d5878b164c8f91d4ef22bdaa552d Pushed a fix for the windows problem which should be in the next release of flutter
感谢您的解决方案,但让您知道 flutter/engine@ a759e94 推送了 Windows 问题的修复程序,该修复程序应该在下一版本的 flutter 中
This is really good news, no more having to monitor the mouse all the time. Causing unnecessary waste of performance.
nice👌👍
Add Feature to Hide Mouse on Controls Removal
Overview
This pull request introduces a new feature to the
MaterialDesktopVideoControlsThemeData
in thematerial_desktop.dart
file of themedia_kit_video_controls
library. The primary addition is thehideMouseOnControlsRemoval
property.Changes
hideMouseOnControlsRemoval
true
, will hide the mouse cursor when the video controls are removed. This feature enhances the user experience by providing a cleaner view, especially useful in a full-screen video context.false
to maintain backward compatibility and avoid altering the current behavior for existing users.Usage
Users can now opt to hide the mouse cursor when the video controls are removed by setting the
hideMouseOnControlsRemoval
flag in theMaterialDesktopVideoControlsThemeData
constructor.Example: