Re: [hatari-devel] Mouse pointer not reset when loading save state from menu

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On torstai 14 kesäkuu 2012, Charlie Nolan wrote:
> When loading a save state from the F12 menu, Hatari does not reset the
> mouse pointer as it does when leaving the F12 menu normally.

What means "does not reset the mouse pointer"?


> This causes the host mouse cursor to become visible

Does this happen on Linux?  With which SDL version?

As far as I can see from code, the cursor should be hidden
whenever one exits from a dialog, except if one:
* invoked file selector with keyboard shortcut
  (not from one of the options dialog), AND
* there was some kind of an error.

(If there was an error, you should see some message in console.)

Attached patch should fix that corner case.
Does that help?


> and not be aligned properly with the emulated mouse, potentially
> rendering large segments of the emulated screen inaccessible.

There's nothing guaranteeing sync (if some program e.g. interprets
IKBD events differently for its own mouse).

Only thing Hatari does is center the host cursor position to
Hatari window whenever:
* There's cold reset
* Falcon changes screen size
  (which can be pretty annoying when Falcon screen size
   changes frequently like it does at boot)

And restoring (after dialog closes) the position mouse had before
error/notice/options dialog was opened.

Position restore isn't done when exiting file selector because that's
called from many places within F12 options dialog, whereas the only
place when it's called directly is from floppy selection shortcut key.


	- Eero
diff -r dffd611d2de7 src/gui-sdl/dlgFileSelect.c
--- a/src/gui-sdl/dlgFileSelect.c	Sat Jun 16 11:21:11 2012 +0300
+++ b/src/gui-sdl/dlgFileSelect.c	Mon Jun 18 23:17:14 2012 +0300
@@ -458,12 +458,12 @@
 {
 	struct dirent **files = NULL;
 	char *pStringMem;
-	char *retpath;
+	char *retpath = NULL;
 	const char *home;
 	char *path, *fname;                 /* The actual file and path names */
 	bool reloaddir = true;              /* Do we have to reload the directory file list? */
 	int retbut;
-	int oldcursorstate;
+	bool bOldMouseVisibility;
 	int selection;                      /* The selection index */
 	char *zipfilename;                  /* Filename in zip file */
 	char *zipdir;
@@ -487,6 +487,10 @@
 	fname[0] = 0;
 	path[0] = 0;
 
+	/* Save mouse state and enable cursor */
+	bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
+	SDL_ShowCursor(SDL_ENABLE);
+
 	SDLGui_CenterDlg(fsdlg);
 	if (bAllowNew)
 	{
@@ -511,8 +515,7 @@
 		if (!(File_DirExists(path) || getcwd(path, FILENAME_MAX)))
 		{
 			perror("SDLGui_FileSelect: non-existing path and CWD failed");
-			free(pStringMem);
-			return NULL;
+			goto clean_exit;
 		}
 	}
 
@@ -521,11 +524,6 @@
 	File_ShrinkName(dlgpath, path, DLGPATH_SIZE);
 	File_ShrinkName(dlgfname, fname, DLGFNAME_SIZE);
 
-	/* Save old mouse cursor state and enable cursor */
-	oldcursorstate = SDL_ShowCursor(SDL_QUERY);
-	if (oldcursorstate == SDL_DISABLE)
-		SDL_ShowCursor(SDL_ENABLE);
-
 	do
 	{
 		if (reloaddir)
@@ -538,8 +536,7 @@
 				if(!files)
 				{
 					fprintf(stderr, "SDLGui_FileSelect: ZIP_GetFilesDir error!\n");
-					free(pStringMem);
-					return NULL;
+					goto clean_exit;
 				}
 			}
 			else
@@ -557,8 +554,7 @@
 			if (entries < 0)
 			{
 				fprintf(stderr, "SDLGui_FileSelect: Path not found.\n");
-				free(pStringMem);
-				return NULL;
+				goto clean_exit;
 			}
 
 			/* reload always implies refresh */
@@ -582,8 +578,7 @@
 		{
 			if (!DlgFileSelect_RefreshEntries(files, path, browsingzip))
 			{
-				free(pStringMem);
-				return NULL;
+				goto clean_exit;
 			}
 			refreshentries = false;
 		}
@@ -600,8 +595,7 @@
 			if (!tempstr)
 			{
 				perror("Error while allocating temporary memory in SDLGui_FileSelect()");
-				free(pStringMem);
-				return NULL;
+				goto clean_exit;
 			}
 
 			if (browsingzip == true)
@@ -610,8 +604,7 @@
 						   zipdir, files[retbut-SGFSDLG_ENTRYFIRST+ypos]->d_name))
 				{
 					fprintf(stderr, "SDLGui_FileSelect: Path name too long!\n");
-					free(pStringMem);
-					return NULL;
+					goto clean_exit;
 				}
 				/* directory? */
 				if (File_DoesFileNameEndWithSlash(tempstr))
@@ -665,8 +658,7 @@
 						   path, files[retbut-SGFSDLG_ENTRYFIRST+ypos]->d_name))
 				{
 					fprintf(stderr, "SDLGui_FileSelect: Path name too long!\n");
-					free(pStringMem);
-					return NULL;
+					goto clean_exit;
 				}
 				if (File_DirExists(tempstr))
 				{
@@ -812,9 +804,6 @@
 	while (retbut!=SGFSDLG_OKAY && retbut!=SGFSDLG_CANCEL
 	       && retbut!=SDLGUI_QUIT && retbut != SDLGUI_ERROR && !bQuitProgram);
 
-	if (oldcursorstate == SDL_DISABLE)
-		SDL_ShowCursor(SDL_DISABLE);
-
 	files_free(files);
 
 	if (browsingzip)
@@ -832,6 +821,8 @@
 	}
 	else
 		retpath = NULL;
+clean_exit:
+	SDL_ShowCursor(bOldMouseVisibility);
 	free(pStringMem);
 	return retpath;
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/