diff --git a/docs/changelog.md b/docs/changelog.md index b3c4427b..3d2d5223 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -4,10 +4,11 @@ - Polish translation fixed. German, Turkish and Japanese translation updated. French translation added! Thanks to the translation team! - Support of relative folders from command line. +- Support for the mpv option `cursor-autohide` has been added. - A issue with the support of the mpv property `title-bar` has been fixed, at the moment this is most useful for users of the popular uosc user script, the mpv built-in OSC doesn't fully support it yet. -- Set `media-controls=yes`. +- Set `media-controls=yes` by default. # v7.1.1.1 Beta (2024-07-20) diff --git a/docs/manual.md b/docs/manual.md index 797cb413..31a98e59 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -637,6 +637,7 @@ https://mpv.io/manual/master/#window **mpv.net has currently implemented the following window properties:** - [border](https://mpv.io/manual/master/#options-border) +- [cursor-autohide](https://mpv.io/manual/master/#options-cursor-autohide) - [fullscreen](https://mpv.io/manual/master/#options-fullscreen) - [keepaspect-window](https://mpv.io/manual/master/#options-keepaspect-window) - [ontop](https://mpv.io/manual/master/#options-ontop) diff --git a/src/MpvNet.Windows/WinForms/MainForm.Designer.cs b/src/MpvNet.Windows/WinForms/MainForm.Designer.cs index 9d37af5f..abf0c4ed 100644 --- a/src/MpvNet.Windows/WinForms/MainForm.Designer.cs +++ b/src/MpvNet.Windows/WinForms/MainForm.Designer.cs @@ -38,7 +38,7 @@ void InitializeComponent() // CursorTimer // CursorTimer.Enabled = true; - CursorTimer.Interval = 1000; + CursorTimer.Interval = 500; CursorTimer.Tick += CursorTimer_Tick; // // ProgressTimer diff --git a/src/MpvNet.Windows/WinForms/MainForm.cs b/src/MpvNet.Windows/WinForms/MainForm.cs index 86ac38f2..fe7bc608 100644 --- a/src/MpvNet.Windows/WinForms/MainForm.cs +++ b/src/MpvNet.Windows/WinForms/MainForm.cs @@ -38,10 +38,12 @@ public partial class MainForm : Form int _lastCursorChanged; int _lastCycleFullscreen; int _taskbarButtonCreatedMessage; + int _cursorAutohide = 1000; bool _contextMenuIsReady; bool _wasMaximized; bool _maxSizeSet; + bool _isCursorVisible = true; public MainForm() { @@ -68,9 +70,9 @@ public MainForm() Player.Init(Handle, true); - // bool methods not working correctly - Player.ObserveProperty("window-maximized", PropChangeWindowMaximized); - Player.ObserveProperty("window-minimized", PropChangeWindowMinimized); + Player.ObserveProperty("window-maximized", PropChangeWindowMaximized); // bool methods not working correctly + Player.ObserveProperty("window-minimized", PropChangeWindowMinimized); // bool methods not working correctly + Player.ObserveProperty("cursor-autohide", PropChangeCursorAutohide); Player.ObservePropertyBool("border", PropChangeBorder); Player.ObservePropertyBool("fullscreen", PropChangeFullscreen); @@ -1252,8 +1254,7 @@ void CursorTimer_Tick(object sender, EventArgs e) _lastCursorPosition = MousePosition; _lastCursorChanged = Environment.TickCount; } - else if ((Environment.TickCount - _lastCursorChanged > 1500 || - Environment.TickCount - _lastCursorChanged > 5000) && + else if ((Environment.TickCount - _lastCursorChanged > _cursorAutohide) && ClientRectangle.Contains(PointToClient(MousePosition)) && ActiveForm == this && !ContextMenu.IsVisible && !IsMouseInOsc()) @@ -1312,6 +1313,18 @@ void PropChangeWindowMinimized() }); } + void PropChangeCursorAutohide() + { + string strValue = Player.GetPropertyString("cursor-autohide"); + + if (strValue == "no") + _cursorAutohide = 0; + else if (strValue == "always") + _cursorAutohide = -1; + else if (int.TryParse(strValue, out var intValue)) + _cursorAutohide = intValue; + } + void PropChangeBorder(bool enabled) { Player.Border = enabled; @@ -1478,20 +1491,18 @@ protected override void OnKeyDown(KeyEventArgs e) base.OnKeyDown(e); } - static bool _isCursorVisible = true; - - static void ShowCursor() + void ShowCursor() { - if (!_isCursorVisible) + if (!_isCursorVisible && _cursorAutohide != -1) { Cursor.Show(); _isCursorVisible = true; } } - static void HideCursor() + void HideCursor() { - if (_isCursorVisible) + if (_isCursorVisible && _cursorAutohide != 0) { Cursor.Hide(); _isCursorVisible = false;