Loading core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -5452,6 +5452,14 @@ public final class Settings { @Readable public static final String SHOW_TOUCHES = "show_touches"; /** * Show key presses and other events dispatched to focused windows on the screen. * 0 = no * 1 = yes * @hide */ public static final String SHOW_KEY_PRESSES = "show_key_presses"; /** * Log raw orientation data from * {@link com.android.server.policy.WindowOrientationListener} for use with the Loading Loading @@ -5842,6 +5850,7 @@ public final class Settings { PRIVATE_SETTINGS.add(NOTIFICATION_LIGHT_PULSE); PRIVATE_SETTINGS.add(POINTER_LOCATION); PRIVATE_SETTINGS.add(SHOW_TOUCHES); PRIVATE_SETTINGS.add(SHOW_KEY_PRESSES); PRIVATE_SETTINGS.add(WINDOW_ORIENTATION_LISTENER_LOG); PRIVATE_SETTINGS.add(POWER_SOUNDS_ENABLED); PRIVATE_SETTINGS.add(DOCK_SOUNDS_ENABLED); Loading core/java/android/view/MotionEvent.java +34 −0 Original line number Diff line number Diff line Loading @@ -4166,6 +4166,40 @@ public final class MotionEvent extends InputEvent implements Parcelable { nativeWriteToParcel(mNativePtr, out); } /** * Get the x coordinate of the location where the pointer should be dispatched. * * This is required because a mouse event, such as from a touchpad, may contain multiple * pointers that should all be dispatched to the cursor position. * @hide */ public float getXDispatchLocation(int pointerIndex) { if (isFromSource(InputDevice.SOURCE_MOUSE)) { final float xCursorPosition = getXCursorPosition(); if (xCursorPosition != INVALID_CURSOR_POSITION) { return xCursorPosition; } } return getX(pointerIndex); } /** * Get the y coordinate of the location where the pointer should be dispatched. * * This is required because a mouse event, such as from a touchpad, may contain multiple * pointers that should all be dispatched to the cursor position. * @hide */ public float getYDispatchLocation(int pointerIndex) { if (isFromSource(InputDevice.SOURCE_MOUSE)) { final float yCursorPosition = getYCursorPosition(); if (yCursorPosition != INVALID_CURSOR_POSITION) { return yCursorPosition; } } return getY(pointerIndex); } /** * Transfer object for pointer coordinates. * Loading core/java/android/view/ViewGroup.java +17 −19 Original line number Diff line number Diff line Loading @@ -2040,8 +2040,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager @Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { final float x = event.getX(pointerIndex); final float y = event.getY(pointerIndex); final float x = event.getXDispatchLocation(pointerIndex); final float y = event.getYDispatchLocation(pointerIndex); if (isOnScrollbarThumb(x, y) || isDraggingScrollBar()) { return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_ARROW); } Loading Loading @@ -2125,8 +2125,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager HoverTarget firstOldHoverTarget = mFirstHoverTarget; mFirstHoverTarget = null; if (!interceptHover && action != MotionEvent.ACTION_HOVER_EXIT) { final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getYDispatchLocation(0); final int childrenCount = mChildrenCount; if (childrenCount != 0) { final ArrayList<View> preorderedList = buildOrderedChildList(); Loading Loading @@ -2347,8 +2347,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Check what the child under the pointer says about the tooltip. final int childrenCount = mChildrenCount; if (childrenCount != 0) { final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getYDispatchLocation(0); final ArrayList<View> preorderedList = buildOrderedChildList(); final boolean customOrder = preorderedList == null Loading Loading @@ -2443,8 +2443,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager @Override protected boolean pointInHoveredChild(MotionEvent event) { if (mFirstHoverTarget != null) { return isTransformedTouchPointInView(event.getX(), event.getY(), mFirstHoverTarget.child, null); return isTransformedTouchPointInView(event.getXDispatchLocation(0), event.getYDispatchLocation(0), mFirstHoverTarget.child, null); } return false; } Loading Loading @@ -2513,8 +2513,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager public boolean onInterceptHoverEvent(MotionEvent event) { if (event.isFromSource(InputDevice.SOURCE_MOUSE)) { final int action = event.getAction(); final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getYDispatchLocation(0); if ((action == MotionEvent.ACTION_HOVER_MOVE || action == MotionEvent.ACTION_HOVER_ENTER) && isOnScrollbar(x, y)) { return true; Loading @@ -2535,8 +2535,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Send the event to the child under the pointer. final int childrenCount = mChildrenCount; if (childrenCount != 0) { final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getXDispatchLocation(0); final ArrayList<View> preorderedList = buildOrderedChildList(); final boolean customOrder = preorderedList == null Loading Loading @@ -2700,10 +2700,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final int childrenCount = mChildrenCount; if (newTouchTarget == null && childrenCount != 0) { final float x = isMouseEvent ? ev.getXCursorPosition() : ev.getX(actionIndex); final float y = isMouseEvent ? ev.getYCursorPosition() : ev.getY(actionIndex); final float x = ev.getXDispatchLocation(actionIndex); final float y = ev.getYDispatchLocation(actionIndex); // Find a child that can receive the event. // Scan children from front to back. final ArrayList<View> preorderedList = buildTouchDispatchChildList(); Loading Loading @@ -2757,8 +2755,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } else { mLastTouchDownIndex = childIndex; } mLastTouchDownX = ev.getX(); mLastTouchDownY = ev.getY(); mLastTouchDownX = x; mLastTouchDownY = y; newTouchTarget = addTouchTarget(child, idBitsToAssign); alreadyDispatchedToNewTouchTarget = true; break; Loading Loading @@ -3287,7 +3285,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (ev.isFromSource(InputDevice.SOURCE_MOUSE) && ev.getAction() == MotionEvent.ACTION_DOWN && ev.isButtonPressed(MotionEvent.BUTTON_PRIMARY) && isOnScrollbarThumb(ev.getX(), ev.getY())) { && isOnScrollbarThumb(ev.getXDispatchLocation(0), ev.getYDispatchLocation(0))) { return true; } return false; Loading core/proto/android/providers/settings/system.proto +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ message SystemSettingsProto { // orientationplot.py tool. // 0 = no, 1 = yes optional SettingProto window_orientation_listener_log = 3 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto show_key_presses = 4 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional DevOptions developer_options = 7; Loading core/res/res/drawable/focus_event_pressed_key_background.xml 0 → 100644 +37 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright 2023 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:name="focus_event_pressed_key_background" android:shape="rectangle"> <!-- View background color --> <solid android:color="#AA000000" > </solid> <!-- View border color and width --> <stroke android:width="2dp" android:color="@android:color/white"> </stroke> <!-- The radius makes the corners rounded --> <corners android:radius="8dp"> </corners> </shape> No newline at end of file Loading
core/java/android/provider/Settings.java +9 −0 Original line number Diff line number Diff line Loading @@ -5452,6 +5452,14 @@ public final class Settings { @Readable public static final String SHOW_TOUCHES = "show_touches"; /** * Show key presses and other events dispatched to focused windows on the screen. * 0 = no * 1 = yes * @hide */ public static final String SHOW_KEY_PRESSES = "show_key_presses"; /** * Log raw orientation data from * {@link com.android.server.policy.WindowOrientationListener} for use with the Loading Loading @@ -5842,6 +5850,7 @@ public final class Settings { PRIVATE_SETTINGS.add(NOTIFICATION_LIGHT_PULSE); PRIVATE_SETTINGS.add(POINTER_LOCATION); PRIVATE_SETTINGS.add(SHOW_TOUCHES); PRIVATE_SETTINGS.add(SHOW_KEY_PRESSES); PRIVATE_SETTINGS.add(WINDOW_ORIENTATION_LISTENER_LOG); PRIVATE_SETTINGS.add(POWER_SOUNDS_ENABLED); PRIVATE_SETTINGS.add(DOCK_SOUNDS_ENABLED); Loading
core/java/android/view/MotionEvent.java +34 −0 Original line number Diff line number Diff line Loading @@ -4166,6 +4166,40 @@ public final class MotionEvent extends InputEvent implements Parcelable { nativeWriteToParcel(mNativePtr, out); } /** * Get the x coordinate of the location where the pointer should be dispatched. * * This is required because a mouse event, such as from a touchpad, may contain multiple * pointers that should all be dispatched to the cursor position. * @hide */ public float getXDispatchLocation(int pointerIndex) { if (isFromSource(InputDevice.SOURCE_MOUSE)) { final float xCursorPosition = getXCursorPosition(); if (xCursorPosition != INVALID_CURSOR_POSITION) { return xCursorPosition; } } return getX(pointerIndex); } /** * Get the y coordinate of the location where the pointer should be dispatched. * * This is required because a mouse event, such as from a touchpad, may contain multiple * pointers that should all be dispatched to the cursor position. * @hide */ public float getYDispatchLocation(int pointerIndex) { if (isFromSource(InputDevice.SOURCE_MOUSE)) { final float yCursorPosition = getYCursorPosition(); if (yCursorPosition != INVALID_CURSOR_POSITION) { return yCursorPosition; } } return getY(pointerIndex); } /** * Transfer object for pointer coordinates. * Loading
core/java/android/view/ViewGroup.java +17 −19 Original line number Diff line number Diff line Loading @@ -2040,8 +2040,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager @Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { final float x = event.getX(pointerIndex); final float y = event.getY(pointerIndex); final float x = event.getXDispatchLocation(pointerIndex); final float y = event.getYDispatchLocation(pointerIndex); if (isOnScrollbarThumb(x, y) || isDraggingScrollBar()) { return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_ARROW); } Loading Loading @@ -2125,8 +2125,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager HoverTarget firstOldHoverTarget = mFirstHoverTarget; mFirstHoverTarget = null; if (!interceptHover && action != MotionEvent.ACTION_HOVER_EXIT) { final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getYDispatchLocation(0); final int childrenCount = mChildrenCount; if (childrenCount != 0) { final ArrayList<View> preorderedList = buildOrderedChildList(); Loading Loading @@ -2347,8 +2347,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Check what the child under the pointer says about the tooltip. final int childrenCount = mChildrenCount; if (childrenCount != 0) { final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getYDispatchLocation(0); final ArrayList<View> preorderedList = buildOrderedChildList(); final boolean customOrder = preorderedList == null Loading Loading @@ -2443,8 +2443,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager @Override protected boolean pointInHoveredChild(MotionEvent event) { if (mFirstHoverTarget != null) { return isTransformedTouchPointInView(event.getX(), event.getY(), mFirstHoverTarget.child, null); return isTransformedTouchPointInView(event.getXDispatchLocation(0), event.getYDispatchLocation(0), mFirstHoverTarget.child, null); } return false; } Loading Loading @@ -2513,8 +2513,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager public boolean onInterceptHoverEvent(MotionEvent event) { if (event.isFromSource(InputDevice.SOURCE_MOUSE)) { final int action = event.getAction(); final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getYDispatchLocation(0); if ((action == MotionEvent.ACTION_HOVER_MOVE || action == MotionEvent.ACTION_HOVER_ENTER) && isOnScrollbar(x, y)) { return true; Loading @@ -2535,8 +2535,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager // Send the event to the child under the pointer. final int childrenCount = mChildrenCount; if (childrenCount != 0) { final float x = event.getX(); final float y = event.getY(); final float x = event.getXDispatchLocation(0); final float y = event.getXDispatchLocation(0); final ArrayList<View> preorderedList = buildOrderedChildList(); final boolean customOrder = preorderedList == null Loading Loading @@ -2700,10 +2700,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final int childrenCount = mChildrenCount; if (newTouchTarget == null && childrenCount != 0) { final float x = isMouseEvent ? ev.getXCursorPosition() : ev.getX(actionIndex); final float y = isMouseEvent ? ev.getYCursorPosition() : ev.getY(actionIndex); final float x = ev.getXDispatchLocation(actionIndex); final float y = ev.getYDispatchLocation(actionIndex); // Find a child that can receive the event. // Scan children from front to back. final ArrayList<View> preorderedList = buildTouchDispatchChildList(); Loading Loading @@ -2757,8 +2755,8 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager } else { mLastTouchDownIndex = childIndex; } mLastTouchDownX = ev.getX(); mLastTouchDownY = ev.getY(); mLastTouchDownX = x; mLastTouchDownY = y; newTouchTarget = addTouchTarget(child, idBitsToAssign); alreadyDispatchedToNewTouchTarget = true; break; Loading Loading @@ -3287,7 +3285,7 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (ev.isFromSource(InputDevice.SOURCE_MOUSE) && ev.getAction() == MotionEvent.ACTION_DOWN && ev.isButtonPressed(MotionEvent.BUTTON_PRIMARY) && isOnScrollbarThumb(ev.getX(), ev.getY())) { && isOnScrollbarThumb(ev.getXDispatchLocation(0), ev.getYDispatchLocation(0))) { return true; } return false; Loading
core/proto/android/providers/settings/system.proto +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ message SystemSettingsProto { // orientationplot.py tool. // 0 = no, 1 = yes optional SettingProto window_orientation_listener_log = 3 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto show_key_presses = 4 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional DevOptions developer_options = 7; Loading
core/res/res/drawable/focus_event_pressed_key_background.xml 0 → 100644 +37 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright 2023 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:name="focus_event_pressed_key_background" android:shape="rectangle"> <!-- View background color --> <solid android:color="#AA000000" > </solid> <!-- View border color and width --> <stroke android:width="2dp" android:color="@android:color/white"> </stroke> <!-- The radius makes the corners rounded --> <corners android:radius="8dp"> </corners> </shape> No newline at end of file