diff --git a/Telegram/SourceFiles/platform/win/main_window_win.cpp b/Telegram/SourceFiles/platform/win/main_window_win.cpp index 24764233de..4b3ffbb8e3 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.cpp +++ b/Telegram/SourceFiles/platform/win/main_window_win.cpp @@ -115,8 +115,7 @@ struct MainWindow::Private { MainWindow::MainWindow(not_null controller) : Window::MainWindow(controller) , _private(std::make_unique()) -, ps_tbHider_hWnd(createTaskbarHider()) -, ps_tbHider(QWindow::fromWinId(WId(ps_tbHider_hWnd))) { +, _taskbarHiderWindow(std::make_unique()) { 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(); } diff --git a/Telegram/SourceFiles/platform/win/main_window_win.h b/Telegram/SourceFiles/platform/win/main_window_win.h index dc7eb211e3..b44872adbc 100644 --- a/Telegram/SourceFiles/platform/win/main_window_win.h +++ b/Telegram/SourceFiles/platform/win/main_window_win.h @@ -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 _taskbarHiderWindow; + }; } // namespace Platform