Fix XSendEvent crash & bootsplash.

Fixes a crash due to an Xlib error, as well as ensures that Godot
holds the correct size of the window after window modes have been
applied, before exiting the DisplayServerX11 constructor. This ensures
the bootsplash will be displayed with the correct dimensions.

Fixes #65320
This commit is contained in:
MatthewZelriche 2022-09-04 16:46:37 -06:00
parent 733e0be8ec
commit ef02f06b8c

View file

@ -4900,6 +4900,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
} }
} }
show_window(main_window); show_window(main_window);
XSync(x11_display, False);
_validate_mode_on_map(main_window);
#if defined(VULKAN_ENABLED) #if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") { if (rendering_driver == "vulkan") {
@ -5046,24 +5048,13 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
} }
cursor_set_shape(CURSOR_BUSY); cursor_set_shape(CURSOR_BUSY);
Vector<XEvent> save_events; // Search the X11 event queue for ConfigureNotify events and process all
while (XPending(x11_display) > 0) { // that are currently queued early, so we can get the final window size
XEvent xevent{ 0 }; // for correctly drawing of the bootsplash.
XNextEvent(x11_display, &xevent); XEvent config_event;
if (xevent.type == ConfigureNotify) { while (XCheckTypedEvent(x11_display, ConfigureNotify, &config_event)) {
_window_changed(&xevent); _window_changed(&config_event);
} else {
// Don't discard this event, we must resend it...
save_events.push_back(xevent);
}
} }
// Resend events that would have been dropped by the early event queue
// processing we just performed.
for (XEvent &ev : save_events) {
XSendEvent(x11_display, ev.xany.window, False, 0, &ev);
}
events_thread.start(_poll_events_thread, this); events_thread.start(_poll_events_thread, this);
_update_real_mouse_position(windows[MAIN_WINDOW_ID]); _update_real_mouse_position(windows[MAIN_WINDOW_ID]);