From 0a7a6643aad0c623fd285936f4127a38351bde3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Wed, 5 Jan 2022 11:49:50 -0500 Subject: [PATCH] mainapplication: fix fullscreen management Remove all references to appWindow.isFullScreen and uses visibility Store latest state to keep previous states when passing the call in fullscreen or a media player. Fix also fullscreen's transition on media messages Change-Id: I1b141fc052aa607561275faf231504f48b3c49b8 --- src/MainApplicationWindow.qml | 7 ++-- .../DataTransferMessageDelegate.qml | 36 +++++++++++++++---- src/mainview/MainView.qml | 2 +- src/mainview/components/CallStackView.qml | 20 ++++++----- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/MainApplicationWindow.qml b/src/MainApplicationWindow.qml index f6e4b468c..acaf6bbce 100644 --- a/src/MainApplicationWindow.qml +++ b/src/MainApplicationWindow.qml @@ -47,12 +47,13 @@ ApplicationWindow { } property ApplicationWindow appWindow : root + property bool isFullscreen: visibility === Window.FullScreen function toggleFullScreen() { - if (visibility !== Window.FullScreen) { - showFullScreen() - } else { + if (isFullscreen) { showNormal() + } else { + showFullScreen() } } diff --git a/src/commoncomponents/DataTransferMessageDelegate.qml b/src/commoncomponents/DataTransferMessageDelegate.qml index 0f3545559..daea1bf4f 100644 --- a/src/commoncomponents/DataTransferMessageDelegate.qml +++ b/src/commoncomponents/DataTransferMessageDelegate.qml @@ -35,6 +35,7 @@ Loader { property bool showTime: false property int seq: MsgSeq.single property string author: Author + property bool changeWindowVisibility: false width: ListView.view ? ListView.view.width : 0 @@ -278,7 +279,7 @@ Loader { settings.fullScreenSupportEnabled: mediaInfo.isVideo settings.javascriptCanOpenWindows: false Component.onCompleted: loadHtml(mediaInfo.html, 'file://') - layer.enabled: parent !== appContainer && !appWindow.isFullScreen + layer.enabled: parent !== appContainer && !appWindow.isFullscreen layer.effect: OpacityMask { maskSource: MessageBubble { out: isOutgoing @@ -288,20 +289,43 @@ Loader { radius: msgRadius } } + + function leaveFullScreen() { + parent = localMediaCompLoader + if (root.changeWindowVisibility) { + root.changeWindowVisibility = false + appWindow.showNormal() + } + } + onFullScreenRequested: function(request) { if (JamiQmlUtils.callIsFullscreen) return - if (request.toggleOn && !appWindow.isFullScreen) { + if (request.toggleOn) { parent = appContainer - appWindow.toggleFullScreen() - } else if (!request.toggleOn && appWindow.isFullScreen) { - parent = localMediaCompLoader - appWindow.toggleFullScreen() + if (!appWindow.isFullscreen) { + root.changeWindowVisibility = true + appWindow.showFullScreen() + } + } else { + leaveFullScreen() } request.accept() } + + Connections { + target: appWindow + + function onVisibilityChanged() { + if (wev.isFullScreen && !appWindow.isFullScreen) { + wev.fullScreenCancelled() + leaveFullScreen() + } + } + } } } + Component { id: animatedImageComp AnimatedImage { diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index 1394fa234..5792f2882 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -562,7 +562,7 @@ Rectangle { onActivated: { if (JamiQmlUtils.callIsFullscreen) callStackView.toggleFullScreen() - else if (appWindow.isFullScreen) + else if (appWindow.visibility === Window.FullScreen) appWindow.toggleFullScreen() } } diff --git a/src/mainview/components/CallStackView.qml b/src/mainview/components/CallStackView.qml index cce19dc4d..1f1d927fb 100644 --- a/src/mainview/components/CallStackView.qml +++ b/src/mainview/components/CallStackView.qml @@ -26,9 +26,10 @@ import net.jami.Constants 1.1 import "../../commoncomponents" Rectangle { - id: callStackViewWindow + id: root property bool isAudioOnly: false + property bool changeWindowVisibility: false property var sipKeys: [ "1", "2", "3", "A", "4", "5", "6", "B", @@ -116,10 +117,13 @@ Rectangle { // manual toggle here because of our fake fullscreen mode (F11) // TODO: handle and save window states, not just a boolean isFullScreen - if (!appWindow.isFullScreen && !JamiQmlUtils.callIsFullscreen) - appWindow.isFullScreen = true - else if (JamiQmlUtils.callIsFullscreen) - appWindow.isFullScreen = false + if (!appWindow.isFullscreen && !JamiQmlUtils.callIsFullscreen) { + root.changeWindowVisibility = true + appWindow.showFullScreen() + } else if (JamiQmlUtils.callIsFullscreen && root.changeWindowVisibility) { + root.changeWindowVisibility = false + appWindow.showNormal() + } JamiQmlUtils.callIsFullscreen = !JamiQmlUtils.callIsFullscreen callPage.parent = JamiQmlUtils.callIsFullscreen ? @@ -134,7 +138,7 @@ Rectangle { target: JamiQmlUtils function onFullScreenCallEnded() { - if (appWindow.isFullScreen) { + if (appWindow.isFullscreen) { toggleFullScreen() } } @@ -173,7 +177,7 @@ Rectangle { anchors.fill: parent property int stackNumber: CallStackView.OngoingPageStack - isAudioOnly: callStackViewWindow.isAudioOnly + isAudioOnly: root.isAudioOnly visible: callStackMainView.currentItem.stackNumber === stackNumber } @@ -184,7 +188,7 @@ Rectangle { anchors.fill: parent property int stackNumber: CallStackView.InitialPageStack - isAudioOnly: callStackViewWindow.isAudioOnly + isAudioOnly: root.isAudioOnly onCallAccepted: { CallAdapter.acceptACall(responsibleAccountId, responsibleConvUid) -- GitLab