Skip to content

Commit

Permalink
Add MileXamlContentWindowDefaultMessageLoop API.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Sep 5, 2024
1 parent 8024c25 commit 5f218d3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mile.Xaml.Native/Mile.Xaml.Native.def
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ EXPORTS
MileXamlGetCoreWindowHandle
MileXamlSetXamlContentForContentWindow
MileXamlContentWindowDefaultCallback
MileXamlContentWindowDefaultMessageLoop
MileXamlGetTransparentBackgroundAttribute
MileXamlSetTransparentBackgroundAttribute
MileXamlGetPreferredDarkModeAttribute
Expand Down
25 changes: 25 additions & 0 deletions Mile.Xaml.Native/Mile.Xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,31 @@ EXTERN_C LRESULT CALLBACK MileXamlContentWindowDefaultCallback(
return 0;
}

EXTERN_C int WINAPI MileXamlContentWindowDefaultMessageLoop()
{
MSG Message;
while (::GetMessageW(&Message, nullptr, 0, 0))
{
// Workaround for capturing Alt+F4 in applications with XAML Islands.
// Reference: https://github.com/microsoft/microsoft-ui-xaml/issues/2408
if (Message.message == WM_SYSKEYDOWN && Message.wParam == VK_F4)
{
::SendMessageW(
::GetAncestor(Message.hwnd, GA_ROOT),
Message.message,
Message.wParam,
Message.lParam);

continue;
}

::TranslateMessage(&Message);
::DispatchMessageW(&Message);
}

return static_cast<int>(Message.wParam);
}

EXTERN_C HRESULT WINAPI MileXamlGetTransparentBackgroundAttribute(
_Out_ PBOOLEAN TransparentBackground)
{
Expand Down
7 changes: 7 additions & 0 deletions Mile.Xaml.Native/Mile.Xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ EXTERN_C LRESULT CALLBACK MileXamlContentWindowDefaultCallback(
_In_ WPARAM wParam,
_In_ LPARAM lParam);

/**
* @brief The default message loop function for Mile.Xaml.ContentWindow
* window class.
* @return The message loop exit code.
*/
EXTERN_C int WINAPI MileXamlContentWindowDefaultMessageLoop();

/**
* @brief Retrieves the transparent background attribute for contents hosted
* via XAML Islands.
Expand Down

0 comments on commit 5f218d3

Please sign in to comment.