Commit Graph

4076 Commits

Author SHA1 Message Date
Leonard Hecker
f6de9e0618 Fix a VT mouse release bug in #20756 (#20914)
I broke #20756 with a refactor.
This diff makes the issue fairly obvious.

Closes #20630
2026-11-11 18:58:49 +00:00
Leonard Hecker
5f7dc28301 Can we have infinite scrollback? (#18290)
Mom: We have infinite scrollback at home.
Infinite scrollback at home:

...very much finite. How do you define "infinite" scrollback anyway?
Does it entail downloading RAM? It's a mystery. So, this PR adds support
for 1B rows of scrollback, because that's >600GB of memory, which makes
it effectively unusable. But it's enough to have a lot of finity.

Thanks to the raised limit, this PR sets the default history size from
to 16Ki which is roughly 10MB of memory. The can be cut in half once we
remove the charOffsets cache on each ROW.

Related to #1410

## Validation Steps Performed
* Set scrollback to 1M lines
* Dump 100MB of text and watch the RSS grow
* Reflow the window (it lags a little) ✅
* Clear the buffer (it's fast) ✅
2026-11-09 22:32:21 +01:00
Leonard Hecker
cbc857bdf7 Decommit memory on cls (#20889)
While the changes are complex, they are straightforward,
except for one bit: The complete refactor of `ScrollRows`.

The reason it became necessary is that moving the viewport to the top
during `ClearScrollback` may wrap the source range across the buffer's
end. VT/conhost scrolling keeps src/dst ranges within logical bounds,
where choosing the copy direction is sufficient.

For instance: Imagine we have physical rows `A B C` and I call
`ScrollRows(2, 2, -2)` then this should result in `C, A, C`.
However, the old logic would produce `C C C`, because it copies
`2 (C) -> 0 (A)` and then `0 (A) -> 1 (B)`. By the time the 2nd copy
runs, the contents of row A have already been overwritten by C.

This is the classic difference between a `memmove` and a `scroll array`.
`ScrollRows` has never been an actual scroll function. The name stems
more from `ScrollConsoleScreenBuffer`, which turn refers to historical
bit blit scrolling.

Part of #18290

## Validation Steps Performed
* `cls` = memory use 📉
2026-11-07 00:21:25 +01:00
Dustin L. Howett
188822fa51 Localization Updates - resize overlay - 23:44:03 (#20869)
Follows #20861.

Co-authored-by: Console Service Bot <consvc@microsoft.com>
2026-11-02 12:52:10 -06:00
Mike Griese
f472aa97c1 Fix the useAcrylicInTabRow flicker (#20881)
This PR fixes the flicker in the tab row when you've got:

```jsonc
{
    "showTabsInTitlebar": true,
    "useAcrylicInTabRow": true,
    "compatibility.enableUnfocusedAcrylic": true,

    "profiles": {
        "defaults": {
            "useAcrylic": true,
            "opacity": 80
        }
    }
}
```

For historical reference:
- #10864
- merged **August 23, 2021.** Added `useAcrylicInTabRow`, with a
separate tab-row brush hardcoded to `HostBackdrop`.
- #11180
- merged **September 20, 2021.** Added transparent window backgrounds.
This removed the XAML opaque backstop and enabled the later in-app
acrylic approach.
- #15923
- merged **September 7, 2023.** Added
`compatibility.enableUnfocusedAcrylic`, defaulting to true, and switched
`TermControl` to `Backdrop`. **It did not update the separate tab-row
brush in `TerminalPage`**. This is when the bug showed up.

We don't need a HWND to bounce foreground off of.
We don't need to recycle brushes.

We just need to know that we now support both HostBackdrop acrylic, XOR
in-app Backdrop acrylic, and make sure to not try to use both at the
same time.

Closes #14384
Closes #20316
Closes #20293
Closes #19705

I'm out.
2026-11-02 11:35:54 -06:00
Clint Rutkas
703ef7f969 Settings: make clickable SettingsCards support UIA Invoke (#20871)
Caught while investigating something else.

ButtonBase does not provide UIA access to the `Invoke` pattern.

This PR moves SettingsCard to build on `Button` instead so that UIA can
`Invoke` it.
2026-10-30 14:48:47 -05:00
Clint Rutkas
95142e6ebf Wrap Settings delete confirmation flyouts instead of scrolling horizontally (#20868)
We were clipping a flyout at 200% scalling. here is before and after
screenshots. This affected a few other spots and we caught those.

Closes #20577
2026-10-30 00:59:52 +00:00
Leonard Hecker
ff3fb7b423 Conhost font sizing for AtlasEngine (#19905)
This PR does 3 things:
* Provide a way to combine AtlasEngine's support for font sizes with
  GdiEngine's use of cell sizes (it doesn't support font sizes at all)
* Fix the DIP roundtrip issues in conhost due to float -> int casts
* Fix the roundtrip issues due to desired font -> actual font
  -> desired font feedback loops; it now uses the desired font
  permanently for settings, DPI changes, etc

Breaking changes:
* `GetCurrentConsoleFont(Ex)` now report the desired (configured)
  font settings instead of the actual ones. This better matches
  modern behavior with font fallback etc. I expect this to break
  some applications, although I cannot imagine why it would.
* TrueType fonts won't store a width value in the registry anymore

Totally works. Just trust me bro.

This PR doesn't yet include the logic to hook it up to Windows Terminal.
It's just for that new inbox conhost renderer. Huh what? Who said that!

## Validation Steps Performed
* Settings store X=0 for TrueType font sizes ⚠️ (intentional!)
* Ctrl+Scroll font sizing tracks GdiEngine relatively closely ✅
* Probably? Fixes all of the conhost font size roundtrip issues ✅
2026-10-30 00:45:03 +01:00
Leonard Hecker
533408607a Add support for UTF8 encoded file URIs (#20809)
Aside from illegally using `URL_UNESCAPE_AS_UTF8`, this PR fixes:
* `get_strong` for the async `_OpenHyperlinkHandler`
* `PATHEXT=".exe;;.bat"` would allow any file, because
  `""` is the suffix of any string
* `SEE_MASK_FLAG_NO_UI` + error handling for `ShellExecute`

``"`e]8;;file:///C:/../%E4%B8%AD%E6%96%87.txt`alink`e]8;;`a"``
will now open by clicking on the link (if `中文.txt` exists).

If it doesn't exist, you'll now see a nice "The system
cannot find the file specified." error dialog.

Closes #20803
2026-10-29 19:13:47 +01:00
Nakul
09beddc623 Allow users to disable the new resize indicator (#20861)
Adds a `showResizeOverlay` setting so the size overlay shown
while resizing can be turned off. It's on by default, and there's a
toggle for it on the Interaction page in the settings UI.

Closes #20694
2026-10-28 23:56:08 +00:00
Leonard Hecker
f3560938b2 Prevent ConPTY from mangling newlines after LNM (#20863)
The reason the repro works is because `printf` does line buffering.
So, `echo -e '\e[20h\n\e[20lone\ntwo\nthree'` enables LNM and flushes.
Then, the next chunk starts with `disableNewlineTranslation = false`
from the previous write. Even if this chunk disables LNM, ConPTY
still used to translate `one\n` to `one\r\n`.

Closes #20845
2026-10-28 15:14:11 +01:00
Leonard Hecker
c91793f7dc Fix a WriteCharsLegacy deadlock (#20862)
The line wrapping check was busted. This new code
is a 1:1 copy from `AdaptDispatch::_WriteToBuffer`.

Closes #20693
2026-10-27 22:58:39 +00:00
Dustin L. Howett
b69f4c623b Localization Updates - Drag/Drop Tabs (#20844)
Followup to #20394

Co-authored-by: Console Service Bot <consvc@microsoft.com>
2026-10-27 11:33:09 -05:00
Mike Griese
a65cafae07 Don't repositionCursorWithMouse while in Output (#20852)
Welp this is kinda obvious in retrospect. 

The current check only checks that the cursor is after the last mark's
`end`, which really only ensures that it's after a `Prompt`. It doesn't
at all check that it's within a `Command`. If you have a bunch of
output, well, that's all _after the prompt_.

The braindead simple solution is just to make sure we only do the arrow
key handling when we're actually in the `Command` state. We can't check
that we're inside of the end of the command at this point, because we
don't have that mark yet.

Fixes #20846
Fixes #17803

----

* Original implementation: #15758
* Mark-storage rewrite: #16937
* Follow-up fix: #17141
2026-10-26 17:27:51 -05:00
Ivan Pešić
2c65c836fe Update sr-Cyrl-RS localization (#20851)
Here is an update of the Serbian localization.
2026-10-26 17:25:26 -05:00
Dustin L. Howett
98c8c795eb Reject OSC titles longer than 1000 characters, like xterm (#20839)
I know that this seems short, but like. One thousand characters. In a
title.

Xterm (which I checked at version 398) rejects requests to set a title
this long _outright,_ and does not truncate or elide any part of it.

Closes #20838
2026-10-23 13:25:45 +02:00
Huang-404-Q
a4bb4756fc Prevent repeated alt buffer sequences from using the wrong size (#20825)
`UseAlternateScreenBuffer` set the size of the new alt buffer from
`_mutableViewport` (from the main buffer). Resizing while the alt buffer
was open and requesting it again (which is already somewhat strange and
should be a no-op...) would use the old size.

Closes #20820
2026-10-23 03:55:19 +00:00
Leonard Hecker
21d1f1e617 Fix several scrollbar issues in conhost (#20824)
- Closes #19585, by always tracking the main buffer for scrollbar state,
  instead of letting `SIF_DISABLENOSCROLL` track it implicitly
- Optimized scrollbar state on startup by setting its visibility eagerly
- Fixed a transient full-height thumb on return from the alt buffer

And a real zinger (decade old bug, basically):
- Fixed a bug where the alt buffer doesn't resize if its size matches
  the main buffer (technically unrelated to scrollbars)
2026-10-22 22:27:01 -05:00
Dustin L. Howett
10630264af ci: run the Any CPU, WPF, ConPTY and MSIX bundle builds in CI (#20835) 2026-10-22 14:07:09 +00:00
Dustin L. Howett
1046205b04 Rewrite HwndTerminal to build on ControlInteractivity and -Core (#20812)
This pull request replaces all of HwndTerminal, which used to be a thin
layer on top of TerminalCore.lib, with a new implementation that relies
on the Interactivity and Core layers in TerminalControl.lib.

We used to spend a lot of time reimplementing interactivity components
for HwndTerminal or--if I'm being honest--letting it rot and never
giving it the improvements the rest of the application got.

Among those improvements:

- Automatic scrolling finally works (as of #20710)
- Selection works the same way as it does in Terminal proper (starts on
  the half-cell, uses an exclusive range)
- Consistent double- and triple-click behavior without having to
  reimplement word- and line-wise expansion
- Scroll wheel behavior
- Shift+Click to suppress VT mouse mode
- Scrolling and focus handling move down into the Win32 message loop
  from WPF

This pull request seeks to get HwndTerminal back to where it was (plus
the things we naturally get from switching over). In the future, we can
more easily add:

- title reporting (surprised we didn't have this)
- clickable URLs
- automatic copy-to-clipboard
- right-click menu support
- DTTERM window manipulation
- shaders
- Ctrl+Scroll zoom

Implementation Details
----------------------

The WPF control is backed by a flat "C" API, which takes in a `void*`
and does some stuff to it. We call that a `PTERM`. References to "Flat
C" in this commit body describe the body of work below WPF.

X-macros are used to fill out the definintions of every C API and bridge
it to a properly typed C++ member function. Ugh. No more crap where we
split the implementation into half C export and half C++ member.

ControlCore and ControlInteractivity require something that looks like
TerminalSettings. The WPF control only supports the most basic settings,
in `struct TerminalTheme`, and so I've added a bridge WinRT type to
adapt TerminalTheme to
IXxxSettings. Most of the values it returns are our "defaults", and some
of them are overridden.

Core requires an `ITerminalConnection`, but the WPF API uses a pair of
"write output" and "send input" callbacks. Flat C provides an
ITerminalConnection that bridges those callbacks. It does not
communicate connection state or anything else. Resizing is probably
going to be a problem.

Core requires a dispatcher queue to ensure that some operations happen
on the UI thread. I have stubbed out an implementation of
`IDispatcherQueue` that calls a couple function pointers with a context
pointer; the WPF code hooks up to that and bridges it into the WPF
dispatcher. Yes, the Core's dispatcher queue _is_ the WPF main UI
thread. It has to be, otherwise we'll explode the first time we try to
update the scroll bar. Prep work was done in #20713.

To make the above easier, I removed all use of DispatcherTimer (see
#20711). Attempts to use it will almost certainly cause the WPF control
to implode.

Core needed to be taught a couple tricks to start up targeting an HWND
instead of a composition handle. See #20722 for more.

Refs #20710
Refs #20711
Refs #20713
Refs #20722

Required #20721
Refs #20745

Related to #6999
2026-10-20 18:53:23 -05:00
Clint Dovholuk
9e6cf223dd Add a setting to disable drag/drop (#20394)
adds "interaction" setting to allow enable/disable of tab
drag/drop/rearrange/tear

Refs #15689

## Validation Steps Performed
- ran as "clint" and verified the interaction setting can be toggled on
and drag/drop/tear works, and toggled off where it doesn't (gifs of both
at the end)
2026-10-19 17:17:23 -05:00
Dustin L. Howett
bba4b4b9d8 build: move the code format leg to VS 2026 (#20821)
This should resolve the issue where we keep having to locally revert the
`->` change.
2026-10-19 13:58:31 -05:00
Dustin L. Howett
6967ba1c07 Allow the ScopedResourceLoader to load up without resources (#20811)
Okay, so this is a very niche case.

We want to light up TermControl in places where we cannot be certain
there is a resources.pri.

In Debug builds, we load up and check that all referenced resources are
present. In Release, we don't.

This prevents us from failing on startup when resources.pri is
unavailable. _However,_ any code that tries to resolve a resource will
crash later.

This is taken as an acceptable risk, because it reveals programmer
error.

This will cause issues in the future if we want to add resource uses to
the Core or Interactivity layers[^1].

In the future, we should either use MRT core (ew) or switch to MUI (ew)
or do something else entirely for resources.

[^1]: we have some right now, but they are only actually referenced by
the XAML layer
2026-10-19 16:32:56 +00:00
Shrikar
6ec7b6561f Don't encode a VK of 65535 when a key is unmapped by the current layout (#20800)
Prevents us from incorrectly encoding `65535` into an input record when
a character has no virtual key mapping in the active keyboard layout.

- `VkKeyScanW` returns a signed `SHORT` `-1` on failure when the
  character does not exist in the active keyboard layout).
- When injected characters without key-down/scan-code information (e.g.
  via VNC or remote inputs) passed through `SendCharEvent`, this caused
  .NET `Console.ReadKey()` to throw an unhandled
  `System.ArgumentOutOfRangeException: Console key values must be
  between 0 and 255 inclusive.` and crash PowerShell.

Closes #20797
2026-10-19 16:01:32 +00:00
PankajBhojwani
9fd41b2bae Fix settings search for check box labels, add indexer properties (#20808)
We have a bunch of edge cases in our settings that had to have manual
accounting for in the settings search index or weren't being handled at
all (controls being wrapped in stack panels, settings that shouldn't
show up in the defaults profile but should for regular profiles, etc).

This PR adds an xml namespace (which gets ignored at compile time) just
for the purpose of telling our index generating script how various
control elements should be treated.

One of those properties is used to indicate which check box contains the
label for a stack panel.
2026-10-16 18:25:33 -05:00
Dustin L. Howett
1e788820e0 Fix OS build after ingesting e90f9a534c (!17124121) (#20801)
This also updates the git2git filter.
2026-10-13 17:59:57 +00:00
Dustin L. Howett
e90f9a534c Banish the new Serialization slop test to the nega-verse (#20794) 2026-10-12 20:12:55 +00:00
Clint Rutkas
0edb684b0c Migrate warning.confirmCloseAllTabs to warning.confirmOnClose (#20783)
#20055 only migrated the old `confirmCloseAllTabs` key, but since #17933
we've written `warning.confirmCloseAllTabs`, so on 1.26 users who turned
the close warning off get the dialog back. This migrates both names
(`warning.confirmOnClose` still wins) and stops a `null` value from
throwing and failing the whole settings load. Adds a regression test;
SettingsModel tests pass (159/159).
2026-10-12 18:23:46 +00:00
Windows Console Service Bot
6676c6f938 Localization Updates - experimental badge - 10/07/2026 03:04:58 (#20775)
Co-authored-by: Console Service Bot <consvc@microsoft.com>
2026-10-08 03:46:25 +00:00
Dustin L. Howett
099afa48ed cooked: properly tear down popups when we fail to parse user input (#20779)
Throwing an exception all the way out of COOKED_READ_DATA::Read is
deleterious for the health of the application. We fail to unbind the
waiter and may leave a dangling pointer around for some applications
(and for some NPC security researchers to think provides an EoP, but
does not.)

This also moves us away from std::stoi in the history pop-up path
entirely.
2026-10-08 01:17:13 +02:00
Leonard Hecker
5951f69654 Fix several ScrollConsoleScreenBuffer ConPTY issues (#20774)
- Fixed #20772 by fully committing to lazy DA1 capabilities path via
  `VtIo::SetDeviceAttributes`. It accidentally only did so with enabled
  cursor inheritance before.
- Fixed #20773 by fixing the source/destination rectangle alignment
  in the non-DECCRA path of `ScrollConsoleScreenBuffer`.

Also closes MSFT-64450466.

As a drive-by:
- Fixed the DECCRA path not restoring cursor attributes in conhost.
- Reduced memory use in the non-DECCRA path.
- Added a `IL/DL` sequence fast-pass for `ScrollConsoleScreenBuffer`.
- Fixed a broken bounds checks in `Read/WriteConsoleOutputWImplHelper`.
- Fixed the TraceLogging definition for `SMALL_RECT`.
2026-10-08 01:16:58 +02:00
Dustin L. Howett
767f832d26 Remove ControlInteractivity and ControlCore from TermControl API (#20745)
Consumers have no need to know about these, and can instead deal with a
new opaque `IContentHandle`. Exposing them offered too much latitude to
do the "wrong thing" with TermControl's constituent types. Even _if_ we
were doing something cross-process, the upper layer doesn't need to use
our implementation details.

In doing this, I've also removed the unused Content::Attached event.
2026-10-07 23:12:45 +00:00
TheJesper
aba31713b5 Preserve ENHANCED_KEY for direct key events (Alt up, F7 down) (#20619)
Our window message intercepts Alt key-up (and F7 key-down) to handle
them before XAML messes them up. These events get forwarded through
IDirectKeyListener, but the ENHANCED_KEY bit from `lParam` was being
lost.

Verified manually.

Closes #18120
2026-10-07 23:11:16 +00:00
Dustin L. Howett
d2fac6ef8b Go back to using implementation types in TermControl (#20721)
This reverts a large part of #10051 and moves us back to using the
native `implementation`-namespace types from TermControl to talk to
ControlInteractivity and ControlCore.

I started down this rabbit hole because I was trying to get rid of
InteractivityAutomationPeer, and I learned that we introduced it as a
go-between for the process-split TermControl/Interactivity.

InteractviityAutomationPeer is not required, and removing it lets us get
rid of some other mild annoyances:

- We don't need to _push_ the bounds of the control down into
Interactivity any longer
- Likewise for padding

Bounds and padding can simply be read directly from the control.

I also undid the move from HANDLE to uint64_t which was only required
for projecting HANDLEs.

The only thing we risked losing out on was automatic event revokers, but
this pull request adds `winrt::auto_revoke` support directly to
`til::event`. It is suitably terrifying. It is certainly UB.
2026-10-07 17:32:55 -05:00
Leonard Hecker
2d417e4eda Minor improvements to til::parse_(un)signed (#20778)
* Allow an explicit `+` prefix like other parsers
* Reject invalid bases
* Fix UB during `uint64_t` -> `T` cast in `parse_signed`
2026-10-07 17:27:02 -05:00
PankajBhojwani
35f29bd316 Add an experimental badge in the SUI for experimental settings (#20748)
For experimental settings, display a bright yellow badge next to it. So,
as part of this, removed "experimental" from the descriptions since the
badge is indicating that already.

Closes #20687
2026-10-06 12:57:21 -05:00
Leonard Hecker
b7752edc52 Restore KKP flags when disabling ASB (#20768)
`_kittyFlags` represents the current buffer flags. When you enable the
ASB, we reset `_kittyFlags` to 0. When you disable the ASB, we restore
the flags from the `_kittyMainStack`. Boom, broken. We never pushed
anything into the `_kittyMainStack` in the first place.

The gets rid of `_kittyFlags`. To make it neat, I also replaced
the heap vector with a static array + length.

Closes #20763
2026-10-06 12:56:34 -05:00
Leonard Hecker
72e7b0630c Avoid loading keyboard layouts for KKP US mappings (#20769)
Replaces `LoadKeyboardLayoutW` with a static LUT.
No more random US keyboards in your language picker.

Closes #20761
2026-10-06 16:31:19 +02:00
PankajBhojwani
805068781c Add automation name for the delete shortcut button (#20767)
It didn't have one before, so screen readers were just reading out
"button". This commit fixes that, screen readers now read out "delete
shortcut button"

Closes #20601
2026-10-05 23:53:17 +00:00
OmarMashal
159bda66f6 Suppress VT mouse release for Ctrl+click on OSC 8 hyperlinks (#20756)
Fixes the unmatched VT mouse release sent when Ctrl+clicking an OSC 8
hyperlink.

Closes #20630

Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
2026-10-05 23:28:55 +00:00
Windows Console Service Bot
2b5336c1fc Localization Updates - main - 09/30/2026 21:12:36 (#20752)
Co-authored-by: Console Service Bot <consvc@microsoft.com>
2026-09-30 21:53:17 +00:00
Dustin L. Howett
e289c45d96 Revert "Fix PGO tests (#20560)" (#20750)
This reverts commit 1507c46524.

The root cause of the PGO failure is documented in #20749. Also, the PR
#20560 didn't actually _fix_ them. :P

Note that this DOES NOT FIX the PGO build.
2026-09-30 15:16:20 -05:00
Sebastien Tardif
4e2b8bd926 Only open File Explorer from OpenCWD when CWD is a real directory (#20697)
OpenCWD now no-ops unless the terminal working directory is an existing
directory, then opens that folder. It no longer passes the raw OSC
string to `explorer.exe` as parameters.

Refs #12859 (the original action asked to do nothing when no CWD is set)

OpenCWD was introduced in #18013.

`ControlCore::OpenCWD` is the command-palette action `Terminal.OpenCWD`.
It used:

```cpp
ShellExecute(nullptr, nullptr, L"explorer", workingDirectory.c_str(), nullptr, SW_SHOW);
```

The working-directory string comes from OSC 7 (`file:` URI, then
`PathCreateFromUrlW`) or OSC 9;9. Both only require
`til::is_legal_path`, which allows `:` and `/`. So a remote host can set
CWD to `https://example.com`, `shell:...`, or `/select,...`. Invoking
Open CWD then ran Explorer with that text as `lpParameters`.

Duplicate-tab and related paths already call `Utils::IsValidDirectory`
before trusting this string (`TerminalPage.cpp`,
`TerminalPaneContent.cpp`). Open CWD now does the same, then
`ShellExecute`s the directory path as `lpFile` so Explorer switches
cannot be supplied as parameters.

If the CWD is empty or not a directory, the action does nothing.
2026-09-30 00:14:35 +00:00
Dustin L. Howett
a3c89e64a4 Move AutoScroll down into Interactivity with a render timer (#20710)
This pull request builds on the render timer infrastructure in #19330
and the pointer ID work in #20017 to move automatic scrolling down into
the Interactivity layer.

Leonard tells me that this is an acceptable use of the render timer
infrastructure because it directly results in a new frame or new content
being rendered (therefore, it does not spin the renderer for no reason.)

Much of the code is the same. I recommend reviewing with:

```
git diff --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space (git merge-base origin/main origin/dev/duhowett/wpf-1-autoscroll-to-interactivity) origin/dev/duhowett/wpf-1-autoscroll-to-interactivity
```
2026-09-29 18:39:10 -05:00
PankajBhojwani
456c3a8ce8 Display reason for launch at login setting being disabled by OS setting (#20743)
Closes #20685
2026-09-29 22:09:47 +00:00
OmarMashal
8f2412ae33 Always open duplicated tabs next to source tab (#20565)
Closes #20355

Co-authored-by: Leonard Hecker <lhecker@microsoft.com>
2026-09-29 13:46:46 -05:00
Leonard Hecker
0626dc1457 Fix 5s lags when using OSC 52 clipboard copy (#20728)
Hilarious repro: `printf "\e]0;A\a\e]52;c;Qg==\a"`

This issue is exactly what happens when you Ctrl+X in a clean file in
msedit and it freezes Windows Terminal. It's because it puts a "•" in
the title and copies the text.

It triggers a title and clipboard change in the same frame which causes
the UI and VT thread to deadlock trying to get the console lock.
2026-09-28 15:11:15 +00:00
Dustin L. Howett
bb0541e7a9 Move MIDI audio timer off Dispatcher to a threadpool (#20711)
The MIDI audio cancellation handler doesn't really need to run on the UI
thread, and this breaks our dependency on DispatcherTimer.
2026-09-27 01:52:30 +02:00
Leonard Hecker
fda72a0709 Fix several Present issues in AtlasEngine (#20723)
* D3D uses deferred execution where render commands are collected as
  descriptors in a ring buffer before they're sent off to the GPU.
  When you don't call `Flush()` (or `Present()` which implies `Flush()`)
  it'll fill up 100s of MB of memory rapidly.
  This PR solves it in two ways:
  * Call `Flush()` whenever we can't call `Present()`
  * Make calling `Flush()` unnecessary by checking if we need to render
    anything in the first place.
* This immediately results in an issue: Not rendering means the frame
  latency waitable object yields immediately (because we can't wait on
  it twice). The solution is to wait 16ms before trying again.
* If the display is off, DWM will not deque frames. `Present1()` will
  indicate this (`DXGI_STATUS_OCCLUDED`) but it's not a failure so we
  don't handle it. Because of this we'll fill the queue to its maximum
  (64 frames). Once the display is on again, DWM will deque at V-Sync
  rate, but since we render as fast as the frame latency waitable
  object, also signaled at V-Sync rate, we'll push frames at the same
  rate they're dequeued, causing a 64-frame latency (~1.1s at 60Hz).
  `SetMaximumFrameLatency(1)` doesn't change this.
  The solution is that we don't limit waiting on the frame latency
  waitable object to just 100ms, but `INFINITE`.
* Since that fix causes the renderer to wait potentially forever,
  a mechanism to cancel waits on shutdown is necessary.
  This also uncovered a flaw in the current design, wherein it blocks
  the UI thread for up to 100ms every time you close or move a tab
  on a low frame rate (or no active) display.

Closes #20226
Closes #20342
Closes #20716

## Validation Steps Performed
* Continuously render, scroll up -> no GPU use ✅
2026-09-26 00:59:39 +00:00
Dustin L. Howett
f823ca2ef6 core, atlas: properly handle no-swapchain-handle situations (#20722)
When ControlCore is set up to target an HWND, there will not be a swap
chain handle.

When there's not going to be a swap chain handle or a listener who cares
about it, don't bother with the event registration (save memory on a
useless object) and don't bother sending the event.

Supersedes #20712
2026-09-25 23:33:57 +00:00