From 9062ac91af1c42749be8aa3d688ad7c3f7cc0b85 Mon Sep 17 00:00:00 2001 From: cutealien Date: Tue, 5 May 2020 13:19:42 +0000 Subject: [PATCH] ICursorControl::isVisible is now always returning the flag that was set in setVisible. This changes the behaviour on Win32 somewhat when Windows returned a CURSOR_SUPPRESSED state (touch-screen input hiding cursor globally). Previously we set IsVisible it to false when CURSOR_SUPPRESSED was set. Also we handle the CURSOR_SUPPRESSED state slightly different now and still try to hide cursors once when requested. Reason for the change is that the old behaviour made it harder to recover from touch-screens hiding the cursor because Irrlicht didn't know anymore which state is _should_ have. This also unifies the behaviour on all drivers as the other drivers already returned the visible flag independent of the system being able to actually show the cursor. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6109 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 4 ++++ include/ICursorControl.h | 2 +- source/Irrlicht/CIrrDeviceWin32.h | 16 ++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/changes.txt b/changes.txt index 1e021bbe..0e1abae7 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,9 @@ -------------------------- Changes in 1.9 (not yet released) +- ICursorControl::isVisible is now always returning the flag set in setVisible. + This changes the behaviour on Win32 somewhat when Windows returned a CURSOR_SUPPRESSED state (touch-screen input). + Previously we set IsVisible it to false when CURSOR_SUPPRESSED was set. + Also we handle the CURSOR_SUPPRESSED state slightly different now and still try to hide cursors once when requested. - Improvements to B3D writer for speed, readability and handling of low framerate animations. Thanks @JLouisB for the patch (For more info, see: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=50067&start=15) - Add another render pass ESNRP_GUI which is drawn last and is p.E. useful for rendering gui nodes in the scenemanager. diff --git a/include/ICursorControl.h b/include/ICursorControl.h index 4597bf37..13c99c45 100644 --- a/include/ICursorControl.h +++ b/include/ICursorControl.h @@ -104,7 +104,7 @@ namespace gui virtual void setVisible(bool visible) = 0; //! Returns if the cursor is currently visible. - /** \return True if the cursor is visible, false if not. */ + /** \return True if the cursor flag is set to visible, false if not. */ virtual bool isVisible() const = 0; //! Sets the new position of the cursor. diff --git a/source/Irrlicht/CIrrDeviceWin32.h b/source/Irrlicht/CIrrDeviceWin32.h index b32da282..9e64a13e 100644 --- a/source/Irrlicht/CIrrDeviceWin32.h +++ b/source/Irrlicht/CIrrDeviceWin32.h @@ -148,11 +148,9 @@ namespace irr while ( gotCursorInfo ) { #ifdef CURSOR_SUPPRESSED - // new flag for Windows 8, where cursor - // might be suppressed for touch interface - if (info.flags == CURSOR_SUPPRESSED) + // Since Windows 8 the cursor can be suppressed by a touch interface + if (visible && info.flags == CURSOR_SUPPRESSED) { - visible=false; break; } #endif @@ -173,6 +171,16 @@ namespace irr // yes, it really must be set each time info.cbSize = sizeof(CURSORINFO); gotCursorInfo = GetCursorInfo(&info); + +#ifdef CURSOR_SUPPRESSED + // Not sure if a cursor which we tried to hide still can be suppressed. + // I have no touch-display for testing this and MSDN doesn't describe it. + // But adding this check shouldn't hurt and might prevent an endless loop. + if (!visible && info.flags == CURSOR_SUPPRESSED) + { + break; + } +#endif } IsVisible = visible; }