diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 764b90bb6..9a8d3feeb 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -136,35 +136,6 @@ MainWindow::MainWindow(not_null controller) : Window::MainWindow(controller) { } -void MainWindow::initHook() { - events() | rpl::start_with_next([=](not_null e) { - if (e->type() == QEvent::ThemeChange) { - updateWindowIcon(); - } - }, lifetime()); - - base::install_event_filter(windowHandle(), [=](not_null e) { - if (e->type() == QEvent::Expose) { - auto ee = static_cast(e.get()); - if (ee->region().isNull()) { - return base::EventFilterResult::Continue; - } - if (!windowHandle() - || windowHandle()->parent() - || !windowHandle()->isVisible()) { - return base::EventFilterResult::Continue; - } - handleNativeSurfaceChanged(true); - } else if (e->type() == QEvent::Hide) { - if (!windowHandle() || windowHandle()->parent()) { - return base::EventFilterResult::Continue; - } - handleNativeSurfaceChanged(false); - } - return base::EventFilterResult::Continue; - }); -} - void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) { if (!TrayIconSupported()) { return; @@ -514,19 +485,22 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *evt) { updateGlobalMenu(); } } + } else if (obj == this && t == QEvent::Paint) { + if (!_exposed) { + _exposed = true; + SkipTaskbar( + windowHandle(), + (Core::App().settings().workMode() == WorkMode::TrayOnly) + && TrayIconSupported()); + } + } else if (obj == this && t == QEvent::Hide) { + _exposed = false; + } else if (obj == this && t == QEvent::ThemeChange) { + updateWindowIcon(); } return Window::MainWindow::eventFilter(obj, evt); } -void MainWindow::handleNativeSurfaceChanged(bool exist) { - if (exist) { - SkipTaskbar( - windowHandle(), - (Core::App().settings().workMode() == WorkMode::TrayOnly) - && TrayIconSupported()); - } -} - MainWindow::~MainWindow() { } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index 311ed3a74..4ef98ba77 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -28,7 +28,6 @@ public: protected: bool eventFilter(QObject *obj, QEvent *evt) override; - void initHook() override; void unreadCounterChangedHook() override; void updateGlobalMenuHook() override; @@ -37,7 +36,6 @@ protected: private: void updateUnityCounter(); - void handleNativeSurfaceChanged(bool exist); QMenuBar *psMainMenu = nullptr; QAction *psLogout = nullptr; @@ -61,6 +59,8 @@ private: QAction *psMonospace = nullptr; QAction *psClearFormat = nullptr; + bool _exposed = false; + }; [[nodiscard]] inline int32 ScreenNameChecksum(const QString &name) { diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index f1b1f7c0b..1276b264f 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -455,8 +455,6 @@ QRect MainWindow::desktopRect() const { } void MainWindow::init() { - createWinId(); - initHook(); updatePalette();