mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
Notification fix :
try fix for non showing notification on Windows add more debug for non showing notification and try hack fix mac notification #LINQT-2441 Notification fix : try fix for non showing notification on Windows add more debug for non showing notification and try hack fix mac notification #LINQT-2441
This commit is contained in:
parent
b57a2a9491
commit
c32f2a1c00
4 changed files with 47 additions and 24 deletions
|
|
@ -1592,10 +1592,6 @@ bool App::event(QEvent *event) {
|
||||||
}
|
}
|
||||||
receivedMessage(0, url.toLocal8Bit());
|
receivedMessage(0, url.toLocal8Bit());
|
||||||
} else if (event->type() == QEvent::ApplicationStateChange) {
|
} else if (event->type() == QEvent::ApplicationStateChange) {
|
||||||
auto state = static_cast<QApplicationStateChangeEvent *>(event);
|
|
||||||
if (state->applicationState() == Qt::ApplicationActive) {
|
|
||||||
Utils::smartShowWindow(getLastActiveWindow());
|
|
||||||
}
|
|
||||||
if (getAccountList()) {
|
if (getAccountList()) {
|
||||||
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
for (int i = 0; i < getAccountList()->rowCount(); ++i) {
|
||||||
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
auto accountCore = getAccountList()->getAt<AccountCore>(i);
|
||||||
|
|
|
||||||
|
|
@ -141,11 +141,10 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
||||||
bool showAsTool = false;
|
bool showAsTool = false;
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
for (auto w : QGuiApplication::topLevelWindows()) {
|
for (auto w : QGuiApplication::topLevelWindows()) {
|
||||||
if ((w->windowState() & Qt::WindowFullScreen) == Qt::WindowFullScreen) {
|
if (w->visibility() == QWindow::FullScreen) {
|
||||||
showAsTool = true;
|
showAsTool = true;
|
||||||
w->raise(); // Used to get focus on Mac (On Mac, A Tool is hidden if the app has not focus and the only
|
w->raise(); // Used to get focus on Mac (On Mac, A Tool is hidden if the app has not focus and the
|
||||||
// way to rid it is to use Widget Attributes(Qt::WA_MacAlwaysShowToolWindow) that is not
|
// only way to rid it is to use Widget Attributes(Qt::WA_MacAlwaysShowToolWindow) that is not available)
|
||||||
// available)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -159,7 +158,7 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
||||||
const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename);
|
const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
engine, &QQmlApplicationEngine::objectCreated, this,
|
engine, &QQmlApplicationEngine::objectCreated, this,
|
||||||
[this, url, screen, engine, type, data](QObject *obj, const QUrl &objUrl) {
|
[this, url, screen, engine, type, data, showAsTool](QObject *obj, const QUrl &objUrl) {
|
||||||
if (!obj && url == objUrl) {
|
if (!obj && url == objUrl) {
|
||||||
lCritical() << "[App] Notifier.qml couldn't be load.";
|
lCritical() << "[App] Notifier.qml couldn't be load.";
|
||||||
engine->deleteLater();
|
engine->deleteLater();
|
||||||
|
|
@ -167,7 +166,16 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
||||||
} else {
|
} else {
|
||||||
auto window = qobject_cast<QQuickWindow *>(obj);
|
auto window = qobject_cast<QQuickWindow *>(obj);
|
||||||
if (window) {
|
if (window) {
|
||||||
|
window->setParent(nullptr);
|
||||||
window->setProperty(NotificationPropertyData, data);
|
window->setProperty(NotificationPropertyData, data);
|
||||||
|
window->setScreen(screen);
|
||||||
|
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure
|
||||||
|
// to have the Window on Top and fullscreen independant
|
||||||
|
window->setFlags((showAsTool ? Qt::Tool : Qt::WindowStaysOnTopHint) |
|
||||||
|
Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
window->setFlag(Qt::WindowDoesNotAcceptFocus);
|
||||||
|
#endif
|
||||||
// for (auto it = data.begin(); it != data.end(); ++it)
|
// for (auto it = data.begin(); it != data.end(); ++it)
|
||||||
// window->setProperty(it.key().toLatin1(), it.value());
|
// window->setProperty(it.key().toLatin1(), it.value());
|
||||||
const int timeout = Notifications[type].getTimeout() * 1000;
|
const int timeout = Notifications[type].getTimeout() * 1000;
|
||||||
|
|
@ -190,8 +198,24 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d
|
||||||
qDebug() << "closing notification";
|
qDebug() << "closing notification";
|
||||||
deleteNotification(QVariant::fromValue(window));
|
deleteNotification(QVariant::fromValue(window));
|
||||||
});
|
});
|
||||||
|
QObject::connect(window, &QQuickWindow::visibleChanged, window, [this](bool visible) {
|
||||||
|
lInfo() << log().arg("Notification visible changed") << visible;
|
||||||
|
});
|
||||||
|
QObject::connect(window, &QQuickWindow::activeChanged, window, [this, window] {
|
||||||
|
lInfo() << log().arg("Notification active changed") << window->isActive();
|
||||||
|
});
|
||||||
|
QObject::connect(window, &QQuickWindow::visibilityChanged, window,
|
||||||
|
[this](QWindow::Visibility visibility) {
|
||||||
|
lInfo() << log().arg("Notification visibility changed") << visibility;
|
||||||
|
});
|
||||||
|
QObject::connect(window, &QQuickWindow::widthChanged, window, [this](int width) {
|
||||||
|
lInfo() << log().arg("Notification width changed") << width;
|
||||||
|
});
|
||||||
|
QObject::connect(window, &QQuickWindow::heightChanged, window, [this](int height) {
|
||||||
|
lInfo() << log().arg("Notification height changed") << height;
|
||||||
|
});
|
||||||
|
lInfo() << QStringLiteral("Create notification:") << window;
|
||||||
showNotification(window, timeout);
|
showNotification(window, timeout);
|
||||||
lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -215,15 +239,21 @@ void Notifier::showNotification(QQuickWindow *notification, int timeout) {
|
||||||
notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer));
|
notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QObject::connect(App::getInstance(), &App::sessionUnlocked, notification, [this, notification] {
|
QObject::connect(App::getInstance(), &App::sessionUnlocked, notification, [this, notification] {
|
||||||
|
if (!notification) return;
|
||||||
lInfo() << log().arg("Windows : screen unlocked, force raising notification");
|
lInfo() << log().arg("Windows : screen unlocked, force raising notification");
|
||||||
notification->show();
|
notification->hide();
|
||||||
|
notification->showNormal();
|
||||||
notification->raise();
|
notification->raise();
|
||||||
notification->requestActivate();
|
lInfo() << log().arg("Notification visibility : visible =") << notification->isVisible()
|
||||||
|
<< "visibility =" << notification->visibility();
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
notification->show();
|
notification->hide();
|
||||||
|
notification->showNormal();
|
||||||
notification->raise();
|
notification->raise();
|
||||||
notification->requestActivate();
|
lInfo() << log().arg("Notification visibility : visible =") << notification->isVisible()
|
||||||
|
<< "visibility =" << notification->visibility() << "size =" << notification->width()
|
||||||
|
<< notification->height();
|
||||||
|
|
||||||
// Destroy it after timeout.
|
// Destroy it after timeout.
|
||||||
QObject::connect(timer, &QTimer::timeout, this,
|
QObject::connect(timer, &QTimer::timeout, this,
|
||||||
|
|
@ -239,7 +269,7 @@ void Notifier::showNotification(QQuickWindow *notification, int timeout) {
|
||||||
void Notifier::deleteNotificationOnTimeout(QVariant notification) {
|
void Notifier::deleteNotificationOnTimeout(QVariant notification) {
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
for (auto w : QGuiApplication::topLevelWindows()) {
|
for (auto w : QGuiApplication::topLevelWindows()) {
|
||||||
if ((w->windowState() & Qt::WindowFullScreen) == Qt::WindowFullScreen) {
|
if (w->visibility() == QWindow::FullScreen) {
|
||||||
w->requestActivate(); // Used to get focus on fullscreens on Mac in order to avoid screen switching.
|
w->requestActivate(); // Used to get focus on fullscreens on Mac in order to avoid screen switching.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -281,9 +281,10 @@ VariantObject *Utils::haveAccount() {
|
||||||
|
|
||||||
void Utils::smartShowWindow(QQuickWindow *window) {
|
void Utils::smartShowWindow(QQuickWindow *window) {
|
||||||
if (!window) return;
|
if (!window) return;
|
||||||
// if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode
|
if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode
|
||||||
// window->showMaximized();
|
window->showMaximized();
|
||||||
lInfo() << "[Utils] : show window" << window;
|
else if (window->visibility() == QWindow::FullScreen) // Avoid to change visibility mode
|
||||||
|
window->showFullScreen();
|
||||||
window->show();
|
window->show();
|
||||||
App::getInstance()->setLastActiveWindow(window);
|
App::getInstance()->setLastActiveWindow(window);
|
||||||
lInfo() << "[Utils] : raise window" << window;
|
lInfo() << "[Utils] : raise window" << window;
|
||||||
|
|
@ -2286,4 +2287,4 @@ bool Utils::stringMatchFormat(QString toMatch, QRegularExpression regExp) {
|
||||||
void Utils::forceCrash() {
|
void Utils::forceCrash() {
|
||||||
lInfo() << "throwing segmentation fault for debug";
|
lInfo() << "throwing segmentation fault for debug";
|
||||||
raise(SIGSEGV);
|
raise(SIGSEGV);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,10 @@ Window {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
objectName: '__internalWindow'
|
objectName: '__internalWindow'
|
||||||
property bool showAsTool : false
|
|
||||||
// Don't use Popup for flags : it could lead to error in geometry. On Mac, Using Tool ensure to have the Window on Top and fullscreen independant
|
|
||||||
// flags: Qt.WindowDoesNotAcceptFocus | Qt.BypassWindowManagerHint | (showAsTool?Qt.Tool:Qt.WindowStaysOnTopHint) | Qt.Window | Qt.FramelessWindowHint;
|
|
||||||
flags: Qt.SplashScreen | Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint // | Qt.WindowStaysOnTopHint
|
|
||||||
opacity: 1.0
|
opacity: 1.0
|
||||||
|
transientParent: null
|
||||||
height: _content[0] != null ? _content[0].height : 0
|
height: _content[0] != null ? _content[0].height : 0
|
||||||
width: _content[0] != null ? _content[0].width : 0
|
width: _content[0] != null ? _content[0].width : 0
|
||||||
visible:true
|
|
||||||
Item {
|
Item {
|
||||||
id: content
|
id: content
|
||||||
anchors.fill:parent
|
anchors.fill:parent
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue