Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9bdf5766 authored by Jon Larimer's avatar Jon Larimer
Browse files
parent e1dc1d6d
Loading
Loading
Loading
Loading
+43 −22
Original line number Diff line number Diff line
@@ -30,8 +30,9 @@ import android.os.ParcelFileDescriptor;
import android.util.AttributeSet;
import android.util.Config;
import android.util.Log;
import java.util.ArrayList;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantLock;

/**
@@ -308,7 +309,7 @@ public class SurfaceView extends View {
                mLayout.memoryType = mRequestedType;

                if (mWindow == null) {
                    mWindow = new MyWindow();
                    mWindow = new MyWindow(this);
                    mLayout.type = WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA;
                    mLayout.gravity = Gravity.LEFT|Gravity.TOP;
                    mSession.add(mWindow, mLayout,
@@ -393,12 +394,21 @@ public class SurfaceView extends View {
        updateWindow(false);
    }
    
    private class MyWindow extends IWindow.Stub {
    private static class MyWindow extends IWindow.Stub {
        private WeakReference<SurfaceView> mSurfaceView;

        public MyWindow(SurfaceView surfaceView) {
            mSurfaceView = new WeakReference<SurfaceView>(surfaceView);
        }

        public void resized(int w, int h, Rect coveredInsets,
                Rect visibleInsets, boolean reportDraw) {
            SurfaceView surfaceView = mSurfaceView.get();
            if (surfaceView != null) {
                if (localLOGV) Log.v(
                "SurfaceView", SurfaceView.this + " got resized: w=" +
                w + " h=" + h + ", cur w=" + mCurWidth + " h=" + mCurHeight);
                        "SurfaceView", surfaceView + " got resized: w=" +
                        w + " h=" + h + ", cur w=" + mCurWidth + " h=" + 
                        mCurHeight);
                synchronized (this) {
                    if (mCurWidth != w || mCurHeight != h) {
                        mCurWidth = w;
@@ -406,22 +416,29 @@ public class SurfaceView extends View {
                    }
                    if (reportDraw) {
                        try {
                        mSession.finishDrawing(mWindow);
                            surfaceView.mSession.finishDrawing(
                                    surfaceView.mWindow);
                        } catch (RemoteException e) {
                        }
                    }
                }
            }
        }

        public void dispatchKey(KeyEvent event) {
            //Log.w("SurfaceView", "Unexpected key event in surface: " + event);
            if (mSession != null && mSurface != null) {
            SurfaceView surfaceView = mSurfaceView.get();
            if (surfaceView != null) {
                //Log.w("SurfaceView", "Unexpected key event in surface: " 
                // + event);
                if (surfaceView.mSession != null && surfaceView.mSurface != 
                        null) {
                    try {
                    mSession.finishKey(mWindow);
                        surfaceView.mSession.finishKey(surfaceView.mWindow);
                    } catch (RemoteException ex) {
                    }
                }
            }
        }

        public void dispatchPointer(MotionEvent event, long eventTime) {
            Log.w("SurfaceView", "Unexpected pointer event in surface: " + event);
@@ -448,8 +465,12 @@ public class SurfaceView extends View {
        }
        
        public void dispatchGetNewSurface() {
            Message msg = mHandler.obtainMessage(GET_NEW_SURFACE_MSG);
            mHandler.sendMessage(msg);
            SurfaceView surfaceView = mSurfaceView.get();
            if (surfaceView != null) {
                Message msg = surfaceView.mHandler.obtainMessage(
                        GET_NEW_SURFACE_MSG);
                surfaceView.mHandler.sendMessage(msg); 
            }
        }

        public void windowFocusChanged(boolean hasFocus, boolean touchEnabled) {