From 2e15f60ef6f9025916611fc8495f95df4ed04a27 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 6 Feb 2017 15:09:09 +0000 Subject: [PATCH] Win32: implement support for full-screen graphics window. --- CHANGELOG.md | 1 + src/graphicswin.cpp | 4 ---- src/platform/w32main.cpp | 28 +++++++++++++++++++++++++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cfd461e..1b194fdd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ Other new features: * In expressions, numbers can contain the digit group separator, "_". * The "=" key is bound to "Zoom In", like "+" key. * The numpad decimal separator key is bound to "." regardless of locale. + * On Windows, full-screen mode is implemented. Bugs fixed: * A point in 3d constrained to any line whose length is free no longer diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 7f15bd88..076c5d39 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -81,10 +81,8 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { { 1, NULL, Command::NONE, 0, TN, NULL }, { 1, N_("Dimensions in &Inches"), Command::UNITS_INCHES, 0, TR, mView }, { 1, N_("Dimensions in &Millimeters"), Command::UNITS_MM, 0, TR, mView }, -#if defined(__unix__) || defined(__APPLE__) { 1, NULL, Command::NONE, 0, TN, NULL }, { 1, N_("&Full Screen"), Command::FULL_SCREEN, C|F(11), TC, mView }, -#endif { 0, N_("&New Group"), Command::NONE, 0, TN, NULL }, { 1, N_("Sketch In &3d"), Command::GROUP_3D, S|'3', TN, mGrp }, @@ -685,9 +683,7 @@ void GraphicsWindow::EnsureValidActives() { CheckMenuByCmd(Command::SHOW_TOOLBAR, /*checked=*/SS.showToolbar); CheckMenuByCmd(Command::PERSPECTIVE_PROJ, /*checked=*/SS.usePerspectiveProj); CheckMenuByCmd(Command::SHOW_GRID,/*checked=*/SS.GW.showSnapGrid); -#if defined(__unix__) || defined(__APPLE__) CheckMenuByCmd(Command::FULL_SCREEN, /*checked=*/FullScreenIsActive()); -#endif if(change) SS.ScheduleShowTW(); } diff --git a/src/platform/w32main.cpp b/src/platform/w32main.cpp index 63080cf3..5960f0e8 100644 --- a/src/platform/w32main.cpp +++ b/src/platform/w32main.cpp @@ -850,12 +850,34 @@ void SolveSpace::InvalidateGraphics() void SolveSpace::ToggleFullScreen() { - // Implement me + static WINDOWPLACEMENT wp; + wp.length = sizeof(wp); + + DWORD dwStyle = GetWindowLong(GraphicsWnd, GWL_STYLE); + if(dwStyle & WS_OVERLAPPEDWINDOW) { + MONITORINFO mi; + mi.cbSize = sizeof(mi); + + if(GetWindowPlacement(GraphicsWnd, &wp) && + GetMonitorInfo(MonitorFromWindow(GraphicsWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) { + SetWindowLong(GraphicsWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW); + SetWindowPos(GraphicsWnd, 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(GraphicsWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); + SetWindowPlacement(GraphicsWnd, &wp); + SetWindowPos(GraphicsWnd, NULL, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | + SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + } } bool SolveSpace::FullScreenIsActive() { - // Implement me - return false; + return GetWindowLong(GraphicsWnd, GWL_STYLE) & WS_OVERLAPPEDWINDOW; } void SolveSpace::InvalidateText()