aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Client/Windows64/Windows64_Minecraft.cpp')
-rw-r--r--Minecraft.Client/Windows64/Windows64_Minecraft.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
index 4cd10fa2..cc589771 100644
--- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
+++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp
@@ -79,6 +79,10 @@ BOOL g_bWidescreen = TRUE;
int g_iScreenWidth = 1920;
int g_iScreenHeight = 1080;
+// Fullscreen toggle state
+static bool g_isFullscreen = false;
+static WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
+
void DefineActions(void)
{
// The app needs to define the actions required, and the possible mappings for these
@@ -642,6 +646,36 @@ void Render()
}
//--------------------------------------------------------------------------------------
+// Toggle borderless fullscreen
+//--------------------------------------------------------------------------------------
+void ToggleFullscreen()
+{
+ DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE);
+ if (!g_isFullscreen)
+ {
+ MONITORINFO mi = { sizeof(mi) };
+ if (GetWindowPlacement(g_hWnd, &g_wpPrev) &&
+ GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi))
+ {
+ SetWindowLong(g_hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW);
+ SetWindowPos(g_hWnd, HWND_TOP,
+ mi.rcMonitor.left, mi.rcMonitor.top,
+ mi.rcMonitor.right - mi.rcMonitor.left,
+ mi.rcMonitor.bottom - mi.rcMonitor.top,
+ SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
+ }
+ }
+ else
+ {
+ SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW);
+ SetWindowPlacement(g_hWnd, &g_wpPrev);
+ SetWindowPos(g_hWnd, NULL, 0, 0, 0, 0,
+ SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
+ }
+ g_isFullscreen = !g_isFullscreen;
+}
+
+//--------------------------------------------------------------------------------------
// Clean up the objects we've created
//--------------------------------------------------------------------------------------
void CleanupDevice()
@@ -1149,8 +1183,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
KMInput.SetCapture(true);
}
}
+
+ // F11 toggles fullscreen
+ if (KMInput.IsKeyPressed(VK_F11))
+ {
+ ToggleFullscreen();
+ }
+
#if 0
- PIXBeginNamedEvent(0,"Profile load check");
// has the game defined profile data been changed (by a profile load)
if(app.uiGameDefinedDataChangedBitmask!=0)
{