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