summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-03-08 13:48:32 +0100
committerPatric Stout <github@truebrain.nl>2021-03-08 19:18:55 +0100
commit3a4a15cc93015ce5bed4f7720d4f0f05178c09e9 (patch)
tree5b1b712f94bd391617aea7b19f08d5df6e52e1b0 /src/video
parentb9eac7c6dc5ca1e60c84aa32805936b616f68d6e (diff)
downloadopenttd-3a4a15cc93015ce5bed4f7720d4f0f05178c09e9.tar.xz
Codechange: don't set the window position when changing blitter
There really is no need to make an extra call to the OS in these cases.
Diffstat (limited to 'src/video')
-rw-r--r--src/video/win32_v.cpp9
-rw-r--r--src/video/win32_v.h2
2 files changed, 6 insertions, 5 deletions
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index d8841671a..894d1e05d 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -128,9 +128,10 @@ uint8 VideoDriver_Win32Base::GetFullscreenBpp()
/**
* Instantiate a new window.
* @param full_screen Whether to make a full screen window or not.
+ * @param resize Whether to change window size.
* @return True if the window could be created.
*/
-bool VideoDriver_Win32Base::MakeWindow(bool full_screen)
+bool VideoDriver_Win32Base::MakeWindow(bool full_screen, bool resize)
{
/* full_screen is whether the new window should be fullscreen,
* _wnd.fullscreen is whether the current window is. */
@@ -172,7 +173,7 @@ bool VideoDriver_Win32Base::MakeWindow(bool full_screen)
}
if (ChangeDisplaySettings(&settings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL) {
- this->MakeWindow(false); // don't care about the result
+ this->MakeWindow(false, resize); // don't care about the result
return false; // the request failed
}
} else if (this->fullscreen) {
@@ -205,7 +206,7 @@ bool VideoDriver_Win32Base::MakeWindow(bool full_screen)
h = r.bottom - r.top;
if (this->main_wnd != nullptr) {
- if (!_window_maximize) SetWindowPos(this->main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
+ if (!_window_maximize && resize) SetWindowPos(this->main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
} else {
int x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2;
int y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2;
@@ -1043,7 +1044,7 @@ bool VideoDriver_Win32GDI::AllocateBackingStore(int w, int h, bool force)
bool VideoDriver_Win32GDI::AfterBlitterChange()
{
assert(BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 0);
- return this->AllocateBackingStore(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen);
+ return this->AllocateBackingStore(_screen.width, _screen.height, true) && this->MakeWindow(_fullscreen, false);
}
void VideoDriver_Win32GDI::MakePalette()
diff --git a/src/video/win32_v.h b/src/video/win32_v.h
index 03733d022..fc705c3f1 100644
--- a/src/video/win32_v.h
+++ b/src/video/win32_v.h
@@ -54,7 +54,7 @@ protected:
bool PollEvent() override;
void Initialize();
- bool MakeWindow(bool full_screen);
+ bool MakeWindow(bool full_screen, bool resize = true);
void ClientSizeChanged(int w, int h, bool force = false);
/** Get screen depth to use for fullscreen mode. */