Repository navigation
Dapplo.Windows 3.12.2
Small efficiency and API fixes, found while reviewing 3.11.2 for Greenshot.
Added
ToForegroundAsync(cancellationToken): the token is checked at the start and while waiting for a minimized window to restore (OperationCanceledException). It still returns aValueTask, most calls complete without waiting or allocating. The wait is measured with aStopwatchinstead ofDateTime.UtcNow. After a wait the foreground switch runs on a thread-pool thread (as before),AttachThreadInputworks from there.
Changed
IsVisibleApplicationWindowandIsVisiblePopupcheck cheapest first:IsWindowVisible, then the class name of the ignored classes (GetClassName), then the cloak check (DwmGetWindowAttribute). Most top-level windows are invisible, so an enumeration no longer asks the class name of every top-level window, only of the visible ones. The cloak check was already only made for windows withWS_VISIBLE, it is now also skipped for visible windows with an ignored class (e.g.Progman). The cachedIsVisiblekeeps its meaning (visible and not cloaked).GetParentuses the style of a cachedWindowInfoinstead of readingGWL_STYLEagain (unlessforceUpdate);IsVisibleApplicationWindowandIsVisiblePopupread the info right before.User32Api.GetTextandGetInternalTextread captions up to 255 characters into a buffer on the stack, only longer captions allocate a buffer. The full length is still supported.