summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/graphicsmanager.cpp13
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp28
-rw-r--r--src/gui/widgets/tabs/setup_video.h4
-rw-r--r--src/render/graphics.cpp40
-rw-r--r--src/render/graphics.h7
-rw-r--r--src/render/graphicsdef.hpp3
-rw-r--r--src/render/imagegraphics.h4
-rw-r--r--src/render/mobileopengl2graphics.cpp14
-rw-r--r--src/render/mobileopenglgraphics.cpp12
-rw-r--r--src/render/modernopenglgraphics.cpp14
-rw-r--r--src/render/normalopenglgraphics.cpp12
-rw-r--r--src/render/nullopenglgraphics.cpp12
-rw-r--r--src/render/safeopenglgraphics.cpp14
-rw-r--r--src/render/sdl2graphics.cpp14
-rw-r--r--src/render/sdl2softwaregraphics.cpp12
-rw-r--r--src/render/sdlgraphics.cpp12
-rw-r--r--src/render/surfacegraphics.h4
18 files changed, 182 insertions, 38 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index eaa2bcdb3..e7cd485ca 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -416,6 +416,7 @@ void setConfigDefaults(Configuration &cfg)
AddDEF("enableDSA", true);
AddDEF("blockAltTab", true);
AddDEF("sdlLogLevel", 0);
+ AddDEF("allowHighDPI", false);
}
void setConfigDefaults2(Configuration &cfg)
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 0335fe53f..dd730af82 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -454,6 +454,7 @@ void GraphicsManager::setVideoMode()
const bool hwaccel = config.getBoolValue("hwaccel");
const bool enableResize = config.getBoolValue("enableresize");
const bool noFrame = config.getBoolValue("noframe");
+ const bool allowHighDPI = config.getBoolValue("allowHighDPI");
#ifdef ANDROID
// int width = config.getValue("screenwidth", 0);
@@ -488,7 +489,7 @@ void GraphicsManager::setVideoMode()
// Try to set the desired video mode
if (!mainGraphics->setVideoMode(width, height, scale, bpp,
- fullscreen, hwaccel, enableResize, noFrame))
+ fullscreen, hwaccel, enableResize, noFrame, allowHighDPI))
{
logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s",
width, height, bpp, SDL_GetError()));
@@ -505,8 +506,14 @@ void GraphicsManager::setVideoMode()
config.setValueInt("screenwidth", oldWidth);
config.setValueInt("screenheight", oldHeight);
config.setValue("screen", oldFullscreen == 1);
- if (!mainGraphics->setVideoMode(oldWidth, oldHeight, scale, bpp,
- oldFullscreen != 0, hwaccel, enableResize, noFrame))
+ if (!mainGraphics->setVideoMode(oldWidth, oldHeight,
+ scale,
+ bpp,
+ oldFullscreen != 0,
+ hwaccel,
+ enableResize,
+ noFrame,
+ allowHighDPI))
{
logger->safeError(strprintf("Couldn't restore %dx%dx%d "
"video mode: %s", oldWidth, oldHeight, bpp,
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index 785ab5a33..b5b74e2b9 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -90,6 +90,11 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
mCustomCursorEnabled(config.getBoolValue("customcursor")),
mEnableResize(config.getBoolValue("enableresize")),
mNoFrame(config.getBoolValue("noframe")),
+#ifdef USE_SDL2
+ mAllowHighDPI(config.getBoolValue("allowHighDPI")),
+ // TRANSLATORS: video settings checkbox
+ mAllowHighDPICheckBox(new CheckBox(this, _("High DPI"), mAllowHighDPI)),
+#endif // USE_SDL2
mCustomCursorCheckBox(new CheckBox(this,
#ifdef ANDROID
// TRANSLATORS: video settings checkbox
@@ -145,6 +150,10 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
mOpenGLDropDown->setActionEventId("opengl");
mEnableResizeCheckBox->setActionEventId("enableresize");
mNoFrameCheckBox->setActionEventId("noframe");
+#ifdef USE_SDL2
+ mAllowHighDPICheckBox->setActionEventId("allowHighDPI");
+ mAllowHighDPICheckBox->addActionListener(this);
+#endif // USE_SDL2
mModeList->addActionListener(this);
mCustomCursorCheckBox->addActionListener(this);
@@ -168,6 +177,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
place(1, 2, mEnableResizeCheckBox, 2);
place(1, 3, mNoFrameCheckBox, 2);
+#ifdef USE_SDL2
+ place(1, 4, mAllowHighDPICheckBox, 2);
+#endif // USE_SDL2
place(0, 6, mFpsSlider);
place(1, 6, mFpsCheckBox).setPadding(3);
@@ -312,6 +324,9 @@ void Setup_Video::apply()
mOpenGLEnabled = intToRenderType(config.getIntValue("opengl"));
mEnableResize = config.getBoolValue("enableresize");
mNoFrame = config.getBoolValue("noframe");
+#ifdef USE_SDL2
+ mAllowHighDPI = config.getBoolValue("allowHighDPI");
+#endif // USE_SDL2
}
void Setup_Video::cancel()
@@ -331,6 +346,9 @@ void Setup_Video::cancel()
mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps));
mEnableResizeCheckBox->setSelected(mEnableResize);
mNoFrameCheckBox->setSelected(mNoFrame);
+#ifdef USE_SDL2
+ mAllowHighDPICheckBox->setSelected(mAllowHighDPI);
+#endif // USE_SDL2
config.setValue("screen", mFullScreenEnabled);
@@ -344,7 +362,9 @@ void Setup_Video::cancel()
config.setValue("customcursor", mCustomCursorEnabled);
config.setValue("opengl", CAST_S32(mOpenGLEnabled));
config.setValue("enableresize", mEnableResize);
- config.setValue("noframe", mNoFrame);
+#ifdef USE_SDL2
+ config.setValue("allowHighDPI", mAllowHighDPI);
+#endif // USE_SDL2
}
void Setup_Video::action(const ActionEvent &event)
@@ -485,6 +505,12 @@ void Setup_Video::action(const ActionEvent &event)
{
config.setValue("noframe", mNoFrameCheckBox->isSelected());
}
+#ifdef USE_SDL2
+ else if (id == "allowHighDPI")
+ {
+ config.setValue("allowHighDPI", mAllowHighDPICheckBox->isSelected());
+ }
+#endif // USE_SDL2
#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__)
else if (id == "detect")
{
diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h
index 6c3b09e9e..e327a29d8 100644
--- a/src/gui/widgets/tabs/setup_video.h
+++ b/src/gui/widgets/tabs/setup_video.h
@@ -76,6 +76,10 @@ class Setup_Video final : public SetupTab,
bool mCustomCursorEnabled;
bool mEnableResize;
bool mNoFrame;
+#ifdef USE_SDL2
+ bool mAllowHighDPI;
+ CheckBox *mAllowHighDPICheckBox;
+#endif // USE_SDL2
CheckBox *mCustomCursorCheckBox;
CheckBox *mEnableResizeCheckBox;
CheckBox *mNoFrameCheckBox;
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index 82a4cbfd6..8ee3b5efa 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -137,6 +137,7 @@ Graphics::Graphics() :
mOpenGL(RENDER_SOFTWARE),
mEnableResize(false),
mNoFrame(false),
+ mAllowHighDPI(false),
mName("Unknown"),
mStartFreeMem(0),
mSync(false),
@@ -183,7 +184,8 @@ void Graphics::setMainFlags(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
{
logger->log("graphics backend: %s", getName().c_str());
logger->log("Setting video mode %dx%d %s",
@@ -194,6 +196,7 @@ void Graphics::setMainFlags(const int w, const int h,
mHWAccel = hwaccel;
mEnableResize = resize;
mNoFrame = noFrame;
+ mAllowHighDPI = allowHighDPI;
mActualWidth = w;
mActualHeight = h;
setScale(scale);
@@ -243,6 +246,8 @@ int Graphics::getOpenGLFlags() const restrict2
int displayFlags = SDL_WINDOW_OPENGL;
if (mFullscreen)
displayFlags |= SDL_WINDOW_FULLSCREEN;
+ if (mAllowHighDPI)
+ displayFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
#else // USE_SDL2
int displayFlags = SDL_ANYFORMAT | SDL_OPENGL;
@@ -382,6 +387,8 @@ int Graphics::getSoftwareFlags() const restrict2
{
#ifdef USE_SDL2
int displayFlags = SDL_WINDOW_SHOWN;
+ if (mAllowHighDPI)
+ displayFlags |= SDL_WINDOW_ALLOW_HIGHDPI;
#else // USE_SDL2
int displayFlags = SDL_ANYFORMAT;
@@ -525,8 +532,15 @@ bool Graphics::setFullscreen(const bool fs) restrict2
if (mFullscreen == fs)
return true;
- return setVideoMode(mActualWidth, mActualHeight, mScale, mBpp, fs,
- mHWAccel, mEnableResize, mNoFrame);
+ return setVideoMode(mActualWidth,
+ mActualHeight,
+ mScale,
+ mBpp,
+ fs,
+ mHWAccel,
+ mEnableResize,
+ mNoFrame,
+ mAllowHighDPI);
}
bool Graphics::resizeScreen(const int width,
@@ -580,15 +594,27 @@ bool Graphics::resizeScreen(const int width,
else
#endif // __native_client__
{
- success = setVideoMode(width, height, mScale, mBpp,
- mFullscreen, mHWAccel, mEnableResize, mNoFrame);
+ success = setVideoMode(width, height,
+ mScale,
+ mBpp,
+ mFullscreen,
+ mHWAccel,
+ mEnableResize,
+ mNoFrame,
+ mAllowHighDPI);
// If it didn't work, try to restore the previous size. If that didn't
// work either, bail out (but then we're in deep trouble).
if (!success)
{
- if (!setVideoMode(prevWidth, prevHeight, mScale, mBpp,
- mFullscreen, mHWAccel, mEnableResize, mNoFrame))
+ if (!setVideoMode(prevWidth, prevHeight,
+ mScale,
+ mBpp,
+ mFullscreen,
+ mHWAccel,
+ mEnableResize,
+ mNoFrame,
+ mAllowHighDPI))
{
return false;
}
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 6eb18dfab..87f2f1429 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -161,7 +161,8 @@ class Graphics notfinal
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2 = 0;
+ const bool noFrame,
+ const bool allowHighDPI) restrict2 = 0;
/**
* Set fullscreen mode.
@@ -496,7 +497,8 @@ class Graphics notfinal
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2;
+ const bool noFrame,
+ const bool allowHighDPI) restrict2;
int getOpenGLFlags() const restrict2 A_WARN_UNUSED;
@@ -542,6 +544,7 @@ class Graphics notfinal
RenderType mOpenGL;
bool mEnableResize;
bool mNoFrame;
+ bool mAllowHighDPI;
std::string mName;
int mStartFreeMem;
bool mSync;
diff --git a/src/render/graphicsdef.hpp b/src/render/graphicsdef.hpp
index 7217361c0..8f8cf93ed 100644
--- a/src/render/graphicsdef.hpp
+++ b/src/render/graphicsdef.hpp
@@ -111,7 +111,8 @@ public:
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2 override final;
+ const bool noFrame,
+ const bool allowHighDPI) restrict2 override final;
void drawImage(const Image *restrict const image,
int dstX, int dstY) restrict2 override final;
diff --git a/src/render/imagegraphics.h b/src/render/imagegraphics.h
index fde338ec3..2b3e5bd71 100644
--- a/src/render/imagegraphics.h
+++ b/src/render/imagegraphics.h
@@ -168,7 +168,9 @@ class ImegeGraphics final : public Graphics
const int bpp A_UNUSED,
const bool fs A_UNUSED, const bool hwaccel A_UNUSED,
const bool resize A_UNUSED,
- const bool noFrame A_UNUSED) restrict2 override final
+ const bool noFrame A_UNUSED,
+ const bool allowHighDPI A_UNUSED)
+ restrict2 override final
{ return false; }
void drawImage(const Image *const image,
diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp
index 919eb67fe..03fe5d016 100644
--- a/src/render/mobileopengl2graphics.cpp
+++ b/src/render/mobileopengl2graphics.cpp
@@ -236,9 +236,17 @@ bool MobileOpenGL2Graphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
-{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
+{
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
return setOpenGLMode();
}
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index 8118e96a4..0f3ce09ea 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -154,9 +154,17 @@ bool MobileOpenGLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
return setOpenGLMode();
}
diff --git a/src/render/modernopenglgraphics.cpp b/src/render/modernopenglgraphics.cpp
index 6950f4555..be1ec4f73 100644
--- a/src/render/modernopenglgraphics.cpp
+++ b/src/render/modernopenglgraphics.cpp
@@ -237,9 +237,17 @@ bool ModernOpenGLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
-{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
+{
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
return setOpenGLMode();
}
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index a03ae4341..96aca6f15 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -178,9 +178,17 @@ bool NormalOpenGLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
return setOpenGLMode();
}
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index ff4a765bf..265ac92f1 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -99,9 +99,17 @@ bool NullOpenGLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
return setOpenGLMode();
}
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 43a22bea3..e65ff94b0 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -64,9 +64,17 @@ bool SafeOpenGLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
-{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
+{
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
return setOpenGLMode();
}
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index a8b5515c4..baa69ca69 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -740,9 +740,17 @@ bool SDLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
-{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
+{
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 789ec413b..808f7c601 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -1465,9 +1465,17 @@ bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index 9220f530e..b67e23d8e 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -1474,9 +1474,17 @@ bool SDLGraphics::setVideoMode(const int w, const int h,
const bool fs,
const bool hwaccel,
const bool resize,
- const bool noFrame) restrict2
+ const bool noFrame,
+ const bool allowHighDPI) restrict2
{
- setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h,
+ scale,
+ bpp,
+ fs,
+ hwaccel,
+ resize,
+ noFrame,
+ allowHighDPI);
if ((mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())) == nullptr)
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index 095b320c7..2e46c9f1e 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -177,7 +177,9 @@ class SurfaceGraphics final : public Graphics
const int bpp A_UNUSED,
const bool fs A_UNUSED, const bool hwaccel A_UNUSED,
const bool resize A_UNUSED,
- const bool noFrame A_UNUSED) restrict2 override final
+ const bool noFrame A_UNUSED,
+ const bool allowHighDPI A_UNUSED)
+ restrict2 override final
{ return false; }
void drawImage(const Image *restrict const image,