Skip to content

Commit 127830e

Browse files
committed
Unified keyboard focus change into a single public function.
1 parent 377c02c commit 127830e

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

GeneralsMD/Code/GameEngine/Include/GameClient/Keyboard.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ class Keyboard : public SubsystemInterface
105105
messages and put them on the
106106
stream for the raw state. */
107107

108-
virtual void loseFocus(); ///< called when window has lost focus
109-
virtual void regainFocus(); ///< called when window has regained focus
108+
virtual void toggleFocus(); ///< called when window has lost focus and has regained focus
110109
// simplified versions where the caller doesn't care which key type was pressed.
111110
Bool isShift();
112111
Bool isCtrl();
@@ -122,8 +121,6 @@ class Keyboard : public SubsystemInterface
122121
WideChar translateKey( WideChar keyCode ); ///< translate key code to printable UNICODE char
123122
WideChar getPrintableKey( KeyDefType key, Int state );
124123
enum { MAX_KEY_STATES = 3};
125-
private:
126-
void changeFocus(); ///< called internally when window has lost focus and has regained focus
127124
protected:
128125

129126
/** get the key data for a single key, KEY_NONE should be returned when

GeneralsMD/Code/GameEngine/Source/GameClient/Input/Keyboard.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -759,25 +759,9 @@ void Keyboard::resetKeys( void )
759759
}
760760

761761
//-------------------------------------------------------------------------------------------------
762-
// called when window has lost focus
762+
// called when window has lost focus and has regained focus
763763
//-------------------------------------------------------------------------------------------------
764-
void Keyboard::loseFocus()
765-
{
766-
changeFocus();
767-
}
768-
769-
//-------------------------------------------------------------------------------------------------
770-
// called when window has regained focus
771-
//-------------------------------------------------------------------------------------------------
772-
void Keyboard::regainFocus()
773-
{
774-
changeFocus();
775-
}
776-
777-
//-------------------------------------------------------------------------------------------------
778-
// called internally when window has lost focus and has regained focus
779-
//-------------------------------------------------------------------------------------------------
780-
void Keyboard::changeFocus()
764+
void Keyboard::toggleFocus()
781765
{
782766
// TheSuperHackers @fix Caball009 13/12/2025 Fix bug where game remains in waypoint mode
783767
// because the key up state for the alt key is not detected after alt tab.

GeneralsMD/Code/Main/WinMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
420420
case WM_SETFOCUS:
421421
{
422422
if (TheKeyboard)
423-
TheKeyboard->regainFocus();
423+
TheKeyboard->toggleFocus();
424424

425425
if (TheMouse)
426426
TheMouse->regainFocus();
@@ -432,7 +432,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
432432
case WM_KILLFOCUS:
433433
{
434434
if (TheKeyboard)
435-
TheKeyboard->loseFocus();
435+
TheKeyboard->toggleFocus();
436436

437437
if (TheMouse)
438438
{

0 commit comments

Comments
 (0)