From c0125fa469c2823275b68e512781a0b6e481c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 19 Aug 2018 18:24:49 +0200 Subject: [PATCH] Platform: expose window/framebuffer size in *XApplication classes. For consistency with the new Sdl2Application implementation. The dpiScaling() function is not exposed, as I don't want to go through all the pain of getting this through raw Xlib -- and the *XApplication classes are meant to be used in very restricted embedded environments that probably don't have any HiDPI issues anyway. --- src/Magnum/Platform/AbstractXApplication.cpp | 6 +++--- src/Magnum/Platform/AbstractXApplication.h | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Platform/AbstractXApplication.cpp b/src/Magnum/Platform/AbstractXApplication.cpp index b9dfc8aa22..3b458d5e84 100644 --- a/src/Magnum/Platform/AbstractXApplication.cpp +++ b/src/Magnum/Platform/AbstractXApplication.cpp @@ -74,7 +74,7 @@ bool AbstractXApplication::tryCreate(const Configuration& configuration, const G CORRADE_ASSERT(_context->version() == GL::Version::None, "Platform::AbstractXApplication::tryCreate(): context already created", false); - _viewportSize = configuration.size(); + _windowSize = configuration.size(); /* Get default X display */ _display = XOpenDisplay(nullptr); @@ -154,8 +154,8 @@ int AbstractXApplication::exec() { /* Window resizing */ case ConfigureNotify: { Vector2i size(event.xconfigure.width, event.xconfigure.height); - if(size != _viewportSize) { - _viewportSize = size; + if(size != _windowSize) { + _windowSize = size; viewportEvent(size); _flags |= Flag::Redraw; } diff --git a/src/Magnum/Platform/AbstractXApplication.h b/src/Magnum/Platform/AbstractXApplication.h index 069a6700fe..284ef6d5fa 100644 --- a/src/Magnum/Platform/AbstractXApplication.h +++ b/src/Magnum/Platform/AbstractXApplication.h @@ -179,6 +179,23 @@ class AbstractXApplication { /** @{ @name Screen handling */ + public: + /** + * @brief Window size + * + * Window size to which all input event coordinates can be related. + * Same as @ref framebufferSize(). + */ + Vector2i windowSize() const { return _windowSize; } + + /** + * @brief Framebuffer size + * + * Size of the default framebuffer. Same as @ref windowSize(). + */ + Vector2i framebufferSize() const { return _windowSize; } + + protected: /** * @brief Swap buffers * @@ -251,7 +268,7 @@ class AbstractXApplication { std::unique_ptr _context; /** @todo Get this from the created window */ - Vector2i _viewportSize; + Vector2i _windowSize; Flags _flags; };