Skip to content

Commit

Permalink
Fix broken WindowWidget views when not using layers. Fixes #911. (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored and bluemarvin committed Jan 8, 2019
1 parent d7b89d7 commit 5bfad39
Showing 1 changed file with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,34 @@ public void setView(View view) {
mView.setVisibility(VISIBLE);
addView(mView);
mWidgetPlacement.density = getContext().getResources().getDisplayMetrics().density;
if (mTexture != null && mSurface != null && mRenderer == null) {
// Create the UI Renderer for the current surface.
// Surface must be released when switching back to WebView surface or the browser
// will not render it correctly. See release code in unsetView().
mRenderer = new UISurfaceTextureRenderer(mSurface, mWidgetPlacement.textureWidth(), mWidgetPlacement.textureHeight());
}
mWidgetManager.updateWidget(this);
postInvalidate();
mWidgetManager.pushWorldBrightness(this, WidgetManagerDelegate.DEFAULT_DIM_BRIGHTNESS);
mWidgetManager.pushBackHandler(mBackHandler);
setWillNotDraw(false);
postInvalidate();
}

public void unsetView(View view) {
if (mView != null && mView == view) {
mView = null;
removeView(view);
view.setVisibility(GONE);
resumeCompositor();
setWillNotDraw(true);
if (mTexture != null) {
// Surface must be recreated here when not using layers.
// When using layers the new Surface is received via the setSurface() method.
if (mRenderer != null) {
mRenderer.release();
mRenderer = null;
}
mSurface = new Surface(mTexture);
}
mWidgetPlacement.density = 1.0f;
mWidgetManager.updateWidget(this);
mWidgetManager.popWorldBrightness(this);
Expand Down Expand Up @@ -231,14 +247,6 @@ public int getBorderWidth() {
return mBorderWidth;
}

public int getTextureWidth() {
return mWidth;
}

public int getTextureHeight() {
return mHeight;
}

public void setSaveResizeChanges(boolean aSave) {
mSaveResizeChanges = aSave;
}
Expand Down Expand Up @@ -312,6 +320,9 @@ public void resizeSurface(final int aWidth, final int aHeight) {
mHeight = aHeight;
if (mTexture != null) {
mTexture.setDefaultBufferSize(aWidth, aHeight);
}

if (mSurface != null && mView == null) {
callSurfaceChanged();
}
}
Expand Down Expand Up @@ -642,9 +653,8 @@ public void onBookmarksHidden() {
@Override
public void onBookmarksClicked() {
if (mBookmarksView.getVisibility() == View.VISIBLE) {
SessionStore.get().unstackSession();

unsetView(mBookmarksView);
SessionStore.get().unstackSession();

} else {
int sessionId;
Expand Down

0 comments on commit 5bfad39

Please sign in to comment.