Skip to content

Commit

Permalink
slideshow: exit notes view before starting the slideshow
Browse files Browse the repository at this point in the history
If the slideshow is started when impress is in notes view mode slides have a
wrong size and content is messed up.

Signed-off-by: Marco Cecchetti <[email protected]>
Change-Id: I6621f8d756f2c6b6b1bcf478fb50be0fd83d25db
  • Loading branch information
mcecchetti committed Dec 19, 2024
1 parent 83ca5ff commit 71ba183
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
1 change: 1 addition & 0 deletions browser/src/layer/tile/ImpressTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
25 changes: 24 additions & 1 deletion browser/src/slideshow/PresenterConsole.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* PresenterConsole
*/

/* global SlideShow _ */
/* global app SlideShow _ */

class PresenterConsole {
constructor(map, presenter) {
Expand Down Expand Up @@ -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;
Expand Down
38 changes: 36 additions & 2 deletions browser/src/slideshow/SlideShowPresenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 71ba183

Please sign in to comment.