Skip to content

Commit

Permalink
Platform: expose window/framebuffer size in *XApplication classes.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mosra committed Aug 22, 2018
1 parent 769bc0d commit c0125fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Magnum/Platform/AbstractXApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
19 changes: 18 additions & 1 deletion src/Magnum/Platform/AbstractXApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit c0125fa

Please sign in to comment.