@@ -1903,14 +1903,84 @@ DisplayServer::WindowID DisplayServerX11::create_sub_window(WindowMode p_mode, V
19031903void DisplayServerX11::show_window (WindowID p_id) {
19041904 _THREAD_SAFE_METHOD_
19051905
1906- const WindowData &wd = windows[p_id];
1906+ WindowData &wd = windows[p_id];
19071907 popup_open (p_id);
19081908
19091909 DEBUG_LOG_X11 (" show_window: %lu (%u) \n " , wd.x11_window , p_id);
19101910
19111911 XMapWindow (x11_display, wd.x11_window );
19121912 XSync (x11_display, False);
19131913 _validate_mode_on_map (p_id);
1914+
1915+ if (p_id == MAIN_WINDOW_ID) {
1916+ // Get main window size for boot splash drawing.
1917+ bool get_config_event = false ;
1918+
1919+ // Search the X11 event queue for ConfigureNotify events and process all that are currently queued early.
1920+ {
1921+ MutexLock mutex_lock (events_mutex);
1922+
1923+ for (uint32_t event_index = 0 ; event_index < polled_events.size (); ++event_index) {
1924+ XEvent &config_event = polled_events[event_index];
1925+ if (config_event.type == ConfigureNotify) {
1926+ _window_changed (&config_event);
1927+ get_config_event = true ;
1928+ }
1929+ }
1930+ XEvent config_event;
1931+ while (XCheckTypedEvent (x11_display, ConfigureNotify, &config_event)) {
1932+ _window_changed (&config_event);
1933+ get_config_event = true ;
1934+ }
1935+ }
1936+
1937+ // Estimate maximize/full screen window size, ConfigureNotify may arrive only after maximize animation is finished.
1938+ if (!get_config_event && (wd.maximized || wd.fullscreen )) {
1939+ int screen = window_get_current_screen (p_id);
1940+ Size2i sz;
1941+ if (wd.maximized ) {
1942+ sz = screen_get_usable_rect (screen).size ;
1943+ if (!wd.borderless ) {
1944+ Atom prop = XInternAtom (x11_display, " _NET_FRAME_EXTENTS" , True);
1945+ if (prop != None) {
1946+ Atom type;
1947+ int format;
1948+ unsigned long len;
1949+ unsigned long remaining;
1950+ unsigned char *data = nullptr ;
1951+ if (XGetWindowProperty (x11_display, wd.x11_window , prop, 0 , 4 , False, AnyPropertyType, &type, &format, &len, &remaining, &data) == Success) {
1952+ if (format == 32 && len == 4 && data) {
1953+ long *extents = (long *)data;
1954+ sz.width -= extents[0 ] + extents[1 ]; // left, right
1955+ sz.height -= extents[2 ] + extents[3 ]; // top, bottom
1956+ }
1957+ XFree (data);
1958+ }
1959+ }
1960+ }
1961+ } else {
1962+ sz = screen_get_size (screen);
1963+ }
1964+ if (sz == Size2i ()) {
1965+ return ;
1966+ }
1967+
1968+ wd.size = sz;
1969+ #if defined(RD_ENABLED)
1970+ if (rendering_context) {
1971+ rendering_context->window_set_size (p_id, sz.width , sz.height );
1972+ }
1973+ #endif
1974+ #if defined(GLES3_ENABLED)
1975+ if (gl_manager) {
1976+ gl_manager->window_resize (p_id, sz.width , sz.height );
1977+ }
1978+ if (gl_manager_egl) {
1979+ gl_manager_egl->window_resize (p_id, sz.width , sz.height );
1980+ }
1981+ #endif
1982+ }
1983+ }
19141984}
19151985
19161986void DisplayServerX11::delete_sub_window (WindowID p_id) {
0 commit comments