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

Commit a32dcf7f authored by Chris Tate's avatar Chris Tate
Browse files

Actually draw the drag thumbnail

Now sets the layer and thumbnail dimensions correctly.  Also removed the
leftover bits of the now-replaced thumbnail measurement/drawing mechanism.

Fixes bug 3077339

Change-Id: I02983648e0a7ce2ce5fee10825f744e20a3a5b8d
parent 2794eb3b
Loading
Loading
Loading
Loading
+0 −39
Original line number Diff line number Diff line
@@ -204443,19 +204443,6 @@
<parameter name="canvas" type="android.graphics.Canvas">
</parameter>
</method>
<method name="onDrawDragThumbnail"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="protected"
>
<parameter name="canvas" type="android.graphics.Canvas">
</parameter>
</method>
<method name="onDrawScrollBars"
 return="void"
 abstract="false"
@@ -204649,17 +204636,6 @@
<parameter name="heightMeasureSpec" type="int">
</parameter>
</method>
<method name="onMeasureDragThumbnail"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="protected"
>
</method>
<method name="onRestoreInstanceState"
 return="void"
 abstract="false"
@@ -205325,21 +205301,6 @@
<parameter name="contentDescription" type="java.lang.CharSequence">
</parameter>
</method>
<method name="setDragThumbnailDimension"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="protected"
>
<parameter name="width" type="int">
</parameter>
<parameter name="height" type="int">
</parameter>
</method>
<method name="setDrawingCacheBackgroundColor"
 return="void"
 abstract="false"
+5 −50
Original line number Diff line number Diff line
@@ -2037,8 +2037,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
     *
     */
    boolean mCanAcceptDrop;
    private int mThumbnailWidth;
    private int mThumbnailHeight;

    /**
     * Simple constructor to use when creating a view from code.
@@ -9921,10 +9919,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
            throw new IllegalStateException("Drag thumb dimensions must not be negative");
        }

        if (ViewDebug.DEBUG_DRAG) {
            Log.d(VIEW_LOG_TAG, "drag thumb: width=" + thumbSize.x + " height=" + thumbSize.y
                    + " thumbX=" + thumbTouchPoint.x + " thumbY=" + thumbTouchPoint.y);
        }
        Surface surface = new Surface();
        try {
            IBinder token = mAttachInfo.mSession.prepareDrag(mAttachInfo.mWindow,
                    myWindowOnly, mThumbnailWidth, mThumbnailHeight, surface);
                    myWindowOnly, thumbSize.x, thumbSize.y, surface);
            if (ViewDebug.DEBUG_DRAG) Log.d(VIEW_LOG_TAG, "prepareDrag returned token=" + token
                    + " surface=" + surface);
            if (token != null) {
@@ -9951,53 +9953,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        return okay;
    }

    private void measureThumbnail() {
        mPrivateFlags &= ~MEASURED_DIMENSION_SET;

        onMeasureDragThumbnail();

        // flag not set, setDragThumbnailDimension() was not invoked, we raise
        // an exception to warn the developer
        if ((mPrivateFlags & MEASURED_DIMENSION_SET) != MEASURED_DIMENSION_SET) {
            throw new IllegalStateException("onMeasureDragThumbnail() did not set the"
                    + " measured dimension by calling setDragThumbnailDimension()");
        }

        if (ViewDebug.DEBUG_DRAG) {
            Log.d(VIEW_LOG_TAG, "Drag thumb measured: w=" + mThumbnailWidth
                    + " h=" + mThumbnailHeight);
        }
    }

    /**
     * The View must call this method from onMeasureDragThumbnail() in order to
     * specify the dimensions of the drag thumbnail image.
     *
     * @param width The desired thumbnail width.
     * @param height The desired thumbnail height.
     */
    protected final void setDragThumbnailDimension(int width, int height) {
        mPrivateFlags |= MEASURED_DIMENSION_SET;
        mThumbnailWidth = width;
        mThumbnailHeight = height;
    }

    /**
     * The default implementation specifies a drag thumbnail that matches the
     * View's current size and appearance.
     */
    protected void onMeasureDragThumbnail() {
        setDragThumbnailDimension(getWidth(), getHeight());
    }

    /**
     * The default implementation just draws the current View appearance as the thumbnail
     * @param canvas
     */
    protected void onDrawDragThumbnail(Canvas canvas) {
        draw(canvas);
    }

    /**
     * Drag-and-drop event dispatch.  The event.getAction() verb is one of the DragEvent
     * constants DRAG_STARTED_EVENT, DRAG_EVENT, DROP_EVENT, and DRAG_ENDED_EVENT.
+10 −5
Original line number Diff line number Diff line
@@ -555,6 +555,12 @@ public class WindowManagerService extends IWindowManager.Stub
            }
        }

        int getDragLayerLw() {
            return mPolicy.windowTypeToLayerLw(WindowManager.LayoutParams.TYPE_DRAG)
                    * TYPE_LAYER_MULTIPLIER
                    + TYPE_LAYER_OFFSET;
        }

        /* call out to each visible window/session informing it about the drag
         */
        void broadcastDragStartedLw(final float touchX, final float touchY) {
@@ -5533,7 +5539,7 @@ public class WindowManagerService extends IWindowManager.Stub
            return null;
        }

        private void addDragInputWindow(InputWindowList windowList) {
        private void addDragInputWindowLw(InputWindowList windowList) {
            final InputWindow inputWindow = windowList.add();
            inputWindow.inputChannel = mDragState.mServerChannel;
            inputWindow.name = "drag";
@@ -5545,9 +5551,7 @@ public class WindowManagerService extends IWindowManager.Stub
            inputWindow.hasFocus = true;
            inputWindow.hasWallpaper = false;
            inputWindow.paused = false;
            inputWindow.layer = mPolicy.windowTypeToLayerLw(inputWindow.layoutParamsType)
                    * TYPE_LAYER_MULTIPLIER
                    + TYPE_LAYER_OFFSET;
            inputWindow.layer = mDragState.getDragLayerLw();
            inputWindow.ownerPid = Process.myPid();
            inputWindow.ownerUid = Process.myUid();

@@ -5583,7 +5587,7 @@ public class WindowManagerService extends IWindowManager.Stub
                if (DEBUG_DRAG) {
                    Log.d(TAG, "Inserting drag window");
                }
                addDragInputWindow(mTempInputWindows);
                addDragInputWindowLw(mTempInputWindows);
            }

            final int N = windows.size();
@@ -6231,6 +6235,7 @@ public class WindowManagerService extends IWindowManager.Stub
                    surface.setPosition((int)(touchX - thumbCenterX),
                            (int)(touchY - thumbCenterY));
                    surface.setAlpha(.5f);
                    surface.setLayer(mDragState.getDragLayerLw());
                    surface.show();
                } finally {
                    surface.closeTransaction();