From bfdda501cb01df95c968c9f5378bb91cd66eea87 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 11 Feb 2021 11:28:43 +0200 Subject: Windows: Draw something immediately when the window is opened Avoids having a flash of white or other system-provided default window contents when opening a window for the first time. --- src/ui/window.c | 5 +++++ src/ui/window.h | 1 + 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/ui/window.c b/src/ui/window.c index 2062a3bb..2d65a655 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -729,6 +729,7 @@ void init_Window(iWindow *d, iRect rect) { d->lastNotifiedSize = zero_I2(); d->pendingCursor = NULL; d->isDrawFrozen = iTrue; + d->isExposed = iFalse; d->isMouseInside = iTrue; d->focusGainedAt = 0; uint32_t flags = 0; @@ -849,6 +850,10 @@ static void invalidate_Window_(iWindow *d) { static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { switch (ev->event) { case SDL_WINDOWEVENT_EXPOSED: + if (!d->isExposed) { + drawBlank_Window_(d); /* avoid showing system-provided contents */ + d->isExposed = iTrue; + } /* Since we are manually controlling when to redraw the window, we are responsible for ensuring that window contents get redrawn after expose events. Under certain circumstances (e.g., under openbox), not doing this would mean that the window diff --git a/src/ui/window.h b/src/ui/window.h index 25d81e6f..5bde9065 100644 --- a/src/ui/window.h +++ b/src/ui/window.h @@ -38,6 +38,7 @@ struct Impl_Window { iRect lastRect; /* updated when window is moved/resized */ iInt2 lastNotifiedSize; /* keep track of horizontal/vertical notifications */ iBool isDrawFrozen; /* avoids premature draws while restoring window state */ + iBool isExposed; iBool isMouseInside; uint32_t focusGainedAt; SDL_Renderer *render; -- cgit v1.2.3