shithub: qk1

Download patch

ref: 8b1ca987787bf2ee8623f7f1f6f16793e9efa121
parent: b46dffd1b304e78844b91414ffb1dde28bc28305
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Nov 7 19:55:55 EST 2023

in (unix): process focus lost/gained

--- a/unix/in.c
+++ b/unix/in.c
@@ -6,7 +6,7 @@
 
 static cvar_t m_windowed = {"m_windowed", "1", true};
 static cvar_t m_filter = {"m_filter", "0", true};
-static int mouseon, oldmwin;
+static int mouseon, oldmwin, focuslost;
 static float olddx, olddy;
 static int mΔx, mΔy, oldmb;
 
@@ -34,8 +34,18 @@
 			Cbuf_AddText("menu_quit\n");
 			break;
 		case SDL_WINDOWEVENT:
-			if(event.window.event == SDL_WINDOWEVENT_RESIZED)
+			switch(event.window.event){
+			case SDL_WINDOWEVENT_RESIZED:
 				resized = 1;
+				break;
+			case SDL_WINDOWEVENT_FOCUS_LOST:
+				focuslost = mouseon;
+				IN_Grabm(0);
+				break;
+			case SDL_WINDOWEVENT_FOCUS_GAINED:
+				IN_Grabm(focuslost);
+				break;
+			}
 			break;
 		case SDL_MOUSEMOTION:
 			if(mouseon){