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

Commit 93c71566 authored by Omar Elmekkawy's avatar Omar Elmekkawy
Browse files

Fix tiling divider touch region.

The following CL includes:

* Swapping width with height, as the initial naming for SplitScreen meant
that width meant height when the screen is viewed horizontally as the
default is vertically.

* Fix a bug in dividerLeft bounds that used centerY instead of centerX.

* Fixing a bug where divider height is used instead of handle height for
handle height.

* This CL also fixes a bug where hovering on the divider would flip the
cursor to arrows when we only want it on the divider.

As this is a UI change, all those changes were tested extensively on
device.

Flag: com.android.window.flags.enable_tile_resizing
Test: On device testing, unit tests can't test correct touch regions.
Bug: 424342661
Change-Id: Iece4912ba45c8ce2d9a33199f4d7fcb41f1f5d08
parent 41ca53d5
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -70,10 +70,10 @@ class DesktopTilingDividerWindowManager(
    private var handleRegionSize: Size =
        Size(
            displayContext.resources.getDimensionPixelSize(
                R.dimen.split_divider_handle_region_width
                R.dimen.split_divider_handle_region_height
            ),
            displayContext.resources.getDimensionPixelSize(
                R.dimen.split_divider_handle_region_height
                R.dimen.split_divider_handle_region_width
            ),
        )
    private var setTouchRegion = true
@@ -114,7 +114,7 @@ class DesktopTilingDividerWindowManager(
        val centerY = divider.height() / 2f
        val handleLeft = centerX - handle.width() / 2f
        val handleRight = handleLeft + handle.width()
        val dividerLeft = centerY - divider.width() / 2f
        val dividerLeft = centerX - divider.width() / 2f
        val dividerRight = dividerLeft + divider.width()

        val dividerTop = cornerRadius
@@ -371,7 +371,7 @@ class DesktopTilingDividerWindowManager(

    private fun updateTouchRegion() {
        val startX = -handleRegionSize.width / 2
        val handle = Rect(startX, 0, startX + handleRegionSize.width, dividerBounds.height())
        val handle = Rect(startX, 0, startX + handleRegionSize.width, handleRegionSize.height)
        setTouchRegion(handle, dividerBounds, maxRoundedCornerRadius.toFloat())
    }

+6 −2
Original line number Diff line number Diff line
@@ -154,8 +154,12 @@ class TilingDividerView : FrameLayout, View.OnTouchListener, DragDetector.Motion
        }
    }

    override fun onResolvePointerIcon(event: MotionEvent, pointerIndex: Int): PointerIcon =
        PointerIcon.getSystemIcon(context, PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW)
    override fun onResolvePointerIcon(event: MotionEvent, pointerIndex: Int): PointerIcon {
        if (isWithinHandleRegion(event.y.toInt())) {
            return PointerIcon.getSystemIcon(context, PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW)
        }
        return PointerIcon.getSystemIcon(context, PointerIcon.TYPE_ARROW)
    }

    override fun onTouch(v: View, event: MotionEvent): Boolean =
        dragDetector.onMotionEvent(v, event)