From 8d0ff1b61dbd7a5644bfa6080a8357e84c742e2a Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 8 Oct 2021 12:20:24 +0400 Subject: [PATCH] Try setting current window as foreground on activate. --- Telegram/SourceFiles/platform/win/specific_win.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index 8104f6468..0624ca8c3 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -20,6 +20,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "history/history_location_manager.h" #include "storage/localstorage.h" +#include "core/application.h" +#include "window/window_controller.h" #include "core/crash_reports.h" #include @@ -144,6 +146,14 @@ void DeleteMyModules() { void psActivateProcess(uint64 pid) { if (pid) { ::EnumWindows((WNDENUMPROC)_ActivateProcess, (LPARAM)&pid); + } else if (Core::IsAppLaunched()) { + if (const auto window = Core::App().activeWindow()) { + if (const auto handle = window->widget()->windowHandle()) { + if (const auto id = handle->winId()) { + SetForegroundWindow(HWND(id)); + } + } + } } }