Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(win32device): hold the pointer on a borderless or fullscreen game
Olcay Seygan686f5e44c874
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7d9bf1ba4..563ba830f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -604,6 +604,7 @@ found and fixed — EA's own, not port damage.**- Tooltips stay on the screen. A tooltip is drawn to the right of the pointer, and near the right or bottom edge it jumps to the other side to make room, which was all the original code did about edges - the man who wrote it left a note saying so. Nothing then checked where it had jumped to. A wide one, and the game will wrap a tooltip to the full width of the screen when the text asks for it, jumped clean off the left edge with the first half of the sentence outside the monitor; a long narrow one hovered near the top went off the top. Both are put back on the screen now, and the pointer sits over the corner of the box rather than the words going where nobody can read them.- The rank screen is one painting instead of a stretched one. It is sized from that painting at the same scale as everything else and centred on the screen, rather than multiplied out separately across and down from the corner it was authored in - which on a widescreen monitor made it a third too wide and pushed it off centre.- Borderless fullscreen: start with `-borderless` and the game fills the screen at your desktop resolution with no frame and no display mode change, so alt-tab is instant, nothing on the desktop gets shuffled around behind it, and a second monitor stays usable. Screen-edge scrolling works there, the way it does in fullscreen. The loading picture still opens as its own small window with your desktop around it, and the game only takes the screen once it has something to draw.+- Borderless and fullscreen keep the mouse on the game's own screen while you are playing. With a second monitor beside it the pointer slid straight over the edge onto the other screen, so edge-scrolling toward that side did nothing and the next click landed on your desktop. The game has asked for the pointer to be held since 2003, but only a mouse driver the game never uses ever did it. Alt-tab still lets go, and coming back takes the pointer only once you move it over the game again. A plain window leaves it free, as before.- Fullscreen, borderless and windowed are one saved setting now, so borderless no longer means adding a switch to your shortcut every time. `WindowMode` in `Options.ini` takes 0, 1 or 2 in that order; a switch on the command line still wins for that one run. Picking a different one applies when you press Accept instead of the next time you start the game: the window loses or gains its frame and the display device is rebuilt on the spot. Borderless takes your desktop resolution and nothing else, so while it is selected the resolution list greys out and the other two modes hand it straight back.- Antialiasing is a saved setting as well: `MSAA` in `Options.ini`, 0 for off through 4 for sixteen samples. `-msaa 4` still works and still wins for that run. Whatever your card will not give is stepped down instead of refused, so asking for six samples gets you four rather than nothing.- Texture filtering is yours to set. `TextureFilter` in `Options.ini` takes 0 for bilinear, 1 fordiff --git a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/GameClient/Win32Mouse.h b/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/GameClient/Win32Mouse.hindex d67863c00..549b4ced3 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/GameClient/Win32Mouse.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/GameClient/Win32Mouse.h@@ -111,7 +111,8 @@ protected:Bool m_lostFocus; ///< flag if window has lost focues and mouse should stop being updated.Bool m_cursorInWindow; ///< is the pointer over our client area right now, asked of Windows each frameBool m_positionReported; ///< has a window message ever told us where the pointer is-}; // end Win32Mouse+ Bool m_cursorClipped; ///< did update() clip the pointer to the window, and so owes the release+}; // end Win32Mouse// INLINING ///////////////////////////////////////////////////////////////////diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cppindex c8c395a95..09fdcf995 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/GameClient/Win32Mouse.cpp@@ -31,6 +31,7 @@#include <windows.h>#include "Common/Debug.h"+#include "GameClient/Display.h"#include "GameClient/GameClient.h"#include "Win32Device/GameClient/Win32Mouse.h"#include "WinMain.h"@@ -43,6 +44,7 @@// EXTERN /////////////////////////////////////////////////////////////////////////////////////////extern Win32Mouse *TheWin32Mouse;+extern Bool ApplicationIsBorderless;HCURSOR cursorResources[Mouse::NUM_MOUSE_CURSORS][MAX_2D_CURSOR_DIRECTIONS];///////////////////////////////////////////////////////////////////////////////////////////////////@@ -283,6 +285,7 @@ Win32Mouse::Win32Mouse( void )m_lostFocus = FALSE;m_cursorInWindow = TRUE;m_positionReported = FALSE;+ m_cursorClipped = FALSE;} // end Win32Mouse//-------------------------------------------------------------------------------------------------@@ -357,6 +360,35 @@ void Win32Mouse::update( void )if( m_positionReported == FALSE && m_cursorInWindow )setPosition( clientPos.x, clientPos.y );+ //+ // A window that covers a screen, borderless or fullscreen, keeps the pointer while it has the+ // focus. Screen-edge scrolling reads the edge of that screen, and with a second monitor beside it+ // the pointer walked straight over the edge onto the other one. WndProc has asked the mouse for+ // this clip since 2003, but only the DirectInput mouse ever set one, and this is the mouse the+ // game makes. The pointer is taken once it is over the game, so activating from the taskbar+ // does not snatch it across the desktop; the clip is checked every frame, so it follows the+ // window through a mode change and comes back if something else released it. A plain window has+ // no edge scrolling and leaves the pointer free.+ //+ const Bool coversScreen = TheDisplay && ( !TheDisplay->getWindowed() || ApplicationIsBorderless );+ if( coversScreen && ::GetForegroundWindow() == ApplicationHWnd )+ {+ RECT window;+ RECT clip;+ ::GetWindowRect( ApplicationHWnd, &window );+ ::GetClipCursor( &clip );+ if( m_cursorInWindow && !::EqualRect( &window, &clip ) )+ {+ ::ClipCursor( &window );+ m_cursorClipped = TRUE;+ }+ }+ else if( m_cursorClipped )+ {+ ::ClipCursor( NULL );+ m_cursorClipped = FALSE;+ }+// extendMouse::update();