return SDL_IsTextInputActive() != 0;
}
-void VID_SetMouse(qbool relative, qbool hidecursor)
+static void VID_SetMouse(qbool relative, qbool hidecursor)
{
#ifndef DP_MOBILETOUCH
#ifdef MACOSX
in_windowmouse_y = y;
}
+ //Con_Printf("Mouse position: in_mouse %f %f in_windowmouse %f %f\n", in_mouse_x, in_mouse_y, in_windowmouse_x, in_windowmouse_y);
+
VID_BuildJoyState(&joystate);
VID_ApplyJoyState(&joystate);
}
break;
}
+ vid_activewindow = !vid_hidden && vid_hasfocus;
+
// enable/disable sound on focus gain/loss
- if ((!vid_hidden && vid_activewindow) || !snd_mutewhenidle.integer)
+ if (vid_activewindow || !snd_mutewhenidle.integer)
{
if (!sound_active)
{
sound_active = false;
}
}
+
+ if (!vid_activewindow || key_consoleactive || scr_loading)
+ VID_SetMouse(false, false);
+ else if (key_dest == key_menu || key_dest == key_menu_grabbed)
+ VID_SetMouse(vid_mouse.integer && !in_client_mouse && !vid_touchscreen.integer, !vid_touchscreen.integer);
+ else
+ VID_SetMouse(vid_mouse.integer && !cl.csqc_wantsmousemove && cl_prydoncursor.integer <= 0 && (!cls.demoplayback || cl_demo_mousegrab.integer) && !vid_touchscreen.integer, !vid_touchscreen.integer);
}
/////////////////
Con_Printf(CON_ERROR "ERROR: can't %s vsync because %s\n", vsyncwanted ? "activate" : "deactivate", SDL_GetError());
}
+static void VID_SetHints_c(cvar_t *var)
+{
+ SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, vid_mouse_clickthrough.integer ? "1" : "0");
+ SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, vid_minimize_on_focus_loss.integer ? "1" : "0");
+}
+
void VID_Init (void)
{
SDL_version version;
Cvar_RegisterCallback(&vid_resizable, VID_ChangeDisplay_c);
Cvar_RegisterCallback(&vid_borderless, VID_ChangeDisplay_c);
Cvar_RegisterCallback(&vid_vsync, VID_SetVsync_c);
+ Cvar_RegisterCallback(&vid_mouse_clickthrough, VID_SetHints_c);
+ Cvar_RegisterCallback(&vid_minimize_on_focus_loss, VID_SetHints_c);
if (SDL_Init(SDL_INIT_VIDEO) < 0)
Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
#endif
}
+ // DPI scaling prevents use of the native resolution, causing blurry rendering
+ // and/or mouse cursor problems, so we need to opt-out.
+#ifdef WIN32
+ SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "1");
+#endif
- if (vid_mouse_clickthrough.integer)
- SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
+ VID_SetHints_c(NULL);
SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER, 1);
SDL_GL_SetAttribute (SDL_GL_RED_SIZE, 8);
void VID_Finish (void)
{
- vid_activewindow = !vid_hidden && vid_hasfocus;
-
VID_UpdateGamma();
if (!vid_hidden)