mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
fix: 修复 Alt+Space 和 Alt+F4 不起作用的问题
This commit is contained in:
parent
b8f7014e4a
commit
cb63b6a03d
2 changed files with 18 additions and 12 deletions
|
|
@ -83,15 +83,13 @@ bool XamlApp::Initialize(HINSTANCE hInstance, const wchar_t* arguments) {
|
|||
int XamlApp::Run() {
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, nullptr, 0, 0)) {
|
||||
if (msg.message == WM_MAGPIE_SHOWME && _uwpApp) {
|
||||
if (msg.message == WM_MAGPIE_SHOWME) [[unlikely]] {
|
||||
ShowMainWindow();
|
||||
continue;
|
||||
} else if (msg.message == WM_MAGPIE_QUIT) {
|
||||
} else if (msg.message == WM_MAGPIE_QUIT) [[unlikely]] {
|
||||
Quit();
|
||||
continue;
|
||||
} else {
|
||||
_mainWindow.HandleMessage(msg);
|
||||
}
|
||||
|
||||
_mainWindow.HandleMessage(msg);
|
||||
}
|
||||
|
||||
_ReleaseMutexes();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,13 @@ public:
|
|||
}
|
||||
|
||||
void HandleMessage(const MSG& msg) {
|
||||
// XAML Islands 会吞掉 Alt+F4,需要特殊处理
|
||||
// https://github.com/microsoft/microsoft-ui-xaml/issues/2408
|
||||
if (msg.message == WM_SYSKEYDOWN && msg.wParam == VK_F4) [[unlikely]] {
|
||||
SendMessage(GetAncestor(msg.hwnd, GA_ROOT), msg.message, msg.wParam, msg.lParam);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_xamlSourceNative2) {
|
||||
BOOL processed = FALSE;
|
||||
HRESULT hr = _xamlSourceNative2->PreTranslateMessage(&msg, &processed);
|
||||
|
|
@ -95,7 +102,8 @@ protected:
|
|||
case WM_SHOWWINDOW:
|
||||
{
|
||||
if (wParam == TRUE) {
|
||||
SetFocus(_hWnd);
|
||||
// 将焦点置于 XAML Islands 窗口可以修复按 Alt 键会导致 UI 无法交互的问题
|
||||
SetFocus(_hwndXamlIsland);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
@ -135,13 +143,13 @@ protected:
|
|||
|
||||
return 0;
|
||||
}
|
||||
case WM_MENUCHAR:
|
||||
{
|
||||
// 防止按 Alt+Key 时发出铃声
|
||||
return MAKELRESULT(0, MNC_CLOSE);
|
||||
}
|
||||
case WM_SYSCOMMAND:
|
||||
{
|
||||
// Alt 键默认会打开菜单,导致界面不响应鼠标移动。这里禁用这个行为
|
||||
if ((wParam & 0xfff0) == SC_KEYMENU) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 最小化时关闭 ComboBox
|
||||
// 不能在 WM_SIZE 中处理,该消息发送于最小化之后,会导致 ComboBox 无法交互
|
||||
if (wParam == SC_MINIMIZE && _content) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue