### Godot version

 Latest 4.0.dev (a3a42159e31db27f8ae7c1ecad6a9ed417cb05de)

### System information

Ubuntu 22.04.1 LTS

### Issue description

![image](https://user-images.githubusercontent.com/85438892/214476911-0ce83a43-b959-4b13-88fd-d6b9af0cd63a.png)

### Steps to reproduce

Open any script

### Minimal reproduction project

N/A
_THREAD_SAFE_METHOD_
	List<WindowID>::Element *E = popup_list.find(p_window);
	while (E) {
		List<WindowID>::Element *F = E->next();
		WindowID win_id = E->get();
		popup_list.erase(E);
		_send_window_event(windows[win_id], DisplayServerX11::WINDOW_EVENT_CLOSE_REQUEST);
		E = F;
	}
}
bool DisplayServerX11::mouse_process_popups() {
	_THREAD_SAFE_METHOD_
	if (popup_list.is_empty()) {
		return false;
	}
	uint64_t delta = OS::get_singleton()->get_ticks_msec() - time_since_popup;
	if (delta < 250) {
		return false;
	}
	int number_of_screens = XScreenCount(x11_display);
	bool closed = false;
	for (int i = 0; i < number_of_screens; i++) {
		Window root, child;
		int root_x, root_y, win_x, win_y;
		unsigned int mask;
		if (XQueryPointer(x11_display, XRootWindow(x11_display, i), &root, &child, &root_x, &root_y, &win_x, &win_y, &mask)) {
			XWindowAttributes root_attrs;
			XGetWindowAttributes(x11_display, root, &root_attrs);
			Vector2i pos = Vector2i(root_attrs.x + root_x, root_attrs.y + root_y);
			if (mask != last_mouse_monitor_mask) {