stevencohn / OneMore

A OneNote add-in with simple, yet powerful and useful features
Mozilla Public License 2.0
2.43k stars 206 forks source link

Command Palette blinks the main Window? #1422

Open seaspeak opened 1 month ago

seaspeak commented 1 month ago

Problem to Solve

Before/After the Command Palette appears/closes, it seems to briefly cause the OneNote main window to disappear, revealing the background behind it. After a brief flicker, the main window returns and the Command Palette dialog is generated.

To Reproduce

Press Ctrl+Shift+P

Expected Behavior

Screenshots

Environment (if applicable)

Version 6.4.0 with OneNote 16.0.14332.20706

Additional Context

jasonjac2 commented 1 month ago

I thought it was part of attempting to capture the keyboard ASAP. I have noticed it. Is it just annoying or actually causing you problems?

stevencohn commented 1 month ago

There is a funky interaction between the windows. Normally, you can set the parent window of a child window and Windows will handle the rest, ensuring the child is shown above the parent. But when setting the OneNote window as the parent, the child windows disappear, and the OneNote window is pushed behind all other windows on your desktop! So OneMore plays a few tricks to set-unset-set the z-order of its windows to ensure they're correctly on top. This sometimes causes things to flicker. If anyone has a cleaner way of doing it, I'd love to hear!

stevencohn commented 1 month ago

More info for those who think they know the answer LOL... The funky interaction is due to the fact that there is an interop layer in between OneNote and OneMore, via a COM surrogate process. So, the normal parent/child mechanisms don't really work here which is why OneMore takes extraordinary means to force its dialogs to be on top of the OneNote window.

seaspeak commented 1 month ago

Why is Command Palette particularly noticeably annoying?

stevencohn commented 1 month ago

I probably need a slower machine :-) I maybe see it once during a session. And it's a very quick flash. Is it happening more often, or every time you open the Command Palette?

seaspeak commented 1 month ago

I am using Intel 8th gen, got a plan to upgrade to 16th gen if everything goes well :-)

As you said, it is pushed to the bottom of all windows. But isn't the method it used different from SearchHashTags and PreviewMarkdown?

FlickerMoment

Screenshot

Animation

https://github.com/stevencohn/OneMore/assets/8821870/795d2ba1-4bd8-430c-9124-ae6a470f1d07

stevencohn commented 1 month ago

I'll do some more digging. But to answer your question, no, the Hashtags dialog and the Markdown preview dialog all use different techniques due to their technical requirements.

stevencohn commented 2 days ago

Getting closer, although certainly not perfect. Needed to make concessions around which OneMore windows can be properly TopMost window, meaning the Navigator window can no longer be TopMost??