microsoft / microsoft/terminal

Windows Terminal Window Does Not Send `EVENT_OBJECT_DESTROY` On Close

Open
#17,298 6 comments 7 reactions 1 assignee Claimed by @lhecker View on GitHub
Issue-Bug Needs-Attention Needs-Triage
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

1.19.11213.0

### Windows build number

10.0.22631.0

### Other Software

_No response_

### Steps to reproduce

Open a single instance of Windows terminal on the desktop. Close that instance of Windows Terminal. `EVENT_OBJECT_DESTROY` is not emitted.

### Expected Behavior

`EVENT_OBJECT_DESTROY` should be emitted when the Windows Terminal window is closed by the window handle that the user has just interacted with.

### Actual Behavior

`EVENT_OBJECT_DESTROY` is not emitted for the Windows Terminal window that was closed.

When opening Windows Terminal, `EVENT_SYSTEM_FOREGROUND` is emitted, and the window handle of the actual window that I as the user interact with is the log example below is `658858`:
```
2024-05-22T01:39:16.367526Z INFO process_event{event=FocusChange(SystemForeground, Window { hwnd: 658858 })}: komorebi::process_event: processed: (hwnd: 658858, title: PowerShell, exe: WindowsTerminal.exe, class: CASCADIA_HOSTING_WINDOW_CLASS)
```

When I close the window, _sometimes_ an `EVENT_OBJECT_HIDE` is emitted, but it is emitted for a completely separate window handle (`920252`):

```
2024-05-22T01:39:18.051931Z DEBUG process_event{event=Hide(ObjectHide, Window { hwnd: 920252 })}:should_manage{self=Window { hwnd: 920252 } event=Some(Hide(ObjectHide, Window { hwnd: 920252 }))}: komorebi::window: ignoring (exe: WindowsTerminal.exe, title: DesktopWindowXamlSource, event: Hide (WinEvent: ObjectHide, Window: (hwnd: 920252)))
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.