diff --git a/browser/src/layer/tile/ImpressTileLayer.js b/browser/src/layer/tile/ImpressTileLayer.js index 1a2faf43b15f..d573691b11d6 100644 --- a/browser/src/layer/tile/ImpressTileLayer.js +++ b/browser/src/layer/tile/ImpressTileLayer.js @@ -315,6 +315,7 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({ } this._selectedMode = (statusJSON.mode !== undefined) ? statusJSON.mode : (statusJSON.parts.length > 0 && statusJSON.parts[0].mode !== undefined ? statusJSON.parts[0].mode : 0); + this._map.fire('impressmodechanged', {mode: this._selectedMode}); if (statusJSON.gridSnapEnabled === true) app.map.stateChangeHandler.setItemValue('.uno:GridUse', 'true'); diff --git a/browser/src/slideshow/PresenterConsole.js b/browser/src/slideshow/PresenterConsole.js index 355c412c0a64..6bc69e9fb46d 100644 --- a/browser/src/slideshow/PresenterConsole.js +++ b/browser/src/slideshow/PresenterConsole.js @@ -14,7 +14,7 @@ * PresenterConsole */ -/* global SlideShow _ */ +/* global app SlideShow _ */ class PresenterConsole { constructor(map, presenter) { @@ -189,7 +189,30 @@ class PresenterConsole { } } + _onImpressModeChanged(e) { + if (this._waitForExitingNotesMode && e.mode === 0) { + this._waitForExitingNotesMode = false; + this._map.off('impressmodechanged', this._onImpressModeChanged, this); + this._onPresentInConsole(); + } + } + _onPresentInConsole() { + if (app.impress.notesMode) { + console.debug( + 'PresenterConsole._onPresentInConsole: notes mode is enabled, exiting', + ); + // exit notes view mode and wait for status update notification + // so we're sure that impress mode is changed + // finally skip next partsupdate event, + // since it's only due to the mode change + this._presenter._skipNextSlideShowInfoChangedMsg = true; + this._waitForExitingNotesMode = true; + this._map.on('impressmodechanged', this._onImpressModeChanged, this); + app.map.sendUnoCommand('.uno:NormalMultiPaneGUI'); + return; + } + this._map.fire('newpresentinwindow'); if (!this._presenter._slideShowWindowProxy) { return; diff --git a/browser/src/slideshow/SlideShowPresenter.ts b/browser/src/slideshow/SlideShowPresenter.ts index c1edb26caf9a..0429acfae93c 100644 --- a/browser/src/slideshow/SlideShowPresenter.ts +++ b/browser/src/slideshow/SlideShowPresenter.ts @@ -125,8 +125,10 @@ class SlideShowPresenter { private _metaPresentation: MetaPresentation; private _startSlide: number; private _presentationInfoChanged: boolean = false; + _skipNextSlideShowInfoChangedMsg: boolean = false; private _cypressSVGPresentationTest: boolean = false; private _onKeyDownHandler: (e: KeyboardEvent) => void; + private _onImpressModeChanged: any = null; constructor(map: any) { this._cypressSVGPresentationTest = @@ -538,6 +540,17 @@ class SlideShowPresenter { ); } + _onImpressModeChangedImpl(e: any, inWindow: boolean) { + if (this._onImpressModeChanged && e.mode === 0) { + this._map.off('impressmodechanged', this._onImpressModeChanged, this); + this._onImpressModeChanged = null; + const startSlide = { + startSlideNumber: this._startSlide, + }; + inWindow ? this._onStartInWindow(startSlide) : this._onStart(startSlide); + } + } + /// returns true on success _onPrepareScreen(inWindow: boolean) { if (this._checkPresentationDisabled()) { @@ -558,6 +571,23 @@ class SlideShowPresenter { return false; } + if (app.impress.notesMode) { + console.debug( + 'SlideShowPresenter._onPrepareScreen: notes mode is enabled, exiting', + ); + // exit notes view mode and wait for status update notification + // so we're sure that impress mode is changed + // finally skip next partsupdate event, + // since it's only due to the mode change + this._skipNextSlideShowInfoChangedMsg = true; + this._onImpressModeChanged = function (e: any) { + this._onImpressModeChangedImpl(e, inWindow); + }; + this._map.on('impressmodechanged', this._onImpressModeChanged, this); + app.map.sendUnoCommand('.uno:NormalMultiPaneGUI'); + return false; + } + if (app.impress.areAllSlidesHidden()) { this._notifyAllSlidesHidden(); return false; @@ -668,24 +698,24 @@ class SlideShowPresenter { /// called when user triggers the presentation using UI _onStart(that: any) { + this._startSlide = that?.startSlideNumber ?? 0; if (!this._onPrepareScreen(false)) // opens full screen, has to be on user interaction return; // disable slide sorter or it will receive key events this._map._docLayer._preview.partsFocused = false; - this._startSlide = that?.startSlideNumber ?? 0; app.socket.sendMessage('getpresentationinfo'); } /// called when user triggers the in-window presentation using UI _onStartInWindow(that: any) { + this._startSlide = that?.startSlideNumber ?? 0; if (!this._onPrepareScreen(true)) // opens full screen, has to be on user interaction return; // disable present in console onStartInWindow this._enablePresenterConsole(true); - this._startSlide = that?.startSlideNumber ?? 0; app.socket.sendMessage('getpresentationinfo'); } @@ -776,6 +806,10 @@ class SlideShowPresenter { onSlideShowInfoChanged() { if (this._presentationInfoChanged) return; + if (this._skipNextSlideShowInfoChangedMsg) { + this._skipNextSlideShowInfoChangedMsg = false; + return; + } this._presentationInfoChanged = true; app.socket.sendMessage('getpresentationinfo');