diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-17 13:58:43 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-08-17 13:58:43 +0300 |
commit | 253cbf6605bd30aac1825213c4fd48b4296804d7 (patch) | |
tree | e65be0ea1988af83b54bbe619b9e27e4ca0fc701 /src/ui | |
parent | 3b11a2a13474c45ab45c62b109422f2035a34269 (diff) |
Window: Experimenting with draw-driven UI resize
The notification about UI resize will not occur until a draw
has been started, so we can avoid any unnecessary resize handling
between draws. May not work?
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/window.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 86d22b1c..64dcd6f2 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -221,12 +221,14 @@ static void updateSize_Window_(iWindow *d, iBool notifyAlways) { | |||
221 | windowSizeChanged_Window_(d); | 221 | windowSizeChanged_Window_(d); |
222 | const iBool isHoriz = (d->place.lastNotifiedSize.x != size->x); | 222 | const iBool isHoriz = (d->place.lastNotifiedSize.x != size->x); |
223 | const iBool isVert = (d->place.lastNotifiedSize.y != size->y); | 223 | const iBool isVert = (d->place.lastNotifiedSize.y != size->y); |
224 | postCommandf_App("window.resized width:%d height:%d horiz:%d vert:%d", | 224 | if (!isEqual_I2(*size, d->place.lastNotifiedSize)) { |
225 | size->x, | 225 | postCommandf_App("window.resized width:%d height:%d horiz:%d vert:%d", |
226 | size->y, | 226 | size->x, |
227 | isHoriz, | 227 | size->y, |
228 | isVert); | 228 | isHoriz, |
229 | postCommand_App("widget.overflow"); /* check bounds with updated sizes */ | 229 | isVert); |
230 | postCommand_App("widget.overflow"); /* check bounds with updated sizes */ | ||
231 | } | ||
230 | postRefresh_App(); | 232 | postRefresh_App(); |
231 | d->place.lastNotifiedSize = *size; | 233 | d->place.lastNotifiedSize = *size; |
232 | } | 234 | } |
@@ -237,7 +239,7 @@ void drawWhileResizing_Window(iWindow *d, int w, int h) { | |||
237 | the size has actually changed. */ | 239 | the size has actually changed. */ |
238 | d->size = coord_Window(d, w, h); | 240 | d->size = coord_Window(d, w, h); |
239 | windowSizeChanged_Window_(d); | 241 | windowSizeChanged_Window_(d); |
240 | draw_Window(d); | 242 | draw_Window(d); |
241 | } | 243 | } |
242 | 244 | ||
243 | static float pixelRatio_Window_(const iWindow *d) { | 245 | static float pixelRatio_Window_(const iWindow *d) { |
@@ -489,7 +491,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
489 | SDL_GetRendererOutputSize(d->render, &d->size.x, &d->size.y); | 491 | SDL_GetRendererOutputSize(d->render, &d->size.x, &d->size.y); |
490 | setupUserInterface_Window(d); | 492 | setupUserInterface_Window(d); |
491 | postCommand_App("~bindings.changed"); /* update from bindings */ | 493 | postCommand_App("~bindings.changed"); /* update from bindings */ |
492 | updateSize_Window_(d, iFalse); | 494 | //updateSize_Window_(d, iFalse); |
493 | /* Load the border shadow texture. */ { | 495 | /* Load the border shadow texture. */ { |
494 | SDL_Surface *surf = loadImage_(&imageShadow_Embedded, 0); | 496 | SDL_Surface *surf = loadImage_(&imageShadow_Embedded, 0); |
495 | d->borderShadow = SDL_CreateTextureFromSurface(d->render, surf); | 497 | d->borderShadow = SDL_CreateTextureFromSurface(d->render, surf); |
@@ -728,7 +730,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
728 | } | 730 | } |
729 | case SDL_WINDOWEVENT_RESIZED: | 731 | case SDL_WINDOWEVENT_RESIZED: |
730 | if (d->isMinimized) { | 732 | if (d->isMinimized) { |
731 | updateSize_Window_(d, iTrue); | 733 | //updateSize_Window_(d, iTrue); |
732 | return iTrue; | 734 | return iTrue; |
733 | } | 735 | } |
734 | if (unsnap_Window_(d, NULL)) { | 736 | if (unsnap_Window_(d, NULL)) { |
@@ -739,7 +741,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
739 | //printf("normal rect set (resize)\n"); fflush(stdout); | 741 | //printf("normal rect set (resize)\n"); fflush(stdout); |
740 | } | 742 | } |
741 | checkPixelRatioChange_Window_(d); | 743 | checkPixelRatioChange_Window_(d); |
742 | updateSize_Window_(d, iTrue /* we were already redrawing during the resize */); | 744 | //updateSize_Window_(d, iTrue /* we were already redrawing during the resize */); |
743 | postRefresh_App(); | 745 | postRefresh_App(); |
744 | return iTrue; | 746 | return iTrue; |
745 | case SDL_WINDOWEVENT_RESTORED: | 747 | case SDL_WINDOWEVENT_RESTORED: |
@@ -1014,7 +1016,7 @@ void draw_Window(iWindow *d) { | |||
1014 | if (d->isDrawFrozen) { | 1016 | if (d->isDrawFrozen) { |
1015 | return; | 1017 | return; |
1016 | } | 1018 | } |
1017 | #if defined (iPlatformMobile) | 1019 | //#if defined (iPlatformMobile) |
1018 | /* Check if root needs resizing. */ { | 1020 | /* Check if root needs resizing. */ { |
1019 | iInt2 renderSize; | 1021 | iInt2 renderSize; |
1020 | SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y); | 1022 | SDL_GetRendererOutputSize(d->render, &renderSize.x, &renderSize.y); |
@@ -1023,7 +1025,7 @@ void draw_Window(iWindow *d) { | |||
1023 | processEvents_App(postedEventsOnly_AppEventMode); | 1025 | processEvents_App(postedEventsOnly_AppEventMode); |
1024 | } | 1026 | } |
1025 | } | 1027 | } |
1026 | #endif | 1028 | //#endif |
1027 | const int winFlags = SDL_GetWindowFlags(d->win); | 1029 | const int winFlags = SDL_GetWindowFlags(d->win); |
1028 | const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; | 1030 | const iBool gotFocus = (winFlags & SDL_WINDOW_INPUT_FOCUS) != 0; |
1029 | iPaint p; | 1031 | iPaint p; |