From fe05ee72048960cf4eb693386c0b89f29c92f852 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Tue, 28 Apr 2020 22:49:40 +0200 Subject: [PATCH] Make sure session listeners are set when LoadRequest is called (#3265) --- .../org/mozilla/vrbrowser/ui/widgets/WindowWidget.java | 5 ++--- .../shared/org/mozilla/vrbrowser/ui/widgets/Windows.java | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java index ef62d36f2..9eccf9832 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/WindowWidget.java @@ -1117,12 +1117,9 @@ public void setSession(@NonNull Session aSession, @OldSessionDisplayAction int a } else { onCurrentSessionChange(null, aSession.getGeckoSession()); } - setupListeners(mSession); for (WindowListener listener: mListeners) { listener.onSessionChanged(oldSession, aSession); } - - } mCaptureOnPageStop = false; hideLibraryPanels(); @@ -1152,6 +1149,7 @@ public void onStackSession(Session aSession) { // e.g. tab opened via window.open() aSession.updateLastUse(); Session current = mSession; + setupListeners(aSession); setSession(aSession); SessionStore.get().setActiveSession(aSession); current.captureBackgroundBitmap(getWindowWidth(), getWindowHeight()).thenAccept(aVoid -> current.setActive(false)); @@ -1164,6 +1162,7 @@ public void onStackSession(Session aSession) { public void onUnstackSession(Session aSession, Session aParent) { if (mSession == aSession) { aParent.setActive(true); + setupListeners(aParent); setSession(aParent); SessionStore.get().setActiveSession(aParent); SessionStore.get().destroySession(aSession); diff --git a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java index 154dfc007..92f11c674 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java @@ -1211,7 +1211,9 @@ public void onTabSelect(Session aTab) { Session moveTo = targetWindow.getSession(); moveFrom.surfaceDestroyed(); moveTo.surfaceDestroyed(); + windowToMove.setupListeners(moveTo); windowToMove.setSession(moveTo, WindowWidget.SESSION_DO_NOT_RELEASE_DISPLAY); + targetWindow.setupListeners(moveFrom); targetWindow.setSession(moveFrom, WindowWidget.SESSION_DO_NOT_RELEASE_DISPLAY); SessionStore.get().setActiveSession(targetWindow.getSession()); windowToMove.setActiveWindow(false); @@ -1220,6 +1222,7 @@ public void onTabSelect(Session aTab) { } else { setFirstPaint(targetWindow, aTab); targetWindow.getSession().setActive(false); + targetWindow.setupListeners(aTab); aTab.setActive(true); targetWindow.setSession(aTab); SessionStore.get().setActiveSession(aTab); @@ -1234,6 +1237,7 @@ public void addTab(@NonNull WindowWidget targetWindow, @Nullable String aUri) { Session session = SessionStore.get().createSuspendedSession(aUri, targetWindow.getSession().isPrivateMode()); setFirstPaint(targetWindow, session); targetWindow.getSession().setActive(false); + targetWindow.setupListeners(session); session.setActive(true); targetWindow.setSession(session); if (aUri == null || aUri.isEmpty()) { @@ -1297,6 +1301,7 @@ public void onTabsClose(ArrayList aTabs) { Session tab = available.get(0); if (tab != null) { setFirstPaint(window, tab); + window.setupListeners(tab); tab.setActive(true); window.setSession(tab); } @@ -1336,6 +1341,7 @@ public void onTabsReceived(@NonNull List aTabs) { if (i == 0 && !fullscreen) { // Set the first received tab of the list the current one. SessionStore.get().setActiveSession(session); + targetWindow.setupListeners(session); targetWindow.getSession().setActive(false); targetWindow.setSession(session); }