Skip to content

Fixes #4172 Timeout revamp and remove continuous mouse #4173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 46 commits into
base: v2_develop
Choose a base branch
from

Conversation

tznind
Copy link
Collaborator

@tznind tznind commented Jun 21, 2025

This is super set of #4172 and #4123 it adds also the smooth timeout class

smooth

Fixes

Proposed Changes/Todos

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

tznind and others added 30 commits June 3, 2025 19:34
…(old implementation of WantContinuousButtonPressed)
…on firing twice immediately as mouse is pressed down.
@tznind tznind marked this pull request as ready for review June 21, 2025 08:16
@tznind tznind requested a review from tig as a code owner June 21, 2025 08:16
@tznind tznind changed the title Logarithmic timeout Timeout revamp and remove continuous mouse Jun 21, 2025
@tznind tznind changed the title Timeout revamp and remove continuous mouse Fixes #4172 Timeout revamp and remove continuous mouse Jun 21, 2025
Copy link
Collaborator

@tig tig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is awesome.

I'm thinking about it. Makes me wonder if my naming of MouseState makes sense.

Perhaps it should'v been MousePressStates as it really only is relevenant when the mouse is pressed???

Copy link
Collaborator

@tig tig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am so in love with this PR.

Please see my comments. Mostly about naming stuff.

I made some signifcant changes to the mouse event handling in

to address related bugs that may or may not make merging this difficult.

I'm more than happy to try to deal with that. Or, if you are motivated, please merge #4165 into this first. Just let me know your preference.

Thanks.

public View? MouseGrabView { get; }

/// <summary>Invoked when a view wants to grab the mouse; can be canceled.</summary>
public event EventHandler<GrabMouseEventArgs>? GrabbingMouse;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these events should be "MouseGrabViewChanging" and "MouseGrabViewChanged".

No need for the "Un" versions (if MouseGrabView is null...).

What do you think?

/// is called.
/// </summary>
/// <param name="view">View that will receive all mouse events until <see cref="UngrabMouse"/> is invoked.</param>
public void GrabMouse (View? view);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this were Set (View? view) we could nuke the UnGrab() method, simplifying the surface area?

/// Runs all idle hooks
/// </summary>
void LockAndRunIdles ();

/// <summary>
/// Runs all timeouts that are due
/// </summary>
void LockAndRunTimers ();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "Lock" really needed in the name of this function?

@@ -44,6 +21,9 @@ public interface ITimedEvents
/// </remarks>
object AddTimeout (TimeSpan time, Func<bool> callback);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Timeout" in AddTimeout is superfluous, now right? This and RemoveTimeout can be just Add and Remove?

/// <see langword="false"/>
/// if the idle handler is not found.</returns>
bool RemoveIdle (Func<bool> fnTrue);

/// <summary>
/// Invoked when a new timeout is added. To be used in the case when
/// <see cref="Application.EndAfterFirstIteration"/> is <see langword="true"/>.
/// </summary>
event EventHandler<TimeoutEventArgs>? TimeoutAdded;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added?

/// there are no active timers.
/// </param>
/// <returns><see langword="true"/> if there is a timer active.</returns>
bool CheckTimers (out int waitTimeout);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check?

@@ -32,15 +32,15 @@ internal interface IMainLoopDriver
void Wakeup ();
}

/// <summary>The MainLoop monitors timers and idle handlers.</summary>
/// <summary>The MainLoop monitors timers handlers.</summary>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timers->timer

@@ -32,15 +32,15 @@ internal interface IMainLoopDriver
void Wakeup ();
}

/// <summary>The MainLoop monitors timers and idle handlers.</summary>
/// <summary>The MainLoop monitors timers handlers.</summary>
/// <remarks>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This remarks i no longer needed.

/// <summary>
/// <para>
/// Handler for raising periodic events while the mouse is held down.
/// Typically, mouse pointer only needs to be pressed down in a view
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pointer->button

@BDisp
Copy link
Collaborator

BDisp commented Jun 24, 2025

I'm more than happy to try to deal with that. Or, if you are motivated, please merge #4165 into this first. Just let me know your preference.

Why not just merge #4165 it into the v2_develop?

@tig
Copy link
Collaborator

tig commented Jun 24, 2025

I'm more than happy to try to deal with that. Or, if you are motivated, please merge #4165 into this first. Just let me know your preference.

Why not just merge #4165 it into the v2_develop?

because #4165 is not really ready.

@BDisp
Copy link
Collaborator

BDisp commented Jun 24, 2025

because #4165 is not really ready.

I didn't realize it was still failing, because it never failed me again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Idles are just timeouts with Timespan.Zero v2win/v2net - WantContinuousButtonPressed does not repeat.
3 participants