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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 40215506..c5194ea0 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -524,6 +524,7 @@ void init_Window(iWindow *d, iRect rect) {
524 d->lastRect = rect; 524 d->lastRect = rect;
525 d->pendingCursor = NULL; 525 d->pendingCursor = NULL;
526 d->isDrawFrozen = iTrue; 526 d->isDrawFrozen = iTrue;
527 d->isMouseInside = iTrue;
527 uint32_t flags = 0; 528 uint32_t flags = 0;
528#if defined (iPlatformApple) 529#if defined (iPlatformApple)
529 SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl"); 530 SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl");
@@ -543,7 +544,7 @@ void init_Window(iWindow *d, iRect rect) {
543 if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { 544 if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) {
544 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); 545 SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect));
545 } 546 }
546 const iInt2 minSize = init_I2(425, 250); 547 const iInt2 minSize = init_I2(425, 300);
547 SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y); 548 SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y);
548 SDL_SetWindowTitle(d->win, "Lagrange"); 549 SDL_SetWindowTitle(d->win, "Lagrange");
549 /* Some info. */ { 550 /* Some info. */ {
@@ -655,6 +656,12 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
655 return iTrue; 656 return iTrue;
656 case SDL_WINDOWEVENT_LEAVE: 657 case SDL_WINDOWEVENT_LEAVE:
657 unhover_Widget(); 658 unhover_Widget();
659 d->isMouseInside = iFalse;
660 postCommand_App("window.mouse.exited");
661 return iTrue;
662 case SDL_WINDOWEVENT_ENTER:
663 d->isMouseInside = iTrue;
664 postCommand_App("window.mouse.entered");
658 return iTrue; 665 return iTrue;
659 default: 666 default:
660 break; 667 break;
@@ -812,6 +819,9 @@ iInt2 coord_Window(const iWindow *d, int x, int y) {
812} 819}
813 820
814iInt2 mouseCoord_Window(const iWindow *d) { 821iInt2 mouseCoord_Window(const iWindow *d) {
822 if (!d->isMouseInside) {
823 return init_I2(-1000000, -1000000);
824 }
815 int x, y; 825 int x, y;
816 SDL_GetMouseState(&x, &y); 826 SDL_GetMouseState(&x, &y);
817 return coord_Window(d, x, y); 827 return coord_Window(d, x, y);