Update skip taskbar hint on Linux without QWindow events

This commit is contained in:
Ilya Fedin 2024-06-21 14:36:17 +04:00 committed by John Preston
parent d2d5226dc7
commit 671a15d763
3 changed files with 14 additions and 42 deletions

View file

@ -136,35 +136,6 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller)
: Window::MainWindow(controller) {
}
void MainWindow::initHook() {
events() | rpl::start_with_next([=](not_null<QEvent*> e) {
if (e->type() == QEvent::ThemeChange) {
updateWindowIcon();
}
}, lifetime());
base::install_event_filter(windowHandle(), [=](not_null<QEvent*> e) {
if (e->type() == QEvent::Expose) {
auto ee = static_cast<QExposeEvent*>(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() {
}

View file

@ -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) {

View file

@ -455,8 +455,6 @@ QRect MainWindow::desktopRect() const {
}
void MainWindow::init() {
createWinId();
initHook();
updatePalette();