### Godot version

v4.2.dev.custom_build [c3b0a92c3]

### System information

Debian Linux X11 Xfce

### Issue description

In the following scene tree it is not possible to write anything in `LineEditB`.
![image](https://github.com/godotengine/godot/assets/6299227/ce5f696a-d86a-402f-98f7-6a762f15543e)

I would expect, that it is possible to focus `LineEditB` with a mouse click and write into it.

Regression from #58334

### Steps to reproduce

1. Load and run MRP
2. Mouse Click into the left LineEditB
3. Type Keyboard => No letters appear in the LineEditB

Variant:

1. Load and run MRP
2. Mouse Click into the right LineEditA
3. Mouse Click into the left LineEditB
4. Type Keyboard => Letters appear in LineEditA instead of LineEditB


### Minimal reproduction project

[BugKeyInputRouting.zip](https://github.com/godotengine/godot/files/11994804/BugKeyInputRouting.zip)

ERR_READ_THREAD_GUARD_V(false);
	return gui.dragging;
}
bool Viewport::gui_is_drag_successful() const {
	ERR_READ_THREAD_GUARD_V(false);
	return gui.drag_successful;
}
void Viewport::set_input_as_handled() {
	ERR_MAIN_THREAD_GUARD;
	if (!handle_input_locally) {
		ERR_FAIL_COND(!is_inside_tree());
		Viewport *vp = this;
		while (true) {
			if (Object::cast_to<Window>(vp)) {
				break;
			}
			if (!vp->get_parent()) {
				break;
			}
			vp = vp->get_parent()->get_viewport();
		}
		if (vp != this) {
			vp->set_input_as_handled();
			return;
		}
	}
	local_input_handled = true;
}
bool Viewport::is_input_handled() const {