diff --git a/Linphone/core/App.cpp b/Linphone/core/App.cpp index 15ca795ac..88f3e01f7 100644 --- a/Linphone/core/App.cpp +++ b/Linphone/core/App.cpp @@ -1596,10 +1596,6 @@ bool App::event(QEvent *event) { } receivedMessage(0, url.toLocal8Bit()); } else if (event->type() == QEvent::ApplicationStateChange) { - auto state = static_cast(event); - if (state->applicationState() == Qt::ApplicationActive) { - Utils::smartShowWindow(getLastActiveWindow()); - } if (getAccountList()) { for (int i = 0; i < getAccountList()->rowCount(); ++i) { auto accountCore = getAccountList()->getAt(i); diff --git a/Linphone/core/notifier/Notifier.cpp b/Linphone/core/notifier/Notifier.cpp index ada1d893f..a1b8b781b 100644 --- a/Linphone/core/notifier/Notifier.cpp +++ b/Linphone/core/notifier/Notifier.cpp @@ -142,11 +142,10 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d bool showAsTool = false; #ifdef Q_OS_MACOS for (auto w : QGuiApplication::topLevelWindows()) { - if ((w->windowState() & Qt::WindowFullScreen) == Qt::WindowFullScreen) { + if (w->visibility() == QWindow::FullScreen) { 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 - // way to rid it is to use Widget Attributes(Qt::WA_MacAlwaysShowToolWindow) that is not - // available) + w->raise(); // Used to get focus on Mac (On Mac, A Tool is hidden if the app has not focus and the + // only way to rid it is to use Widget Attributes(Qt::WA_MacAlwaysShowToolWindow) that is not available) } } #endif @@ -160,7 +159,7 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d const QUrl url(QString(NotificationsPath) + Notifier::Notifications[type].filename); QObject::connect( 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) { lCritical() << log().arg("%1 couldn't be load.").arg(url.toString()); engine->deleteLater(); @@ -172,6 +171,13 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d window->setParent(nullptr); 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) // window->setProperty(it.key().toLatin1(), it.value()); const int timeout = Notifications[type].getTimeout() * 1000; @@ -210,7 +216,7 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d QObject::connect(window, &QQuickWindow::heightChanged, window, [this](int height) { lInfo() << log().arg("Notification height changed") << height; }); - lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window); + lInfo() << QStringLiteral("Create notification:") << window; showNotification(window, timeout); } } @@ -236,6 +242,7 @@ void Notifier::showNotification(QQuickWindow *notification, int timeout) { notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer)); #ifdef Q_OS_WIN QObject::connect(App::getInstance(), &App::sessionUnlocked, notification, [this, notification] { + if (!notification) return; lInfo() << log().arg("Windows : screen unlocked, force raising notification"); notification->hide(); notification->showNormal(); @@ -265,7 +272,7 @@ void Notifier::showNotification(QQuickWindow *notification, int timeout) { void Notifier::deleteNotificationOnTimeout(QVariant notification) { #ifdef Q_OS_MACOS 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. } } diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index 4f2e1583a..270d581cd 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -279,9 +279,10 @@ VariantObject *Utils::haveAccount() { void Utils::smartShowWindow(QQuickWindow *window) { if (!window) return; - // if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode - // window->showMaximized(); - lInfo() << "[Utils] : show window" << window; + if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode + window->showMaximized(); + else if (window->visibility() == QWindow::FullScreen) // Avoid to change visibility mode + window->showFullScreen(); window->show(); App::getInstance()->setLastActiveWindow(window); lInfo() << "[Utils] : raise window" << window; @@ -2224,4 +2225,4 @@ bool Utils::stringMatchFormat(QString toMatch, QRegularExpression regExp) { void Utils::forceCrash() { lInfo() << "throwing segmentation fault for debug"; raise(SIGSEGV); -} \ No newline at end of file +} diff --git a/Linphone/view/Control/Popup/DesktopPopup.qml b/Linphone/view/Control/Popup/DesktopPopup.qml index 58af95827..0cb31b009 100644 --- a/Linphone/view/Control/Popup/DesktopPopup.qml +++ b/Linphone/view/Control/Popup/DesktopPopup.qml @@ -37,14 +37,10 @@ Window { // --------------------------------------------------------------------------- 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.WindowStaysOnTopHint //| Qt.FramelessWindowHint opacity: 1.0 + transientParent: null height: _content[0] != null ? _content[0].height : 0 width: _content[0] != null ? _content[0].width : 0 - Item { id: content anchors.fill:parent