public virtual android.view.WindowManagerClass.LayoutParams getRootViewLayoutParameter (android.view.View view) { android.view.ViewParent vp = view.getParent(); while (vp != null && !(vp is android.view.ViewRootImpl)) { vp = vp.getParent(); } if (vp == null) { return(null); } android.view.ViewRootImpl vr = (android.view.ViewRootImpl)vp; int N = mRoots.Length; { for (int i = 0; i < N; ++i) { if (mRoots[i] == vr) { return(mParams[i]); } } } return(null); }
// func doesn't allow null... does it matter if we clear them? //view.setLayoutParams(null); public virtual void closeAll(android.os.IBinder token, string who, string what) { lock (this) { if (mViews == null) { return; } int count = mViews.Length; { //Log.i("foo", "Closing all windows of " + token); for (int i = 0; i < count; i++) { //Log.i("foo", "@ " + i + " token " + mParams[i].token // + " view " + mRoots[i].getView()); if (token == null || mParams[i].token == token) { android.view.ViewRootImpl root = mRoots[i]; root.mAddNesting = 1; //Log.i("foo", "Force closing " + root); if (who != null) { android.view.WindowLeaked leak = new android.view.WindowLeaked(what + " " + who + " has leaked window " + root.getView() + " that was originally added here"); XobotOS.Runtime.Util.SetStackTrace(leak, root.getLocation().StackTrace); android.util.Log.e("WindowManager", leak.Message, leak); } removeViewLocked(i); i--; count--; } } } } }
private bool onContainerKey(android.view.KeyEvent @event) { int keyCode = @event.getKeyCode(); if (isInterestingKey(keyCode)) { if (keyCode == android.view.KeyEvent.KEYCODE_BACK) { if (@event.getAction() == android.view.KeyEvent.ACTION_DOWN && @event.getRepeatCount () == 0) { if (mOwnerView != null) { android.view.KeyEvent.DispatcherState ds = mOwnerView.getKeyDispatcherState(); if (ds != null) { ds.startTracking(@event, this); } } return(true); } else { if (@event.getAction() == android.view.KeyEvent.ACTION_UP && @event.isTracking() && [email protected]()) { setVisible(false); return(true); } } } else { dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT); } // Let the container handle the key return(false); } else { android.view.ViewRootImpl viewRoot = getOwnerViewRootImpl(); if (viewRoot != null) { viewRoot.dispatchKey(@event); } // We gave the key to the owner, don't let the container handle this key return(true); } }
public virtual void reportNewConfiguration(android.content.res.Configuration config ) { lock (this) { int count = mViews.Length; config = new android.content.res.Configuration(config); { for (int i = 0; i < count; i++) { android.view.ViewRootImpl root = mRoots[i]; root.requestUpdateConfiguration(config); } } } }
public virtual void removeViewImmediate(android.view.View view) { lock (this) { int index = findViewLocked(view, true); android.view.ViewRootImpl root = mRoots[index]; android.view.View curView = root.getView(); root.mAddNesting = 0; root.die(true); finishRemoveViewLocked(curView, index); if (curView == view) { return; } throw new System.InvalidOperationException("Calling with view " + view + " but the ViewAncestor is attached to " + curView); } }
public virtual void updateViewLayout(android.view.View view, android.view.ViewGroup .LayoutParams @params) { if (!(@params is android.view.WindowManagerClass.LayoutParams)) { throw new System.ArgumentException("Params must be WindowManager.LayoutParams"); } android.view.WindowManagerClass.LayoutParams wparams = (android.view.WindowManagerClass .LayoutParams)@params; view.setLayoutParams(wparams); lock (this) { int index = findViewLocked(view, true); android.view.ViewRootImpl root = mRoots[index]; mParams[index] = wparams; root.setLayoutParams(wparams, false); } }
internal virtual void finishRemoveViewLocked(android.view.View view, int index) { int count = mViews.Length; // remove it from the list android.view.View[] tmpViews = new android.view.View[count - 1]; removeItem(tmpViews, mViews, index); mViews = tmpViews; android.view.ViewRootImpl[] tmpRoots = new android.view.ViewRootImpl[count - 1]; removeItem(tmpRoots, mRoots, index); mRoots = tmpRoots; android.view.WindowManagerClass.LayoutParams[] tmpParams = new android.view.WindowManagerClass .LayoutParams[count - 1]; removeItem(tmpParams, mParams, index); mParams = tmpParams; if (view != null) { view.assignParent(null); } }
public virtual void setStoppedState(android.os.IBinder token, bool stopped) { lock (this) { if (mViews == null) { return; } int count = mViews.Length; { for (int i = 0; i < count; i++) { if (token == null || mParams[i].token == token) { android.view.ViewRootImpl root = mRoots[i]; root.setStopped(stopped); } } } } }
/// <hide></hide> public virtual void dumpGfxInfo(java.io.FileDescriptor fd) { java.io.FileOutputStream fout = new java.io.FileOutputStream(fd); java.io.PrintWriter pw = new java.io.PrintWriter(fout); try { lock (this) { if (mViews != null) { pw.println("View hierarchy:"); int count = mViews.Length; int viewsCount = 0; int displayListsSize = 0; int[] info = new int[2]; { for (int i = 0; i < count; i++) { android.view.ViewRootImpl root = mRoots[i]; root.dumpGfxInfo(pw, info); string name = root.GetType().FullName + '@' + Sharpen.Util.IntToHexString(GetHashCode ()); pw.printf(" %s: %d views, %.2f kB (display lists)\n", name, info[0], info[1] / 1024.0f ); viewsCount += info[0]; displayListsSize += info[1]; } } pw.printf("\nTotal ViewRootImpl: %d\n", count); pw.printf("Total Views: %d\n", viewsCount); pw.printf("Total DisplayList: %.2f kB\n\n", displayListsSize / 1024.0f); } } } finally { pw.flush(); } }
internal virtual android.view.View removeViewLocked(int index) { android.view.ViewRootImpl root = mRoots[index]; android.view.View view = root.getView(); // Don't really remove until we have matched all calls to add(). root.mAddNesting--; if (root.mAddNesting > 0) { return(view); } if (view != null) { android.view.inputmethod.InputMethodManager imm = android.view.inputmethod.InputMethodManager .getInstance(view.getContext()); if (imm != null) { imm.windowDismissed(mViews[index].getWindowToken()); } } root.die(false); finishRemoveViewLocked(view, index); return(view); }
private void updateWindow(bool force, bool redrawNeeded) { if (!mHaveFrame) { return; } android.view.ViewRootImpl viewRoot = (android.view.ViewRootImpl)getRootView().getParent (); if (viewRoot != null) { mTranslator = viewRoot.mTranslator; } if (mTranslator != null) { mSurface.setCompatibilityTranslator(mTranslator); } int myWidth = mRequestedWidth; if (myWidth <= 0) { myWidth = getWidth(); } int myHeight = mRequestedHeight; if (myHeight <= 0) { myHeight = getHeight(); } getLocationInWindow(mLocation); bool creating = mWindow == null; bool formatChanged = mFormat != mRequestedFormat; bool sizeChanged = mWidth != myWidth || mHeight != myHeight; bool visibleChanged = mVisible != mRequestedVisible || mNewSurfaceNeeded; if (force || creating || formatChanged || sizeChanged || visibleChanged || mLeft != mLocation[0] || mTop != mLocation[1] || mUpdateWindowNeeded || mReportDrawNeeded || redrawNeeded) { try { bool visible = mVisible = mRequestedVisible; mLeft = mLocation[0]; mTop = mLocation[1]; mWidth = myWidth; mHeight = myHeight; mFormat = mRequestedFormat; // Scaling/Translate window's layout here because mLayout is not used elsewhere. // Places the window relative mLayout.x = mLeft; mLayout.y = mTop; mLayout.width = getWidth(); mLayout.height = getHeight(); if (mTranslator != null) { mTranslator.translateLayoutParamsInAppWindowToScreen(mLayout); } mLayout.format = mRequestedFormat; mLayout.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_NOT_TOUCHABLE | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_FOCUSABLE | android.view.WindowManagerClass .LayoutParams.FLAG_LAYOUT_NO_LIMITS | android.view.WindowManagerClass.LayoutParams .FLAG_SCALED | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_FOCUSABLE | android.view.WindowManagerClass.LayoutParams.FLAG_NOT_TOUCHABLE; if (!getContext().getResources().getCompatibilityInfo().supportsScreen()) { mLayout.flags |= android.view.WindowManagerClass.LayoutParams.FLAG_COMPATIBLE_WINDOW; } if (mWindow == null) { mWindow = new android.view.SurfaceView.MyWindow(this); mLayout.type = mWindowType; mLayout.gravity = android.view.Gravity.LEFT | android.view.Gravity.TOP; mSession.addWithoutInputChannel(mWindow, mWindow.mSeq, mLayout, mVisible ? VISIBLE : GONE, mContentInsets); } if (visibleChanged && (!visible || mNewSurfaceNeeded)) { reportSurfaceDestroyed(); } mNewSurfaceNeeded = false; bool realSizeChanged; bool reportDrawNeeded; mSurfaceLock.@lock(); try { mUpdateWindowNeeded = false; reportDrawNeeded = mReportDrawNeeded; mReportDrawNeeded = false; mDrawingStopped = !visible; int relayoutResult = mSession.relayout(mWindow, mWindow.mSeq, mLayout, mWidth, mHeight , visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets, mVisibleInsets, mConfiguration , mSurface); if ((relayoutResult & android.view.WindowManagerImpl.RELAYOUT_FIRST_TIME) != 0) { mReportDrawNeeded = true; } mSurfaceFrame.left = 0; mSurfaceFrame.top = 0; if (mTranslator == null) { mSurfaceFrame.right = mWinFrame.width(); mSurfaceFrame.bottom = mWinFrame.height(); } else { float appInvertedScale = mTranslator.applicationInvertedScale; mSurfaceFrame.right = (int)(mWinFrame.width() * appInvertedScale + 0.5f); mSurfaceFrame.bottom = (int)(mWinFrame.height() * appInvertedScale + 0.5f); } int surfaceWidth = mSurfaceFrame.right; int surfaceHeight = mSurfaceFrame.bottom; realSizeChanged = mLastSurfaceWidth != surfaceWidth || mLastSurfaceHeight != surfaceHeight; mLastSurfaceWidth = surfaceWidth; mLastSurfaceHeight = surfaceHeight; } finally { mSurfaceLock.unlock(); } try { redrawNeeded |= creating | reportDrawNeeded; if (visible) { mDestroyReportNeeded = true; android.view.SurfaceHolderClass.Callback[] callbacks; lock (mCallbacks) { callbacks = new android.view.SurfaceHolderClass.Callback[mCallbacks.size()]; mCallbacks.toArray(callbacks); } if (visibleChanged) { mIsCreating = true; foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { c.surfaceCreated(mSurfaceHolder); } } if (creating || formatChanged || sizeChanged || visibleChanged || realSizeChanged) { foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { c.surfaceChanged(mSurfaceHolder, mFormat, myWidth, myHeight); } } if (redrawNeeded) { foreach (android.view.SurfaceHolderClass.Callback c in callbacks) { if (c is android.view.SurfaceHolderClass.Callback2) { ((android.view.SurfaceHolderClass.Callback2)c).surfaceRedrawNeeded(mSurfaceHolder ); } } } } else { mSurface.release(); } } finally { mIsCreating = false; if (redrawNeeded) { mSession.finishDrawing(mWindow); } } } catch (android.os.RemoteException) { } } }
private void addView(android.view.View view, android.view.ViewGroup.LayoutParams @params, android.view.CompatibilityInfoHolder cih, bool nest) { if (false) { android.util.Log.v("WindowManager", "addView view=" + view); } if (!(@params is android.view.WindowManagerClass.LayoutParams)) { throw new System.ArgumentException("Params must be WindowManager.LayoutParams"); } android.view.WindowManagerClass.LayoutParams wparams = (android.view.WindowManagerClass .LayoutParams)@params; android.view.ViewRootImpl root; android.view.View panelParentView = null; lock (this) { // Here's an odd/questionable case: if someone tries to add a // view multiple times, then we simply bump up a nesting count // and they need to remove the view the corresponding number of // times to have it actually removed from the window manager. // This is useful specifically for the notification manager, // which can continually add/remove the same view as a // notification gets updated. int index = findViewLocked(view, false); if (index >= 0) { if (!nest) { throw new System.InvalidOperationException("View " + view + " has already been added to the window manager." ); } root = mRoots[index]; root.mAddNesting++; // Update layout parameters. view.setLayoutParams(wparams); root.setLayoutParams(wparams, true); return; } // If this is a panel window, then find the window it is being // attached to for future reference. if (wparams.type >= android.view.WindowManagerClass.LayoutParams.FIRST_SUB_WINDOW && wparams.type <= android.view.WindowManagerClass.LayoutParams.LAST_SUB_WINDOW) { int count = mViews != null ? mViews.Length : 0; { for (int i = 0; i < count; i++) { if (mRoots[i].mWindow.asBinder() == wparams.token) { panelParentView = mViews[i]; } } } } root = new android.view.ViewRootImpl(view.getContext()); root.mAddNesting = 1; if (cih == null) { root.mCompatibilityInfo = new android.view.CompatibilityInfoHolder(); } else { root.mCompatibilityInfo = cih; } view.setLayoutParams(wparams); if (mViews == null) { index = 1; mViews = new android.view.View[1]; mRoots = new android.view.ViewRootImpl[1]; mParams = new android.view.WindowManagerClass.LayoutParams[1]; } else { index = mViews.Length + 1; object[] old = mViews; mViews = new android.view.View[index]; System.Array.Copy(old, 0, mViews, 0, index - 1); old = mRoots; mRoots = new android.view.ViewRootImpl[index]; System.Array.Copy(old, 0, mRoots, 0, index - 1); old = mParams; mParams = new android.view.WindowManagerClass.LayoutParams[index]; System.Array.Copy(old, 0, mParams, 0, index - 1); } index--; mViews[index] = view; mRoots[index] = root; mParams[index] = wparams; } // do this last because it fires off messages to start doing things root.setView(view, wparams, panelParentView); }