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

修复新配置候选窗口有时会包含不可见的窗口的问题 #760

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Magpie.App/NewProfileViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,21 @@

namespace winrt::Magpie::App::implementation {

static bool IsCandidateWindow(HWND hWnd) {
if (!IsWindowVisible(hWnd)) {
// 检查窗口是否可见应查看整个所有者链
static bool IsWindowAndOwnerVisible(HWND hWnd) noexcept {
do {
if (!IsWindowVisible(hWnd)) {
return false;
}

hWnd = GetWindowOwner(hWnd);
} while (hWnd);

return true;
}

static bool IsCandidateWindow(HWND hWnd) noexcept {
if (!IsWindowAndOwnerVisible(hWnd)) {
return false;
}

Expand Down Expand Up @@ -60,7 +73,7 @@ static bool IsCandidateWindow(HWND hWnd) {
}
}

static SmallVector<HWND> GetDesktopWindows() {
static SmallVector<HWND> GetDesktopWindows() noexcept {
SmallVector<HWND> windows;

// EnumWindows 可以枚举到 UWP 窗口,官方文档已经过时。无法枚举到全屏状态下的 UWP 窗口
Expand Down