microsoft / DevHomeAzureExtension

Dev Home Azure Extension
MIT License
68 stars 15 forks source link

User/sahrbini/fix foreground #166

Closed safmswork closed 1 month ago

safmswork commented 2 months ago

Summary of the pull request

References and relevant issues

Detailed description of the pull request / Additional comments

There is currently an issue with all DevHome extensions that run in their own process, where foreground rights are not transferred to the extension process. This leads to UI issues obviously. But in the specific case of Dev Environment Start Menu and Taskbar pinning, it blocks the entire feature from working. This is because the Shell APIs for Start Menu and Taskbar pinning require the caller to be in the foreground, and if it isn't the Shell APIs fail.

There is currently work going on to fix this foreground issue for all DevHome extensions in a proper way, but this work won't be done in time for Build. The pinning features are required for Build, so I have to put in this temporary fix. The fix here is to directly call SetForegroundWindow on the process (WindowsApp) launched by the pinning code .

NOTE: There is a corresponding PR in the Devhome repo that is also required to fix the issue: https://github.com/microsoft/devhome/pull/2791

Validation steps performed

Made sure pinning worked and that other options within Dev Environments (launch, start, stop, etc.) still work.

PR checklist