mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 06:12:19 +00:00
- added vid_setsize CCMD and fixed some issues with window restoration when switching from fullscreen.
Windows apparently cannot both undo borderless fullscreen and resize the window at the same time, so this must delay the resizing one frame.
This commit is contained in:
parent
369267bbe9
commit
156ed5790e
5 changed files with 88 additions and 6 deletions
|
@ -680,10 +680,10 @@ void D_Display ()
|
|||
// fullscreen toggle has been requested
|
||||
if (setmodeneeded)
|
||||
{
|
||||
setmodeneeded = false;
|
||||
screen->ToggleFullscreen(fullscreen);
|
||||
V_OutputResized(screen->GetWidth(), screen->GetHeight());
|
||||
setmodeneeded = false;
|
||||
}
|
||||
}
|
||||
|
||||
// change the view size if needed
|
||||
if (setsizeneeded)
|
||||
|
|
|
@ -857,6 +857,20 @@ void ScaleWithAspect (int &w, int &h, int Width, int Height)
|
|||
h = static_cast<int>(y);
|
||||
}
|
||||
|
||||
CCMD(vid_setsize)
|
||||
{
|
||||
if (argv.argc() < 2)
|
||||
{
|
||||
Printf("Usage: vid_setsize width height\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->SetWindowSize((int)strtol(argv[1], nullptr, 0), (int)strtol(argv[2], nullptr, 0));
|
||||
V_OutputResized(screen->GetClientWidth(), screen->GetClientHeight());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IVideo::DumpAdapters ()
|
||||
{
|
||||
Printf("Multi-monitor support unavailable.\n");
|
||||
|
|
|
@ -423,6 +423,7 @@ public:
|
|||
virtual void UnbindTexUnit(int no) {}
|
||||
virtual void TextureFilterChanged() {}
|
||||
virtual void BeginFrame() {}
|
||||
virtual void SetWindowSize(int w, int h) {}
|
||||
|
||||
virtual int GetClientWidth() = 0;
|
||||
virtual int GetClientHeight() = 0;
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "doomerrors.h"
|
||||
#include "base_sysfb.h"
|
||||
#include "win32basevideo.h"
|
||||
#include "c_dispatch.h"
|
||||
|
||||
|
||||
extern HWND Window;
|
||||
|
@ -69,6 +70,7 @@ CVAR(Bool, win_maximized, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
|
||||
EXTERN_CVAR(Int, vid_defwidth)
|
||||
EXTERN_CVAR(Int, vid_defheight)
|
||||
EXTERN_CVAR(Bool, fullscreen)
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
@ -226,6 +228,64 @@ void SystemBaseFrameBuffer::RestoreWindowedPos()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void SystemBaseFrameBuffer::SetWindowSize(int w, int h)
|
||||
{
|
||||
if (w < 0 || h < 0)
|
||||
{
|
||||
RestoreWindowedPos();
|
||||
}
|
||||
else
|
||||
{
|
||||
LONG style = WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW;
|
||||
LONG exStyle = WS_EX_WINDOWEDGE;
|
||||
SetWindowLong(Window, GWL_STYLE, style);
|
||||
SetWindowLong(Window, GWL_EXSTYLE, exStyle);
|
||||
|
||||
int winx, winy, winw, winh, scrwidth, scrheight;
|
||||
|
||||
RECT r = { 0, 0, w, h };
|
||||
AdjustWindowRectEx(&r, style, false, exStyle);
|
||||
w = int(r.right - r.left);
|
||||
h = int(r.bottom - r.top);
|
||||
|
||||
GetCenteredPos(w, h, winx, winy, winw, winh, scrwidth, scrheight);
|
||||
|
||||
// Just move to (0,0) if we were run with the -0 option.
|
||||
if (Args->CheckParm("-0"))
|
||||
{
|
||||
winx = winy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeepWindowOnScreen(winx, winy, winw, winh, scrwidth, scrheight);
|
||||
}
|
||||
|
||||
if (!fullscreen)
|
||||
{
|
||||
ShowWindow(Window, SW_SHOWNORMAL);
|
||||
SetWindowPos(Window, nullptr, winx, winy, winw, winh, SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
win_maximized = false;
|
||||
SetSize(GetClientWidth(), GetClientHeight());
|
||||
SaveWindowedPos();
|
||||
}
|
||||
else
|
||||
{
|
||||
win_x = winx;
|
||||
win_y = winy;
|
||||
win_w = winw;
|
||||
win_h = winh;
|
||||
win_maximized = false;
|
||||
fullscreen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void SystemBaseFrameBuffer::PositionWindow(bool fullscreen)
|
||||
{
|
||||
RECT r;
|
||||
|
@ -233,7 +293,7 @@ void SystemBaseFrameBuffer::PositionWindow(bool fullscreen)
|
|||
|
||||
RECT monRect;
|
||||
|
||||
if (!m_Fullscreen) SaveWindowedPos();
|
||||
if (!m_Fullscreen && fullscreen) SaveWindowedPos();
|
||||
if (m_Monitor)
|
||||
{
|
||||
MONITORINFOEX mi;
|
||||
|
@ -264,7 +324,6 @@ void SystemBaseFrameBuffer::PositionWindow(bool fullscreen)
|
|||
SetWindowLong(Window, GWL_STYLE, style);
|
||||
SetWindowLong(Window, GWL_EXSTYLE, exStyle);
|
||||
|
||||
m_Fullscreen = fullscreen;
|
||||
if (fullscreen)
|
||||
{
|
||||
SetWindowPos(Window, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||
|
@ -275,7 +334,14 @@ void SystemBaseFrameBuffer::PositionWindow(bool fullscreen)
|
|||
else
|
||||
{
|
||||
RestoreWindowedPos();
|
||||
// This doesn't restore the window size properly so we must force a set size the next tic.
|
||||
if (m_Fullscreen)
|
||||
{
|
||||
::fullscreen = false;
|
||||
}
|
||||
|
||||
}
|
||||
m_Fullscreen = fullscreen;
|
||||
SetSize(GetClientWidth(), GetClientHeight());
|
||||
}
|
||||
|
||||
|
@ -306,7 +372,7 @@ SystemBaseFrameBuffer::SystemBaseFrameBuffer(void *hMonitor, bool fullscreen) :
|
|||
SystemBaseFrameBuffer::~SystemBaseFrameBuffer()
|
||||
{
|
||||
ResetGammaTable();
|
||||
SaveWindowedPos();
|
||||
if (!m_Fullscreen) SaveWindowedPos();
|
||||
|
||||
ShowWindow (Window, SW_SHOW);
|
||||
SetWindowLong(Window, GWL_STYLE, WS_VISIBLE | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW);
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
|
||||
bool IsFullscreen() override;
|
||||
void ToggleFullscreen(bool yes) override;
|
||||
void SetWindowSize(int client_w, int client_h);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -35,7 +36,7 @@ protected:
|
|||
float m_Gamma, m_Brightness, m_Contrast;
|
||||
uint16_t m_origGamma[768];
|
||||
bool m_supportsGamma;
|
||||
bool m_Fullscreen;
|
||||
bool m_Fullscreen = false;
|
||||
char m_displayDeviceNameBuffer[32/*CCHDEVICENAME*/]; // do not use windows.h constants here!
|
||||
char *m_displayDeviceName;
|
||||
void *m_Monitor;
|
||||
|
|
Loading…
Reference in a new issue