Browse Source

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.
pull/272/head
Vladimír Vondruš 8 years ago
parent
commit
c0125fa469
  1. 6
      src/Magnum/Platform/AbstractXApplication.cpp
  2. 19
      src/Magnum/Platform/AbstractXApplication.h

6
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;
}

19
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<Platform::GLContext> _context;
/** @todo Get this from the created window */
Vector2i _viewportSize;
Vector2i _windowSize;
Flags _flags;
};

Loading…
Cancel
Save