mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use event filter to get surface expose event
This commit is contained in:
parent
cfee688feb
commit
3cf739eca9
2 changed files with 31 additions and 14 deletions
|
@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/invoke_queued.h"
|
#include "base/event_filter.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
|
@ -649,6 +649,27 @@ void MainWindow::initHook() {
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
|
||||||
if (_appMenuSupported) {
|
if (_appMenuSupported) {
|
||||||
LOG(("Using D-Bus global menu."));
|
LOG(("Using D-Bus global menu."));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1268,22 +1289,18 @@ void MainWindow::updateGlobalMenuHook() {
|
||||||
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
|
||||||
void MainWindow::handleVisibleChangedHook(bool visible) {
|
void MainWindow::handleNativeSurfaceChanged(bool exist) {
|
||||||
if (visible) {
|
if (exist) {
|
||||||
InvokeQueued(this, [=] {
|
SkipTaskbar(
|
||||||
SkipTaskbar(
|
windowHandle(),
|
||||||
windowHandle(),
|
(Global::WorkMode().value() == dbiwmTrayOnly)
|
||||||
(Global::WorkMode().value() == dbiwmTrayOnly)
|
&& trayAvailable());
|
||||||
&& trayAvailable());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
if (_appMenuSupported && _mainMenuExporter) {
|
if (_appMenuSupported && _mainMenuExporter) {
|
||||||
if (visible) {
|
if (exist) {
|
||||||
InvokeQueued(this, [=] {
|
RegisterAppMenu(windowHandle(), kMainMenuObjectPath.utf16());
|
||||||
RegisterAppMenu(windowHandle(), kMainMenuObjectPath.utf16());
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
UnregisterAppMenu(windowHandle());
|
UnregisterAppMenu(windowHandle());
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ protected:
|
||||||
void initHook() override;
|
void initHook() override;
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
void updateGlobalMenuHook() override;
|
void updateGlobalMenuHook() override;
|
||||||
void handleVisibleChangedHook(bool visible) override;
|
|
||||||
|
|
||||||
void initTrayMenuHook() override;
|
void initTrayMenuHook() override;
|
||||||
bool hasTrayIcon() const override;
|
bool hasTrayIcon() const override;
|
||||||
|
@ -76,6 +75,7 @@ private:
|
||||||
base::unique_qptr<Ui::PopupMenu> _trayIconMenuXEmbed;
|
base::unique_qptr<Ui::PopupMenu> _trayIconMenuXEmbed;
|
||||||
|
|
||||||
void updateIconCounters();
|
void updateIconCounters();
|
||||||
|
void handleNativeSurfaceChanged(bool exist);
|
||||||
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
StatusNotifierItem *_sniTrayIcon = nullptr;
|
StatusNotifierItem *_sniTrayIcon = nullptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue