Skip to content

macOS: Window::Hide()/Show() play AppKit's fade-and-shrink animation #82

Done

Description

@lijy91

Problem

On macOS, Window::Hide() calls orderOut:, and AppKit plays its fade-and-shrink animation for document windows (NSWindow.animationBehavior == .default). Showing can animate in the same way.

For a region screenshot the app hides its own window, captures the display, then shows a full-display overlay. The animation is visible: we recorded it at 60 fps and saw several frames of the window shrinking and fading before the overlay appears. It can also leave a ghost of the window in the captured frame if the capture starts too early. Electron's hide() is instant, as is Window::Hide() on Windows.

The Flutter screen-capture example (PR #75) works around it in MainFlutterWindow.swift with a hideForCapture method channel. Before hiding, it sets animationBehavior = .none and sets alphaValue = 0 inside a CATransaction with actions disabled. When the window comes back, it restores the original animationBehavior.

Proposal

Pick one direction:

  1. Make Hide() / Show() / ShowInactive() instant on macOS: no AppKit window animation, matching the other platforms. This changes current behaviour; note it in the CHANGELOG.
  2. Add an explicit toggle, e.g. void Window::SetAnimationsEnabled(bool is_enabled) / bool AreAnimationsEnabled() const. On macOS it maps to NSWindowAnimationBehaviorNone / Default; on Windows to DWMWA_TRANSITIONS_FORCEDISABLED; elsewhere it is recorded only.

Option 1 is simpler and matches what users expect from Hide(); option 2 keeps today's default.

Acceptance

From Dart, window.hide() removes the window from screen within one frame on macOS: no fade or shrink frames in a 60 fps recording. This must work without a custom MainFlutterWindow.swift.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions