summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index cdb122be..dd9181ad 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -514,17 +514,25 @@ static void setupUserInterface_Window(iWindow *d) {
514 } 514 }
515} 515}
516 516
517static void updateRootSize_Window_(iWindow *d) { 517static void updateRootSize_Window_(iWindow *d, iBool notifyAlways) {
518 iInt2 *size = &d->root->rect.size; 518 iInt2 *size = &d->root->rect.size;
519 const iInt2 oldSize = *size; 519 const iInt2 oldSize = *size;
520 SDL_GetRendererOutputSize(d->render, &size->x, &size->y); 520 SDL_GetRendererOutputSize(d->render, &size->x, &size->y);
521 if (!isEqual_I2(oldSize, *size)) { 521 if (notifyAlways || !isEqual_I2(oldSize, *size)) {
522 arrange_Widget(d->root); 522 arrange_Widget(d->root);
523 postCommandf_App("window.resized width:%d height:%d", size->x, size->y); 523 postCommandf_App("window.resized width:%d height:%d", size->x, size->y);
524 postRefresh_App(); 524 postRefresh_App();
525 } 525 }
526} 526}
527 527
528void drawWhileResizing_Window(iWindow *d, int w, int h) {
529 /* This is called while a window resize is in progress, so we can be pretty confident
530 the size has actually changed. */
531 d->root->rect.size = mulf_I2(init_I2(w, h), d->pixelRatio);
532 arrange_Widget(d->root);
533 draw_Window(d);
534}
535
528static float pixelRatio_Window_(const iWindow *d) { 536static float pixelRatio_Window_(const iWindow *d) {
529#if defined (iPlatformMsys) 537#if defined (iPlatformMsys)
530 iUnused(d); 538 iUnused(d);
@@ -631,7 +639,7 @@ void init_Window(iWindow *d, iRect rect) {
631 init_Text(d->render); 639 init_Text(d->render);
632 setupUserInterface_Window(d); 640 setupUserInterface_Window(d);
633 postCommand_App("bindings.changed"); /* update from bindings */ 641 postCommand_App("bindings.changed"); /* update from bindings */
634 updateRootSize_Window_(d); 642 updateRootSize_Window_(d, iFalse);
635} 643}
636 644
637void deinit_Window(iWindow *d) { 645void deinit_Window(iWindow *d) {
@@ -692,11 +700,11 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
692 return iTrue; 700 return iTrue;
693 } 701 }
694 case SDL_WINDOWEVENT_RESIZED: 702 case SDL_WINDOWEVENT_RESIZED:
695 case SDL_WINDOWEVENT_SIZE_CHANGED: 703// case SDL_WINDOWEVENT_SIZE_CHANGED:
696 if (!isMaximized_Window_(d) && !d->isDrawFrozen) { 704 if (!isMaximized_Window_(d) && !d->isDrawFrozen) {
697 d->lastRect.size = init_I2(ev->data1, ev->data2); 705 d->lastRect.size = init_I2(ev->data1, ev->data2);
698 } 706 }
699 updateRootSize_Window_(d); 707 updateRootSize_Window_(d, iTrue /* we were already redrawing during the resize */);
700 return iTrue; 708 return iTrue;
701 case SDL_WINDOWEVENT_LEAVE: 709 case SDL_WINDOWEVENT_LEAVE:
702 unhover_Widget(); 710 unhover_Widget();
@@ -836,7 +844,7 @@ void draw_Window(iWindow *d) {
836 844
837void resize_Window(iWindow *d, int w, int h) { 845void resize_Window(iWindow *d, int w, int h) {
838 SDL_SetWindowSize(d->win, w, h); 846 SDL_SetWindowSize(d->win, w, h);
839 updateRootSize_Window_(d); 847 updateRootSize_Window_(d, iFalse);
840} 848}
841 849
842void setTitle_Window(iWindow *d, const iString *title) { 850void setTitle_Window(iWindow *d, const iString *title) {