-
Notifications
You must be signed in to change notification settings - Fork 185
feat(input): Add Alt+Enter support for fullscreen toggling #2608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,9 +51,11 @@ | |
| #include "Common/GameMemory.h" | ||
| #include "Common/StackDump.h" | ||
| #include "Common/MessageStream.h" | ||
| #include "Common/OptionPreferences.h" | ||
| #include "Common/Registry.h" | ||
| #include "Common/Team.h" | ||
| #include "GameClient/ClientInstance.h" | ||
| #include "GameClient/Display.h" | ||
| #include "GameClient/InGameUI.h" | ||
| #include "GameClient/GameClient.h" | ||
| #include "GameLogic/GameLogic.h" ///< @todo for demo, remove | ||
|
|
@@ -655,6 +657,58 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, | |
| break; | ||
| } | ||
| #endif | ||
| case WM_SYSKEYDOWN: | ||
| { | ||
| if (wParam == VK_RETURN && (lParam & (1 << 29))) // Alt + Enter | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the key needs to be configurable in ini - with a default value if not set
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a problem, but what specific use case do you have in mind for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| { | ||
| if (TheGameEngine && !TheGameEngine->getQuitting() && TheDisplay) | ||
| { | ||
| TheWritableGlobalData->m_windowed = !TheGlobalData->m_windowed; | ||
|
|
||
| DWORD windowStyle = WS_POPUP | WS_VISIBLE; | ||
| DWORD exStyle = 0; | ||
| Int resX = TheGlobalData->m_xResolution; | ||
| Int resY = TheGlobalData->m_yResolution; | ||
|
|
||
| if (TheGlobalData->m_windowed) | ||
| { | ||
| windowStyle |= WS_MINIMIZEBOX | WS_SYSMENU | WS_DLGFRAME | WS_CAPTION; | ||
| } | ||
| else | ||
| { | ||
| windowStyle |= WS_SYSMENU; | ||
| exStyle |= WS_EX_TOPMOST; | ||
| } | ||
|
|
||
| RECT windowRect = { 0, 0, resX, resY }; | ||
| AdjustWindowRect(&windowRect, windowStyle, FALSE); | ||
| int width = windowRect.right - windowRect.left; | ||
| int height = windowRect.bottom - windowRect.top; | ||
|
|
||
| int x = 0, y = 0; | ||
| if (TheGlobalData->m_windowed) | ||
| { | ||
| x = max(0, (GetSystemMetrics(SM_CXSCREEN) - width) / 2); | ||
| y = max(0, (GetSystemMetrics(SM_CYSCREEN) - height) / 2); | ||
| } | ||
|
|
||
| TheDisplay->setDisplayMode(resX, resY, 32, TheGlobalData->m_windowed); | ||
|
|
||
| OptionPreferences optionPref; | ||
| optionPref.setWindowed(TheGlobalData->m_windowed); | ||
| optionPref.write(); | ||
|
|
||
| // TheSuperHackers @info Apply styles and position after mode switch | ||
| SetWindowLong(hWnd, GWL_STYLE, windowStyle); | ||
| SetWindowLong(hWnd, GWL_EXSTYLE, exStyle); | ||
| SetWindowPos(hWnd, TheGlobalData->m_windowed ? HWND_NOTOPMOST : HWND_TOPMOST, | ||
| x, y, width, height, SWP_FRAMECHANGED | SWP_SHOWWINDOW); | ||
| UpdateWindow(hWnd); | ||
| } | ||
| return 0; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WM_SYSKEYDOWNfires on auto-repeat when the user holds Enter while Alt is pressed. Bit 30 oflParamis 1 when the key was already held on the previous message; without checking it, every queued repeat will trigger a full D3D device reset, leaving the display in an undefined or flickering state.Add
!(lParam & (1 << 30))to the guard to accept only the initial key-down transition:Prompt To Fix With AI