Browse Source

Platform: print the "HiDPI not enabled" warning at most once on macOS.

If the application is constructed with delayed window creation, the
warning would be printed on each context creation attempt / call to
dpiScaling(const Configuration&), which is silly.
mousecapture
Vladimír Vondruš 6 years ago
parent
commit
7d37647897
  1. 11
      src/Magnum/Platform/GlfwApplication.cpp
  2. 4
      src/Magnum/Platform/GlfwApplication.h
  3. 13
      src/Magnum/Platform/Sdl2Application.cpp
  4. 4
      src/Magnum/Platform/Sdl2Application.h

11
src/Magnum/Platform/GlfwApplication.cpp

@ -54,7 +54,10 @@ static_assert(GLFW_TRUE == true && GLFW_FALSE == false, "GLFW does not have sane
enum class GlfwApplication::Flag: UnsignedByte {
Redraw = 1 << 0,
TextInputActive = 1 << 1
TextInputActive = 1 << 1,
#ifdef CORRADE_TARGET_APPLE
HiDpiWarningPrinted = 1 << 2
#endif
};
GlfwApplication::GlfwApplication(const Arguments& arguments): GlfwApplication{arguments, Configuration{}} {}
@ -127,14 +130,16 @@ void GlfwApplication::create(const Configuration& configuration, const GLConfigu
}
#endif
Vector2 GlfwApplication::dpiScaling(const Configuration& configuration) const {
Vector2 GlfwApplication::dpiScaling(const Configuration& configuration) {
std::ostream* verbose = _verboseLog ? Debug::output() : nullptr;
/* Print a helpful warning in case some extra steps are needed for HiDPI
support */
#ifdef CORRADE_TARGET_APPLE
if(!Implementation::isAppleBundleHiDpiEnabled())
if(!Implementation::isAppleBundleHiDpiEnabled() && !(_flags & Flag::HiDpiWarningPrinted)) {
Warning{} << "Platform::GlfwApplication: warning: the executable is not a HiDPI-enabled app bundle";
_flags |= Flag::HiDpiWarningPrinted;
}
#elif defined(CORRADE_TARGET_WINDOWS)
/** @todo */
#endif

4
src/Magnum/Platform/GlfwApplication.h

@ -428,7 +428,7 @@ class GlfwApplication {
*
* How the content should be scaled relative to system defaults for
* given @ref windowSize(). If a window is not created yet, returns
* zero vector, use @ref dpiScaling(const Configuration&) const for
* zero vector, use @ref dpiScaling(const Configuration&) for
* calculating a value independently. See @ref Platform-GlfwApplication-dpi
* for more information.
* @see @ref framebufferSize()
@ -443,7 +443,7 @@ class GlfwApplication {
* and custom scaling specified on the command-line. See
* @ref Platform-GlfwApplication-dpi for more information.
*/
Vector2 dpiScaling(const Configuration& configuration) const;
Vector2 dpiScaling(const Configuration& configuration);
/**
* @brief Set window title

13
src/Magnum/Platform/Sdl2Application.cpp

@ -87,7 +87,10 @@ enum class Sdl2Application::Flag: UnsignedByte {
Exit = 1 << 4,
#ifdef CORRADE_TARGET_EMSCRIPTEN
TextInputActive = 1 << 5,
Resizable = 1 << 6
Resizable = 1 << 6,
#endif
#ifdef CORRADE_TARGET_APPLE
HiDpiWarningPrinted = 1 << 7
#endif
};
@ -180,16 +183,18 @@ void Sdl2Application::create(const Configuration& configuration, const GLConfigu
}
#endif
Vector2 Sdl2Application::dpiScaling(const Configuration& configuration) const {
Vector2 Sdl2Application::dpiScaling(const Configuration& configuration) {
std::ostream* verbose = _verboseLog ? Debug::output() : nullptr;
/* Print a helpful warning in case some extra steps are needed for HiDPI
support */
#ifdef CORRADE_TARGET_APPLE
if(!Implementation::isAppleBundleHiDpiEnabled())
if(!Implementation::isAppleBundleHiDpiEnabled() && !(_flags & Flag::HiDpiWarningPrinted)) {
Warning{} << "Platform::Sdl2Application: warning: the executable is not a HiDPI-enabled app bundle";
_flags |= Flag::HiDpiWarningPrinted;
}
#elif defined(CORRADE_TARGET_WINDOWS)
/** @todo */
/* Handled below, warning printed only when using virtual DPI scaling */
#endif
/* Use values from the configuration only if not overriden on command line.

4
src/Magnum/Platform/Sdl2Application.h

@ -730,7 +730,7 @@ class Sdl2Application {
*
* How the content should be scaled relative to system defaults for
* given @ref windowSize(). If a window is not created yet, returns
* zero vector, use @ref dpiScaling(const Configuration&) const for
* zero vector, use @ref dpiScaling(const Configuration&) for
* calculating a value independently. See @ref Platform-Sdl2Application-dpi
* for more information.
* @see @ref framebufferSize()
@ -745,7 +745,7 @@ class Sdl2Application {
* and custom scaling specified on the command-line. See
* @ref Platform-Sdl2Application-dpi for more information.
*/
Vector2 dpiScaling(const Configuration& configuration) const;
Vector2 dpiScaling(const Configuration& configuration);
/**
* @brief Set window title

Loading…
Cancel
Save