Use real QWindow for taskbar icon hider.

Fixes #17081.
This commit is contained in:
John Preston 2021-10-08 12:19:41 +04:00
parent eb5ba12ba3
commit dd856b9e4a
2 changed files with 6 additions and 8 deletions

View File

@ -115,8 +115,7 @@ struct MainWindow::Private {
MainWindow::MainWindow(not_null<Window::Controller*> controller)
: Window::MainWindow(controller)
, _private(std::make_unique<Private>())
, ps_tbHider_hWnd(createTaskbarHider())
, ps_tbHider(QWindow::fromWinId(WId(ps_tbHider_hWnd))) {
, _taskbarHiderWindow(std::make_unique<QWindow>()) {
QCoreApplication::instance()->installNativeEventFilter(
EventFilter::CreateInstance(this));
@ -248,8 +247,9 @@ void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) {
psSetupTrayIcon();
HWND psOwner = (HWND)GetWindowLongPtr(ps_hWnd, GWLP_HWNDPARENT);
if (!psOwner) {
SetWindowLongPtr(ps_hWnd, GWLP_HWNDPARENT, (LONG_PTR)ps_tbHider_hWnd);
windowHandle()->setTransientParent(ps_tbHider);
const auto hwnd = _taskbarHiderWindow->winId();
SetWindowLongPtr(ps_hWnd, GWLP_HWNDPARENT, (LONG_PTR)hwnd);
windowHandle()->setTransientParent(_taskbarHiderWindow.get());
}
} break;
@ -538,8 +538,6 @@ MainWindow::~MainWindow() {
}
psDestroyIcons();
if (ps_tbHider) delete ps_tbHider;
if (ps_tbHider_hWnd) DestroyWindow(ps_tbHider_hWnd);
EventFilter::Destroy();
}

View File

@ -86,12 +86,12 @@ private:
rpl::lifetime _showFromTrayLifetime;
HWND ps_hWnd = nullptr;
HWND ps_tbHider_hWnd = nullptr;
QWindow *ps_tbHider = nullptr;
HICON ps_iconBig = nullptr;
HICON ps_iconSmall = nullptr;
HICON ps_iconOverlay = nullptr;
const std::unique_ptr<QWindow> _taskbarHiderWindow;
};
} // namespace Platform