summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/window.c13
-rw-r--r--src/ui/window.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 1599d372..105dcfb3 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -525,6 +525,7 @@ void init_Window(iWindow *d, iRect rect) {
525 d->pendingCursor = NULL; 525 d->pendingCursor = NULL;
526 d->isDrawFrozen = iTrue; 526 d->isDrawFrozen = iTrue;
527 d->isMouseInside = iTrue; 527 d->isMouseInside = iTrue;
528 d->focusGainedAt = 0;
528 uint32_t flags = 0; 529 uint32_t flags = 0;
529#if defined (iPlatformApple) 530#if defined (iPlatformApple)
530 SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl"); 531 SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl");
@@ -668,6 +669,12 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
668 d->isMouseInside = iTrue; 669 d->isMouseInside = iTrue;
669 postCommand_App("window.mouse.entered"); 670 postCommand_App("window.mouse.entered");
670 return iTrue; 671 return iTrue;
672 case SDL_WINDOWEVENT_TAKE_FOCUS:
673 SDL_SetWindowInputFocus(d->win);
674 return iTrue;
675 case SDL_WINDOWEVENT_FOCUS_GAINED:
676 d->focusGainedAt = SDL_GetTicks();
677 return iFalse;
671 default: 678 default:
672 break; 679 break;
673 } 680 }
@@ -699,6 +706,12 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) {
699 postRefresh_App(); 706 postRefresh_App();
700 return iTrue; 707 return iTrue;
701 } 708 }
709 if (event.type == SDL_KEYDOWN && SDL_GetTicks() - d->focusGainedAt < 10) {
710 /* Suspiciously close to when input focus was received. For example under openbox,
711 closing xterm with Ctrl+D will cause the keydown event to "spill" over to us.
712 As a workaround, ignore these events. */
713 return iFalse;
714 }
702 /* Map mouse pointer coordinate to our coordinate system. */ 715 /* Map mouse pointer coordinate to our coordinate system. */
703 if (event.type == SDL_MOUSEMOTION) { 716 if (event.type == SDL_MOUSEMOTION) {
704 setCursor_Window(d, SDL_SYSTEM_CURSOR_ARROW); /* default cursor */ 717 setCursor_Window(d, SDL_SYSTEM_CURSOR_ARROW); /* default cursor */
diff --git a/src/ui/window.h b/src/ui/window.h
index 3ede1578..18df0cf9 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 iBool isDrawFrozen; /* avoids premature draws while restoring window state */ 39 iBool isDrawFrozen; /* avoids premature draws while restoring window state */
40 iBool isMouseInside; 40 iBool isMouseInside;
41 uint32_t focusGainedAt;
41 SDL_Renderer *render; 42 SDL_Renderer *render;
42 iWidget * root; 43 iWidget * root;
43 float pixelRatio; 44 float pixelRatio;