diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/window.c | 27 | ||||
-rw-r--r-- | src/ui/window.h | 1 |
2 files changed, 25 insertions, 3 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index a7ec37dd..19432691 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -507,6 +507,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
507 | theWindow_ = d; | 507 | theWindow_ = d; |
508 | iZap(d->cursors); | 508 | iZap(d->cursors); |
509 | d->initialPos = rect.pos; | 509 | d->initialPos = rect.pos; |
510 | d->lastRect = rect; | ||
510 | d->pendingCursor = NULL; | 511 | d->pendingCursor = NULL; |
511 | d->isDrawFrozen = iTrue; | 512 | d->isDrawFrozen = iTrue; |
512 | uint32_t flags = 0; | 513 | uint32_t flags = 0; |
@@ -525,7 +526,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
525 | exit(-2); | 526 | exit(-2); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | if (left_Rect(rect) >= 0) { | 529 | if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { |
529 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); | 530 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); |
530 | } | 531 | } |
531 | SDL_SetWindowMinimumSize(d->win, 400, 250); | 532 | SDL_SetWindowMinimumSize(d->win, 400, 250); |
@@ -596,6 +597,15 @@ SDL_Renderer *renderer_Window(const iWindow *d) { | |||
596 | return d->render; | 597 | return d->render; |
597 | } | 598 | } |
598 | 599 | ||
600 | static iBool isMaximized_Window_(const iWindow *d) { | ||
601 | #if !defined (iPlatformApple) | ||
602 | return (SDL_GetWindowFlags(d->win) & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED)) != 0; | ||
603 | #else | ||
604 | iUnused(d); | ||
605 | return iFalse; /* There is fullscreen mode but that is not handled at the moment. */ | ||
606 | #endif | ||
607 | } | ||
608 | |||
599 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | 609 | static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { |
600 | switch (ev->event) { | 610 | switch (ev->event) { |
601 | #if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX) | 611 | #if defined (LAGRANGE_ENABLE_WINDOWPOS_FIX) |
@@ -608,11 +618,22 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
608 | } | 618 | } |
609 | return iFalse; | 619 | return iFalse; |
610 | #endif | 620 | #endif |
611 | case SDL_WINDOWEVENT_MOVED: | 621 | case SDL_WINDOWEVENT_MOVED: { |
612 | /* No need to do anything. */ | 622 | if (!isMaximized_Window_(d)) { |
623 | d->lastRect.pos = init_I2(ev->data1, ev->data2); | ||
624 | iInt2 border = zero_I2(); | ||
625 | #if !defined (iPlatformApple) | ||
626 | SDL_GetWindowBordersSize(d->win, &border.y, &border.x, NULL, NULL); | ||
627 | #endif | ||
628 | d->lastRect.pos = max_I2(zero_I2(), sub_I2(d->lastRect.pos, border)); | ||
629 | } | ||
613 | return iTrue; | 630 | return iTrue; |
631 | } | ||
614 | case SDL_WINDOWEVENT_RESIZED: | 632 | case SDL_WINDOWEVENT_RESIZED: |
615 | case SDL_WINDOWEVENT_SIZE_CHANGED: | 633 | case SDL_WINDOWEVENT_SIZE_CHANGED: |
634 | if (!isMaximized_Window_(d)) { | ||
635 | d->lastRect.size = init_I2(ev->data1, ev->data2); | ||
636 | } | ||
616 | updateRootSize_Window_(d); | 637 | updateRootSize_Window_(d); |
617 | return iTrue; | 638 | return iTrue; |
618 | case SDL_WINDOWEVENT_LEAVE: | 639 | case SDL_WINDOWEVENT_LEAVE: |
diff --git a/src/ui/window.h b/src/ui/window.h index b067d30e..da4a2123 100644 --- a/src/ui/window.h +++ b/src/ui/window.h | |||
@@ -35,6 +35,7 @@ iDeclareTypeConstructionArgs(Window, iRect rect) | |||
35 | struct Impl_Window { | 35 | struct Impl_Window { |
36 | SDL_Window * win; | 36 | SDL_Window * win; |
37 | iInt2 initialPos; | 37 | iInt2 initialPos; |
38 | iRect lastRect; /* updated when window is moved/resized */ | ||
38 | iBool isDrawFrozen; /* avoids premature draws while restoring window state */ | 39 | iBool isDrawFrozen; /* avoids premature draws while restoring window state */ |
39 | SDL_Renderer *render; | 40 | SDL_Renderer *render; |
40 | iWidget * root; | 41 | iWidget * root; |