Android: Set window focus based on window touch, not global focus parentage

Since QtEditText is no longer focused on QtWindow touch,
onGlobalFocusChange event is no longer triggered, and so we cannot get
the parent View (QtWindow) of the current global focus object and set
it as the focused QWindow.

Move QWindow focus setting to be done directly under QtWindow onTouched.

Pick-to: 6.7
Change-Id: I292f197c64d170aa2f15a3118e6f861b59c906f5
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
(cherry picked from commit 1442a9ea479d197ed338f440d5106a7e195c4ee2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Petri Virkkunen 2024-07-26 14:23:29 +03:00 committed by Qt Cherry-pick Bot
parent e6211e49b9
commit 7cea4391ce
4 changed files with 1 additions and 20 deletions

View File

@ -149,7 +149,6 @@ class QtActivityDelegate extends QtActivityDelegateBase
r.width(), kbHeight);
return true;
});
registerGlobalFocusChangeListener(m_layout);
m_inputDelegate.setEditPopupMenu(new EditPopupMenu(m_activity, m_layout));
}

View File

@ -108,23 +108,6 @@ abstract class QtActivityDelegateBase
setUpLayout();
}
protected void registerGlobalFocusChangeListener(final View view) {
view.getViewTreeObserver().addOnGlobalFocusChangeListener(this::onGlobalFocusChanged);
}
private void onGlobalFocusChanged(View oldFocus, View newFocus) {
if (newFocus instanceof QtEditText) {
final QtWindow newWindow = (QtWindow) newFocus.getParent();
QtWindow.windowFocusChanged(true, newWindow.getId());
} else {
int id = -1;
if (oldFocus instanceof QtEditText) {
final QtWindow oldWindow = (QtWindow) oldFocus.getParent();
QtWindow.windowFocusChanged(false, oldWindow.getId());
}
}
}
void hideSplashScreen()
{
hideSplashScreen(0);

View File

@ -165,8 +165,6 @@ class QtEmbeddedDelegate extends QtActivityDelegateBase
{
m_view = view;
updateInputDelegate();
if (m_view != null)
registerGlobalFocusChangeListener(m_view);
}
// QtEmbeddedViewInterface implementation end

View File

@ -67,6 +67,7 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
@Override
public boolean onTouchEvent(MotionEvent event)
{
windowFocusChanged(true, getId());
if (m_editText != null && m_inputConnectionListener != null)
m_inputConnectionListener.onEditTextChanged(m_editText);