summaryrefslogtreecommitdiff
path: root/src/i_video.c
diff options
context:
space:
mode:
authorSimon Howard2012-10-28 23:45:08 +0000
committerSimon Howard2012-10-28 23:45:08 +0000
commit993315afc4b1fddaf8952e7e55d1373b5052dd7c (patch)
tree94aa07d101ddced8404ceaa92ce051ed17fe2a88 /src/i_video.c
parenta1b2ce54d02823aa85c7df6aa016c567185451ae (diff)
parentad11652dcd8e0923432ad272e6535276c51d39eb (diff)
downloadchocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.tar.gz
chocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.tar.bz2
chocolate-doom-993315afc4b1fddaf8952e7e55d1373b5052dd7c.zip
Merge from trunk.
Subversion-branch: /branches/v2-branch Subversion-revision: 2537
Diffstat (limited to 'src/i_video.c')
-rw-r--r--src/i_video.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/src/i_video.c b/src/i_video.c
index 7ba4c8cd..959a1472 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -378,6 +378,37 @@ static void UpdateFocus(void)
screenvisible = (state & SDL_APPACTIVE) != 0;
}
+// Show or hide the mouse cursor. We have to use different techniques
+// depending on the OS.
+
+static void ShowCursor(boolean show)
+{
+ // On Windows, using SDL_ShowCursor() adds lag to the mouse input,
+ // so work around this by setting an invisible cursor instead. On
+ // other systems, it isn't possible to change the cursor, so this
+ // hack has to be Windows-only. (Thanks to entryway for this)
+
+#ifdef _WIN32
+ if (show)
+ {
+ SDL_SetCursor(cursors[1]);
+ }
+ else
+ {
+ SDL_SetCursor(cursors[0]);
+ }
+#else
+ SDL_ShowCursor(show);
+#endif
+
+ // When the cursor is hidden, grab the input.
+
+ if (!screensaver_mode)
+ {
+ SDL_WM_GrabInput(!show);
+ }
+}
+
void I_EnableLoadingDisk(void)
{
patch_t *disk;
@@ -532,12 +563,10 @@ void I_ShutdownGraphics(void)
{
if (initialized)
{
- SDL_SetCursor(cursors[1]);
- SDL_ShowCursor(1);
- SDL_WM_GrabInput(SDL_GRAB_OFF);
+ ShowCursor(true);
SDL_QuitSubSystem(SDL_INIT_VIDEO);
-
+
initialized = false;
}
}
@@ -895,17 +924,15 @@ static void UpdateGrab(void)
{
// Hide the cursor in screensaver mode
- SDL_SetCursor(cursors[0]);
+ ShowCursor(false);
}
else if (grab && !currently_grabbed)
{
- SDL_SetCursor(cursors[0]);
- SDL_WM_GrabInput(SDL_GRAB_ON);
+ ShowCursor(false);
}
else if (!grab && currently_grabbed)
{
- SDL_SetCursor(cursors[1]);
- SDL_WM_GrabInput(SDL_GRAB_OFF);
+ ShowCursor(true);
}
currently_grabbed = grab;