diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-11 11:28:43 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-11 11:28:43 +0200 |
commit | bfdda501cb01df95c968c9f5378bb91cd66eea87 (patch) | |
tree | 0862ec95e4ba9f6080c5fa7f5e41bc51b049ea5d | |
parent | 66babe2b1e670012e8c36d219f20e6fa69462a9b (diff) |
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.
-rw-r--r-- | src/ui/window.c | 5 | ||||
-rw-r--r-- | src/ui/window.h | 1 |
2 files changed, 6 insertions, 0 deletions
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) { | |||
729 | d->lastNotifiedSize = zero_I2(); | 729 | d->lastNotifiedSize = zero_I2(); |
730 | d->pendingCursor = NULL; | 730 | d->pendingCursor = NULL; |
731 | d->isDrawFrozen = iTrue; | 731 | d->isDrawFrozen = iTrue; |
732 | d->isExposed = iFalse; | ||
732 | d->isMouseInside = iTrue; | 733 | d->isMouseInside = iTrue; |
733 | d->focusGainedAt = 0; | 734 | d->focusGainedAt = 0; |
734 | uint32_t flags = 0; | 735 | uint32_t flags = 0; |
@@ -849,6 +850,10 @@ static void invalidate_Window_(iWindow *d) { | |||
849 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | 850 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { |
850 | switch (ev->event) { | 851 | switch (ev->event) { |
851 | case SDL_WINDOWEVENT_EXPOSED: | 852 | case SDL_WINDOWEVENT_EXPOSED: |
853 | if (!d->isExposed) { | ||
854 | drawBlank_Window_(d); /* avoid showing system-provided contents */ | ||
855 | d->isExposed = iTrue; | ||
856 | } | ||
852 | /* Since we are manually controlling when to redraw the window, we are responsible | 857 | /* Since we are manually controlling when to redraw the window, we are responsible |
853 | for ensuring that window contents get redrawn after expose events. Under certain | 858 | for ensuring that window contents get redrawn after expose events. Under certain |
854 | circumstances (e.g., under openbox), not doing this would mean that the window | 859 | 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 { | |||
38 | iRect lastRect; /* updated when window is moved/resized */ | 38 | iRect lastRect; /* updated when window is moved/resized */ |
39 | iInt2 lastNotifiedSize; /* keep track of horizontal/vertical notifications */ | 39 | iInt2 lastNotifiedSize; /* keep track of horizontal/vertical notifications */ |
40 | iBool isDrawFrozen; /* avoids premature draws while restoring window state */ | 40 | iBool isDrawFrozen; /* avoids premature draws while restoring window state */ |
41 | iBool isExposed; | ||
41 | iBool isMouseInside; | 42 | iBool isMouseInside; |
42 | uint32_t focusGainedAt; | 43 | uint32_t focusGainedAt; |
43 | SDL_Renderer *render; | 44 | SDL_Renderer *render; |