Input: Handle parent surface crops 1/2
- Surface Insets are set to offset the client content and draw a border around the client surface
(such as shadows in dialogs). Inputs sent to the client are offset such that 0,0 is the start
of the client content. When accounting for surface insets, check if the surface is already
cropped by a parent so that the input offset is not set twice.
- Restrict the touchable region to the input frame bounds.
Test: Open event in calendar. Try to close the event. The event is a dialog and draws shadows.
Test: Open app selector in secondary split screen. Ensure input does not go to primary split screen
window.
Bug: 120413463, 120460606
Change-Id: I0d519f9eb381664b1e71a924b13419dcc1170ba1
diff --git a/libs/ui/Rect.cpp b/libs/ui/Rect.cpp
index d8702e5..045db31 100644
--- a/libs/ui/Rect.cpp
+++ b/libs/ui/Rect.cpp
@@ -72,6 +72,14 @@
return *this;
}
+Rect& Rect::inset(int32_t left, int32_t top, int32_t right, int32_t bottom) {
+ this->left += left;
+ this->top += top;
+ this->right -= right;
+ this->bottom -= bottom;
+ return *this;
+}
+
const Rect Rect::operator +(const Point& rhs) const {
const Rect result(left + rhs.x, top + rhs.y, right + rhs.x, bottom + rhs.y);
return result;