From c076a37540f2daf0b692ece9c2d00e24b6270f89 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 24 Jul 2025 15:59:30 +0200 Subject: [PATCH] fix #LINQT-1655 set height offset for new notification if there is already some displayed --- Linphone/core/notifier/Notifier.cpp | 26 +++++++++----------- Linphone/view/Control/Popup/DesktopPopup.qml | 2 +- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Linphone/core/notifier/Notifier.cpp b/Linphone/core/notifier/Notifier.cpp index 794f96002..9509dbb79 100644 --- a/Linphone/core/notifier/Notifier.cpp +++ b/Linphone/core/notifier/Notifier.cpp @@ -171,28 +171,24 @@ bool Notifier::createNotification(Notifier::NotificationType type, QVariantMap d // window->setProperty(it.key().toLatin1(), it.value()); const int timeout = Notifications[type].getTimeout() * 1000; auto updateNotificationCoordinates = [this, window, screen](int width, int height) { - int *screenHeightOffset = &mScreenHeightOffset[screen->name()]; // Access optimization + auto screenHeightOffset = + screen ? mScreenHeightOffset.value(screen->name()) : 0; // Access optimization QRect availableGeometry = screen->availableGeometry(); - int heightOffset = availableGeometry.y() + - (availableGeometry.height() - - height); //*screen->devicePixelRatio(); when using manual scaler window->setX(availableGeometry.x() + (availableGeometry.width() - width)); //*screen->devicePixelRatio()); when using manual scaler - window->setY(heightOffset - (*screenHeightOffset % heightOffset)); + window->setY(availableGeometry.y() + availableGeometry.height() - screenHeightOffset - + height); }; - QObject::connect(window, &QQuickWindow::widthChanged, - [window, updateNotificationCoordinates](int w) { - updateNotificationCoordinates(w, window->height()); - }); - QObject::connect(window, &QQuickWindow::heightChanged, - [window, updateNotificationCoordinates](int h) { - updateNotificationCoordinates(window->width(), h); - }); updateNotificationCoordinates(window->width(), window->height()); - QObject::connect(window, &QQuickWindow::closing, window, - [this, window] { deleteNotification(QVariant::fromValue(window)); }); + auto screenHeightOffset = + screen ? mScreenHeightOffset.take(screen->name()) : 0; // Access optimization + mScreenHeightOffset.insert(screen->name(), screenHeightOffset + window->height()); + QObject::connect(window, &QQuickWindow::closing, window, [this, window] { + qDebug() << "closing notification"; + deleteNotification(QVariant::fromValue(window)); + }); showNotification(window, timeout); lInfo() << QStringLiteral("Create notification:") << QVariant::fromValue(window); } diff --git a/Linphone/view/Control/Popup/DesktopPopup.qml b/Linphone/view/Control/Popup/DesktopPopup.qml index 1363172b2..49d5e0766 100644 --- a/Linphone/view/Control/Popup/DesktopPopup.qml +++ b/Linphone/view/Control/Popup/DesktopPopup.qml @@ -40,7 +40,7 @@ Window { 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.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint + flags: Qt.Popup | Qt.Dialog | Qt.WindowDoesNotAcceptFocus | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint opacity: 1.0 height: _content[0] != null ? _content[0].height : 0 width: _content[0] != null ? _content[0].width : 0