Skip to content

Conversation

@kaplanelad
Copy link
Contributor

issue: #8385

Implement a new mouse-hide-after duration config that hides the cursor after a period of no mouse movement while keeping it hidden during typing. The core tracks the last mouse move in Surface.cursorPosCallback and uses Surface.maybeHideMouseAfterIdle() to decide when to call hideMouse(). On macOS this is driven by a per-surface NSTimer in SurfaceView_AppKit, and on GTK by a per-surface GLib timeout in class/surface.zig, both reset on mouse movement. macOS uses NSCursor.setHiddenUntilMouseMoves to integrate with the native cursor API, while GTK relies on the existing mouse_visibility action wired through the core surface.

Tests on macos and linux

@kaplanelad kaplanelad requested review from a team as code owners December 17, 2025 07:15
Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

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

Thanks, overall very clean, just one major question.

src/Surface.zig Outdated

/// Hide the mouse if `mouse-hide-after` is configured and the mouse has been
/// idle (no movement) for at least that duration.
pub fn maybeHideMouseAfterIdle(self: *Surface) void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this core stuff at all? I think it might be cleaner to just implement this 100% in the apprt.

@kaplanelad
Copy link
Contributor Author

@mitchellh Thanks for the review! I completely agree and have made the requested changes. hope this aligns with what you expected.

Copy link
Member

@bo2themax bo2themax left a comment

Choose a reason for hiding this comment

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

Looks good on macOS, only a small suggestion

return v;
}

var mouseHideAfter: UInt {
Copy link
Member

Choose a reason for hiding this comment

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

Using Duration is better, like undoTimeout down below

Copy link
Member

@pluiedev pluiedev left a comment

Choose a reason for hiding this comment

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

Looks good overall on the GTK side, just one question

priv.cursor_pos = pos;

// Track mouse movement time for `mouse-hide-after`.
priv.last_mouse_move_time = std.time.Instant.now() catch null;
Copy link
Member

Choose a reason for hiding this comment

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

Is this ever used? I don't think it is, right?

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.

4 participants