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

View file

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