Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown Preview Handler Icon in Windows Status Bar #33491

Open
kpym opened this issue Jun 24, 2024 · 2 comments
Open

Markdown Preview Handler Icon in Windows Status Bar #33491

kpym opened this issue Jun 24, 2024 · 2 comments
Assignees
Labels
Issue-Bug Something isn't working Product-File Explorer Power Toys that touch explorer like Preview Pane Resolution-Fix Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@kpym
Copy link

kpym commented Jun 24, 2024

Microsoft PowerToys version

0.81.1

Installation method

PowerToys auto-update

Running as admin

Yes

Area(s) with issue?

File Explorer: Preview Pane

Steps to reproduce

Since the latest version of PowerToys, an icon for the Markdown Preview Handler appears in the Windows status bar.

✔️ Expected Behavior

This additional icon should not be present.

❌ Actual Behavior

PTMPH

Other Software

No response

@kpym kpym added Issue-Bug Something isn't working Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Jun 24, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@kpym
Copy link
Author

kpym commented Jun 24, 2024

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

This is very close, but one is for MonacoPreviewHandler and the other for MarkdownPreviewHandler.

@davidegiacometti davidegiacometti self-assigned this Jul 28, 2024
@davidegiacometti davidegiacometti added Status-In progress This issue or work-item is under development Product-File Explorer Power Toys that touch explorer like Preview Pane and removed Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams labels Jul 28, 2024
@davidegiacometti davidegiacometti added this to the PowerToys 0.84 milestone Aug 2, 2024
stefansjfw pushed a commit that referenced this issue Aug 7, 2024
<!-- Enter a brief description/summary of your PR here. What does it
fix/what does it change/how was it tested (even manually, if necessary)?
-->
## Summary of the Pull Request

This PR aims to fix some positioning issues of the form used as preview
handler.
It fixes the following issues:
1. The floating window, detached from Explorer that sometimes appears:
#33491 #27475 #24985
2. The **CoreWebView2 members cannot be accessed after the WebView2
control is disposed** crash: #27276
3. `PowerToys.*.PreviewHandler.exe` process leak

### Repro steps for issue 1
- Navigate through files in a folder invoking their preview handler
- Minimize/Restore Explorer quickly (spam WIN+D usually works)
- 2 weird issues happen:
  - Some `PowerToys.*.PreviewHandler.exe` processes are leaked
- Some `PowerToys.*.PreviewHandler.exe` are started with a `NULL` `HWND`

![Screenshot 2024-07-27
**200207](https://github.com/user-attachments/assets/5cb6c857-ad93-422a-8c5b-47bd1c492dce)

This happens because
[IPreviewHandler::DoPreview](https://learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipreviewhandler-dopreview)
is called multiple times and sometimes before calling
[IPreviewHandler::SetWindow](https://learn.microsoft.com/windows/win32/api/shobjidl_core/nf-shobjidl_core-ipreviewhandler-setwindow).

When the managed previewer try to set the parent of the form to the
`NULL` `HWND`, the desktop window is used instead, resulting in the
floating preview window being displayed.
Reference:
https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-setparent#parameters


https://github.com/microsoft/PowerToys/blob/5d77874382f55cdf5268b19ebb97ec07727ca78f/src/modules/previewpane/common/controls/FormHandlerControl.cs#L136

### Repro steps for issue 2
- Preview a file
- Restart `explorer.exe` process
- Make sure `PowerToys.*.PreviewHandler.exe` is leaked and still running
- Preview the same file again
- Preview is displayed (another process is launched)
- Minimize Explorer

What happens here is that the form of the old process have an invalid
`HWND` as parent but receive the `SetRect` for some reason.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] **Closes:** #33491 #27475 #24985 #27276
- [ ] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [ ] **Tests:** Added/updated and all pass
- [ ] **Localization:** All end user facing strings can be localized
- [ ] **Dev docs:** Added/updated
- [ ] **New binaries:** Added on the required places
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [ ] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx

<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

- Don't start preview pane process when `HWND` is `NULL`
- Terminate the preview pane process when setting parent fails
- Prevent leaking processes closing them when a new preview is requested
- Fixed an issue where PDF and SVG previews weren't updated after
restoring Explorer
- Added some error handling in the `UpdateWindowBounds` method of the
managed preview
- Terminate the preview pane when the `SetRect` event is received but
the parent `HWND` has become invalid

<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

- Manually tested all preview panes also using multiple Explorer windows
- Validated that when Explorer is minimized/restored the preview is
updated
- Tested the preview pane resize
- Validated that no window, no taskbar icon and no errors appear on both
repro steps
@stefansjfw stefansjfw added Resolution-Fix Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed Status-In progress This issue or work-item is under development labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Something isn't working Product-File Explorer Power Toys that touch explorer like Preview Pane Resolution-Fix Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

No branches or pull requests

4 participants